openapi: 3.0.0
info:
  title: Luminous API
  version: 1.0.0
  description: API documentation for Luminous
servers:
  - url: 'https://{companyName}.api.joinluminous.com/external/api/v1'
    variables:
      companyName:
        default: companyName
        description: Your company-specific subdomain
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'Authenticate using a bearer token. To create a token, navigate to /settings/api-tokens and click Create API Token.'
paths:
  /products:
    get:
      operationId: getProducts
      tags:
        - Products
      summary: Products
      description: |
        Get a paginated list of products with optional filtering.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Product name
        - `description`: Product description
        - `sku`: Product SKU (searches both internal SKU and alternate SKUs)
        - `upc`: Product UPC/Barcode
        - `tag`: Product tags
        - `q`: General search matches name OR upc OR sku
        - `category.name`: Filter by category name
        - `sub_category.name`: Filter by sub-category name
        - `supplier.name`: Filter by supplier name
        - `priority_list.name`: Filter by fulfillment priority list name

        ### Integer Filters
        - `category.id`: Filter by category ID
        - `sub_category.id`: Filter by sub-category ID
        - `supplier.id`: Filter by supplier ID
        - `bom.id`: Filter by Bill of Materials ID (returns products attached to the specified BOM)
        - `kit_items.product_id`: Filter by kit item product ID (returns kit products that contain the specified product as a component)
        - `priority_list.id`: Filter by fulfillment priority list ID

        ### Enum Filters
        - `type`: Filter by product type (PRODUCT or KIT)

        ### Float Filters
        - `retail_price`: Product retail price
        - `wholesale_price`: Product wholesale price
        - `product_weight_oz`: Product weight total in ounces
        - `product_weight_lb`: Product weight total in pounds
        - `product_length`: Product length (in inches)
        - `product_width`: Product width (in inches)
        - `product_height`: Product height (in inches)
        - `box_length`: Box length (in inches)
        - `box_width`: Box width (in inches)
        - `box_height`: Box height (in inches)
        - `carton_length`: Carton length (in inches)
        - `carton_width`: Carton width (in inches)
        - `carton_height`: Carton height (in inches)
        - `shipping_length`: Shipping length (in inches)
        - `shipping_width`: Shipping width (in inches)
        - `shipping_height`: Shipping height (in inches)
        - `pallet_length`: Pallet length (in inches)
        - `pallet_width`: Pallet width (in inches)
        - `pallet_height`: Pallet height (in inches)

        ### Float Filters (Weight Totals)
        Weight fields are stored as JSON with multiple unit support. Filter by total weight using:
        - `box_weight_oz` / `box_weight_lb`: Box weight total
        - `carton_weight_oz` / `carton_weight_lb`: Carton weight total
        - `shipping_weight_oz` / `shipping_weight_lb`: Shipping weight total
        - `pallet_weight_oz` / `pallet_weight_lb`: Pallet weight total
        - `dimensional_weight_oz` / `dimensional_weight_lb`: Dimensional weight total

        ### Boolean Filters
        - `sellable`: If the product is sellable or not
        - `discontinued`: If the product is discontinued

        ### DateTime Filters
        - `created_at`: When the product was created
        - `updated_at`: When the product was last updated

        ## Examples
        ```
        # Find products by SKU (includes alternate SKUs)
        ?sku[eq]=SKU-001

        # Find products with specific price range
        ?retail_price[gte]=50.00&retail_price[lte]=100.00

        # Find recently updated products
        ?updated_at[gte]=2024-01-01 00:00:00

        # Search products by name
        ?name[contains]=Test Product

        # Find products by category and sub-category
        ?category.name[eq]=Electronics&sub_category.name[eq]=Smartphones

        # Find products by supplier
        ?supplier.name[contains]=Acme

        # Find products by type
        ?type=PRODUCT
        ?type=KIT

        # Find kit products that contain a specific product as a component
        ?kit_items.product_id=123

        # Find products by dimension filters
        ?product_length[gt]=10.0&product_width[lt]=20.0
        ?box_length[eq]=12.5
        ?carton_height[gte]=10.0
        ?shipping_length[lte]=18.0
        ?pallet_width[gt]=40.0

        # Find products by weight (filter by total oz or lb)
        ?shipping_weight_oz[gte]=64
        ?shipping_weight_lb[gt]=5.0
        ?product_weight_oz[lt]=200
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: include
          schema:
            type: string
          example: created_via
          description: |
            Comma-separated list of optional fields to include on each product. Pass
            `created_via` to include the product's creation source (omitted from list
            responses by default; always present on single-product responses).
        - in: query
          name: q
          schema:
            type: string
          description: Filter by name OR upc OR sku
        - in: query
          name: name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: description
          schema:
            type: string
          description: Filter by product description
        - in: query
          name: sku
          schema:
            type: string
          description: Filter by SKU (searches both internal and alternate SKUs)
        - in: query
          name: upc
          schema:
            type: string
          description: Filter by UPC/Barcode
        - in: query
          name: sellable
          schema:
            type: boolean
          description: Filter by sellable status
        - in: query
          name: discontinued
          schema:
            type: boolean
          description: Filter by whether the product is discontinued
        - in: query
          name: retail_price
          schema:
            type: number
            format: float
          description: Filter by retail price
        - in: query
          name: wholesale_price
          schema:
            type: number
            format: float
          description: Filter by wholesale price
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by product tags
        - in: query
          name: category.id
          schema:
            type: integer
          description: Filter by category ID
        - in: query
          name: category.name
          schema:
            type: string
          description: Filter by category name
        - in: query
          name: sub_category.id
          schema:
            type: integer
          description: Filter by sub-category ID
        - in: query
          name: sub_category.name
          schema:
            type: string
          description: Filter by sub-category name
        - in: query
          name: supplier.id
          schema:
            type: integer
          description: Filter by supplier ID
        - in: query
          name: supplier.name
          schema:
            type: string
          description: Filter by supplier name
        - in: query
          name: bom.id
          schema:
            type: integer
          description: Filter by Bill of Materials ID (returns products attached to the specified BOM)
        - in: query
          name: kit_items.product_id
          schema:
            type: integer
          description: Filter by kit item product ID (returns kit products that contain the specified product as a component)
        - in: query
          name: priority_list.id
          schema:
            type: integer
          description: Filter by fulfillment priority list ID
        - in: query
          name: priority_list.name
          schema:
            type: string
          description: Filter by fulfillment priority list name
        - in: query
          name: type
          schema:
            type: string
            enum:
              - PRODUCT
              - KIT
          description: 'Filter by product type (PRODUCT for regular products, KIT for kit products)'
        - in: query
          name: product_weight_oz
          schema:
            type: number
            format: float
          description: Filter by product weight total in ounces
        - in: query
          name: product_weight_lb
          schema:
            type: number
            format: float
          description: Filter by product weight total in pounds
        - in: query
          name: product_length
          schema:
            type: number
            format: float
          description: Filter by product length (in inches)
        - in: query
          name: product_width
          schema:
            type: number
            format: float
          description: Filter by product width (in inches)
        - in: query
          name: product_height
          schema:
            type: number
            format: float
          description: Filter by product height (in inches)
        - in: query
          name: box_weight_oz
          schema:
            type: number
            format: float
          description: Filter by box weight total in ounces
        - in: query
          name: box_weight_lb
          schema:
            type: number
            format: float
          description: Filter by box weight total in pounds
        - in: query
          name: box_length
          schema:
            type: number
            format: float
          description: Filter by box length (in inches)
        - in: query
          name: box_width
          schema:
            type: number
            format: float
          description: Filter by box width (in inches)
        - in: query
          name: box_height
          schema:
            type: number
            format: float
          description: Filter by box height (in inches)
        - in: query
          name: carton_weight_oz
          schema:
            type: number
            format: float
          description: Filter by carton weight total in ounces
        - in: query
          name: carton_weight_lb
          schema:
            type: number
            format: float
          description: Filter by carton weight total in pounds
        - in: query
          name: carton_length
          schema:
            type: number
            format: float
          description: Filter by carton length (in inches)
        - in: query
          name: carton_width
          schema:
            type: number
            format: float
          description: Filter by carton width (in inches)
        - in: query
          name: carton_height
          schema:
            type: number
            format: float
          description: Filter by carton height (in inches)
        - in: query
          name: shipping_weight_oz
          schema:
            type: number
            format: float
          description: Filter by shipping weight total in ounces
        - in: query
          name: shipping_weight_lb
          schema:
            type: number
            format: float
          description: Filter by shipping weight total in pounds
        - in: query
          name: shipping_length
          schema:
            type: number
            format: float
          description: Filter by shipping length (in inches)
        - in: query
          name: shipping_width
          schema:
            type: number
            format: float
          description: Filter by shipping width (in inches)
        - in: query
          name: shipping_height
          schema:
            type: number
            format: float
          description: Filter by shipping height (in inches)
        - in: query
          name: pallet_weight_oz
          schema:
            type: number
            format: float
          description: Filter by pallet weight total in ounces
        - in: query
          name: pallet_weight_lb
          schema:
            type: number
            format: float
          description: Filter by pallet weight total in pounds
        - in: query
          name: dimensional_weight_oz
          schema:
            type: number
            format: float
          description: Filter by dimensional weight total in ounces
        - in: query
          name: dimensional_weight_lb
          schema:
            type: number
            format: float
          description: Filter by dimensional weight total in pounds
        - in: query
          name: pallet_length
          schema:
            type: number
            format: float
          description: Filter by pallet length (in inches)
        - in: query
          name: pallet_width
          schema:
            type: number
            format: float
          description: Filter by pallet width (in inches)
        - in: query
          name: pallet_height
          schema:
            type: number
            format: float
          description: Filter by pallet height (in inches)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the product
                        name:
                          type: string
                          description: Product name
                        description:
                          type: string
                          nullable: true
                          description: Product description
                        retail_price:
                          type: number
                          format: float
                          description: Retail price
                        wholesale_price:
                          type: number
                          format: float
                          description: Wholesale price
                        unit_cost:
                          type: number
                          format: float
                          description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                        purchase_unit_cost:
                          type: number
                          format: float
                          nullable: true
                          description: |
                            Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                        purchase_currency:
                          type: string
                          nullable: true
                          description: |
                            ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                        landed_cost:
                          type: number
                          format: float
                          nullable: true
                          description: Landed cost per unit
                        estimated_landed_cost:
                          type: number
                          format: float
                          nullable: true
                          description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                        design_link:
                          type: string
                          nullable: true
                          description: Product design URL or link. `null` when unset or empty.
                        manufacturing_fee:
                          type: number
                          format: float
                          nullable: true
                          description: Manufacturing fee per unit
                        product_weight:
                          type: array
                          nullable: true
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - oz
                                description: Weight unit
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value
                        product_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: Total product weight in ounces (computed from product_weight)
                        product_weight_lb:
                          type: number
                          format: float
                          nullable: true
                          description: Total product weight in pounds (computed from product_weight)
                        dimensional_weight:
                          type: array
                          nullable: true
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - oz
                                description: Weight unit
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value
                        dimensional_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: Total dimensional weight in ounces (computed from dimensional_weight)
                        dimensional_weight_lb:
                          type: number
                          format: float
                          nullable: true
                          description: Total dimensional weight in pounds (computed from dimensional_weight)
                        product_length:
                          type: number
                          format: float
                          description: Length of the product (in inches)
                        product_width:
                          type: number
                          format: float
                          description: Width of the product (in inches)
                        product_height:
                          type: number
                          format: float
                          description: Height of the product (in inches)
                        box_weight:
                          type: array
                          nullable: true
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - oz
                                description: Weight unit
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value
                        box_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: Total box weight in ounces (computed from box_weight)
                        box_weight_lb:
                          type: number
                          format: float
                          nullable: true
                          description: Total box weight in pounds (computed from box_weight)
                        box_length:
                          type: number
                          format: float
                          nullable: true
                          description: Length of the box (in inches)
                        box_width:
                          type: number
                          format: float
                          nullable: true
                          description: Width of the box (in inches)
                        box_height:
                          type: number
                          format: float
                          nullable: true
                          description: Height of the box (in inches)
                        carton_weight:
                          type: array
                          nullable: true
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - oz
                                description: Weight unit
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value
                        carton_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: Total carton weight in ounces (computed from carton_weight)
                        carton_weight_lb:
                          type: number
                          format: float
                          nullable: true
                          description: Total carton weight in pounds (computed from carton_weight)
                        carton_length:
                          type: number
                          format: float
                          nullable: true
                          description: Length of the carton (in inches)
                        carton_width:
                          type: number
                          format: float
                          nullable: true
                          description: Width of the carton (in inches)
                        carton_height:
                          type: number
                          format: float
                          nullable: true
                          description: Height of the carton (in inches)
                        units_per_carton:
                          type: number
                          format: float
                          nullable: true
                          description: Number of units per carton (Shipping & Packing). `null` when not set.
                        shipping_weight:
                          type: array
                          nullable: true
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - oz
                                description: Weight unit
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value
                        shipping_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: Total shipping weight in ounces (computed from shipping_weight)
                        shipping_weight_lb:
                          type: number
                          format: float
                          nullable: true
                          description: Total shipping weight in pounds (computed from shipping_weight)
                        shipping_length:
                          type: number
                          format: float
                          nullable: true
                          description: Shipping length (in inches)
                        shipping_width:
                          type: number
                          format: float
                          nullable: true
                          description: Shipping width (in inches)
                        shipping_height:
                          type: number
                          format: float
                          nullable: true
                          description: Shipping height (in inches)
                        pallet_weight:
                          type: array
                          nullable: true
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - oz
                                description: Weight unit
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value
                        pallet_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: Total pallet weight in ounces (computed from pallet_weight)
                        pallet_weight_lb:
                          type: number
                          format: float
                          nullable: true
                          description: Total pallet weight in pounds (computed from pallet_weight)
                        pallet_length:
                          type: number
                          format: float
                          nullable: true
                          description: Length of the pallet (in inches)
                        pallet_width:
                          type: number
                          format: float
                          nullable: true
                          description: Width of the pallet (in inches)
                        pallet_height:
                          type: number
                          format: float
                          nullable: true
                          description: Height of the pallet (in inches)
                        cartons_per_pallet:
                          type: number
                          format: float
                          nullable: true
                          description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                        units_per_pallet:
                          type: number
                          format: float
                          nullable: true
                          description: Number of units per pallet (Shipping & Packing). `null` when not set.
                        default_receiving_location_id:
                          type: integer
                          nullable: true
                          description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                        default_assembly_location_id:
                          type: integer
                          nullable: true
                          description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                        lead_time_days:
                          type: integer
                          nullable: true
                          description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                        sellable:
                          type: boolean
                          description: Whether the product can be sold
                        discontinued:
                          type: boolean
                          description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                        is_drop_ship_item:
                          type: boolean
                          description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                        taxable:
                          type: boolean
                          description: Whether the product is subject to sales tax. Defaults to true when not set.
                        lot_tracking:
                          type: boolean
                          description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                        lot_deduction_strategy:
                          type: string
                          nullable: true
                          description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                        round_up_as_component:
                          type: boolean
                          description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                        default_supply_method:
                          type: string
                          nullable: true
                          enum:
                            - purchase
                            - vendor_supplied
                            - assemble
                            - on_hand
                            - assembly_order
                            - buy_and_ship
                            - brand_supplied
                          description: Default supply mode used when planning replenishment for this product
                        image_url:
                          type: string
                          nullable: true
                          description: URL to the product's main image
                        images:
                          type: array
                          description: |
                            The product's image gallery, in order. Position 1 is the hero image channels receive first.
                            Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                            by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                            them again rather than storing them.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                              url:
                                type: string
                                description: Presigned URL of the full-size image.
                              thumbnail_url:
                                type: string
                                nullable: true
                                description: Presigned URL of the thumbnail.
                              position:
                                type: integer
                                description: 1-based position in the gallery.
                        category:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                          description: Product category information
                        subcategory:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                          description: Product subcategory information
                        custom_fields:
                          type: object
                          description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties:
                            type: string
                        attachments:
                          type: array
                          description: Product attachments
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the attachment
                              name:
                                type: string
                                description: Filename of the attachment
                              type:
                                type: string
                                description: MIME type of the attachment
                              size:
                                type: integer
                                description: File size in bytes
                              full_url:
                                type: string
                                description: Full resolution URL of the attachment
                              thumb_url:
                                type: string
                                description: Thumbnail URL of the attachment (if applicable)
                            required:
                              - id
                              - name
                              - type
                              - size
                              - full_url
                        variants:
                          type: array
                          description: Product variants
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              product_weight:
                                type: array
                                nullable: true
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - oz
                                      description: Weight unit
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                      description: Weight value
                              product_weight_oz:
                                type: number
                                format: float
                                nullable: true
                              product_weight_lb:
                                type: number
                                format: float
                                nullable: true
                              dimensional_weight:
                                type: array
                                nullable: true
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - oz
                                      description: Weight unit
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                      description: Weight value
                              dimensional_weight_oz:
                                type: number
                                format: float
                                nullable: true
                              dimensional_weight_lb:
                                type: number
                                format: float
                                nullable: true
                              box_weight:
                                type: array
                                nullable: true
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - oz
                                      description: Weight unit
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                      description: Weight value
                              box_weight_oz:
                                type: number
                                format: float
                                nullable: true
                              box_weight_lb:
                                type: number
                                format: float
                                nullable: true
                              carton_weight:
                                type: array
                                nullable: true
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - oz
                                      description: Weight unit
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                      description: Weight value
                              carton_weight_oz:
                                type: number
                                format: float
                                nullable: true
                              carton_weight_lb:
                                type: number
                                format: float
                                nullable: true
                              shipping_weight:
                                type: array
                                nullable: true
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - oz
                                      description: Weight unit
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                      description: Weight value
                              shipping_weight_oz:
                                type: number
                                format: float
                                nullable: true
                              shipping_weight_lb:
                                type: number
                                format: float
                                nullable: true
                              pallet_weight:
                                type: array
                                nullable: true
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - oz
                                      description: Weight unit
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                      description: Weight value
                              pallet_weight_oz:
                                type: number
                                format: float
                                nullable: true
                              pallet_weight_lb:
                                type: number
                                format: float
                                nullable: true
                              attachments:
                                type: array
                                description: Variant-specific attachments
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the attachment
                                    name:
                                      type: string
                                      description: Filename of the attachment
                                    type:
                                      type: string
                                      description: MIME type of the attachment
                                    size:
                                      type: integer
                                      description: File size in bytes
                                    full_url:
                                      type: string
                                      description: Full resolution URL of the attachment
                                    thumb_url:
                                      type: string
                                      description: Thumbnail URL of the attachment (if applicable)
                                  required:
                                    - id
                                    - name
                                    - type
                                    - size
                                    - full_url
                              retail_price:
                                type: number
                                format: float
                              wholesale_price:
                                type: number
                                format: float
                              custom_fields:
                                type: array
                                items:
                                  type: object
                              variant_attributes:
                                type: array
                                nullable: true
                                description: |
                                  The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                  Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                  `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                  on that axis.
                                items:
                                  type: object
                                  properties:
                                    variant_name:
                                      type: string
                                      description: Name of the variant axis (e.g. "Size")
                                    variant_terms:
                                      type: array
                                      description: Term value(s) selected for this child on that axis
                                      items:
                                        type: string
                              sku:
                                type: string
                              upc:
                                type: string
                              hs_code:
                                type: string
                                nullable: true
                                description: HS/HTS tariff code for the product (max 50 characters)
                              round_up_as_component:
                                type: boolean
                                description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        variant_attributes:
                          type: array
                          nullable: true
                          description: |
                            Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                            each axis. On a parent product, this is the union of all terms used by its child variants. On a
                            child variant, this holds the specific term(s) the child is assigned to.

                            Set via the request field `product_variants` (same shape) on create/update.
                          items:
                            type: object
                            properties:
                              variant_name:
                                type: string
                                description: 'Name of the variant axis (e.g. "Size", "Color")'
                              variant_terms:
                                type: array
                                description: Terms on this axis
                                items:
                                  type: string
                        sku:
                          type: string
                          description: Internal SKU
                        alternate_skus:
                          type: array
                          description: Alternate SKUs
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              sku:
                                type: string
                        upc:
                          type: string
                          description: UPC/Barcode
                        hs_code:
                          type: string
                          nullable: true
                          description: HS/HTS tariff code for the product (max 50 characters)
                        tags:
                          type: array
                          description: Tags associated with the product
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the tag
                              name:
                                type: string
                                description: Name of the tag
                              description:
                                type: string
                                nullable: true
                                description: Description of the tag
                              icon:
                                type: string
                                nullable: true
                                description: Icon identifier or URL for the tag
                              color:
                                type: string
                                nullable: true
                                description: Color code for the tag
                            required:
                              - id
                              - name
                        substitutions:
                          type: array
                          description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Substitution record ID
                              priority:
                                type: integer
                                description: Substitution priority (lower number = higher priority)
                              product:
                                type: object
                                description: The substitute product
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the product
                                  name:
                                    type: string
                                    description: Product name
                                  description:
                                    type: string
                                    nullable: true
                                    description: Product description
                                  retail_price:
                                    type: number
                                    format: float
                                    description: Retail price
                                  wholesale_price:
                                    type: number
                                    format: float
                                    description: Wholesale price
                                  unit_cost:
                                    type: number
                                    format: float
                                    description: Cost per unit
                                  product_weight:
                                    type: array
                                    nullable: true
                                    items:
                                      type: object
                                      required:
                                        - unit
                                        - value
                                      properties:
                                        unit:
                                          type: string
                                          enum:
                                            - lb
                                            - oz
                                          description: Weight unit
                                        value:
                                          type: number
                                          format: float
                                          minimum: 0
                                          description: Weight value
                                  product_weight_oz:
                                    type: number
                                    format: float
                                    nullable: true
                                  product_weight_lb:
                                    type: number
                                    format: float
                                    nullable: true
                                  dimensional_weight:
                                    type: array
                                    nullable: true
                                    items:
                                      type: object
                                      required:
                                        - unit
                                        - value
                                      properties:
                                        unit:
                                          type: string
                                          enum:
                                            - lb
                                            - oz
                                          description: Weight unit
                                        value:
                                          type: number
                                          format: float
                                          minimum: 0
                                          description: Weight value
                                  dimensional_weight_oz:
                                    type: number
                                    format: float
                                    nullable: true
                                  dimensional_weight_lb:
                                    type: number
                                    format: float
                                    nullable: true
                                  product_length:
                                    type: number
                                    format: float
                                    description: Length of the product (in inches)
                                  product_width:
                                    type: number
                                    format: float
                                    description: Width of the product (in inches)
                                  product_height:
                                    type: number
                                    format: float
                                    description: Height of the product (in inches)
                                  box_weight:
                                    type: array
                                    nullable: true
                                    items:
                                      type: object
                                      required:
                                        - unit
                                        - value
                                      properties:
                                        unit:
                                          type: string
                                          enum:
                                            - lb
                                            - oz
                                          description: Weight unit
                                        value:
                                          type: number
                                          format: float
                                          minimum: 0
                                          description: Weight value
                                  box_weight_oz:
                                    type: number
                                    format: float
                                    nullable: true
                                  box_weight_lb:
                                    type: number
                                    format: float
                                    nullable: true
                                  box_length:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Length of the box (in inches)
                                  box_width:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Width of the box (in inches)
                                  box_height:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Height of the box (in inches)
                                  carton_weight:
                                    type: array
                                    nullable: true
                                    items:
                                      type: object
                                      required:
                                        - unit
                                        - value
                                      properties:
                                        unit:
                                          type: string
                                          enum:
                                            - lb
                                            - oz
                                          description: Weight unit
                                        value:
                                          type: number
                                          format: float
                                          minimum: 0
                                          description: Weight value
                                  carton_weight_oz:
                                    type: number
                                    format: float
                                    nullable: true
                                  carton_weight_lb:
                                    type: number
                                    format: float
                                    nullable: true
                                  carton_length:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Length of the carton (in inches)
                                  carton_width:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Width of the carton (in inches)
                                  carton_height:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Height of the carton (in inches)
                                  shipping_weight:
                                    type: array
                                    nullable: true
                                    items:
                                      type: object
                                      required:
                                        - unit
                                        - value
                                      properties:
                                        unit:
                                          type: string
                                          enum:
                                            - lb
                                            - oz
                                          description: Weight unit
                                        value:
                                          type: number
                                          format: float
                                          minimum: 0
                                          description: Weight value
                                  shipping_weight_oz:
                                    type: number
                                    format: float
                                    nullable: true
                                  shipping_weight_lb:
                                    type: number
                                    format: float
                                    nullable: true
                                  shipping_length:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Shipping length (in inches)
                                  shipping_width:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Shipping width (in inches)
                                  shipping_height:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Shipping height (in inches)
                                  pallet_weight:
                                    type: array
                                    nullable: true
                                    items:
                                      type: object
                                      required:
                                        - unit
                                        - value
                                      properties:
                                        unit:
                                          type: string
                                          enum:
                                            - lb
                                            - oz
                                          description: Weight unit
                                        value:
                                          type: number
                                          format: float
                                          minimum: 0
                                          description: Weight value
                                  pallet_weight_oz:
                                    type: number
                                    format: float
                                    nullable: true
                                  pallet_weight_lb:
                                    type: number
                                    format: float
                                    nullable: true
                                  pallet_length:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Length of the pallet (in inches)
                                  pallet_width:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Width of the pallet (in inches)
                                  pallet_height:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Height of the pallet (in inches)
                                  sellable:
                                    type: boolean
                                    description: Whether the product can be sold
                                  discontinued:
                                    type: boolean
                                    description: Whether the product is discontinued
                                  is_drop_ship_item:
                                    type: boolean
                                    description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                  taxable:
                                    type: boolean
                                    description: Whether the product is subject to sales tax. Defaults to true when not set.
                                  image_url:
                                    type: string
                                    nullable: true
                                    description: URL to the product's main image
                                  sku:
                                    type: string
                                    description: Internal SKU
                                  upc:
                                    type: string
                                    description: UPC/Barcode
                                  hs_code:
                                    type: string
                                    nullable: true
                                    description: HS/HTS tariff code for the product (max 50 characters)
                                  round_up_as_component:
                                    type: boolean
                                    description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was last updated
                        supplier:
                          type: object
                          nullable: true
                          description: Supplier information
                        type:
                          type: string
                          enum:
                            - PRODUCT
                            - KIT
                          description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                        kit_items:
                          type: array
                          nullable: true
                          description: Kit items (components) for kit products. Only present when type = KIT.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the kit item
                              product_id:
                                type: integer
                                description: ID of the product component
                              quantity:
                                type: number
                                format: float
                                description: Quantity of this component in the kit
                              uom_id:
                                type: integer
                                description: Unit of measure ID for the quantity
                              base_uom_quantity:
                                type: number
                                format: float
                                description: Quantity converted to base unit of measure
                              price:
                                type: number
                                format: float
                                description: Price for this kit item
                              original_price:
                                type: number
                                format: float
                                description: Original price for this kit item
                              total:
                                type: number
                                format: float
                                description: Calculated total (quantity * price)
                              product:
                                type: object
                                nullable: true
                                description: Product information for this kit item (when loaded)
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  sku:
                                    type: string
                                  description:
                                    type: string
                                    nullable: true
                                  retail_price:
                                    type: number
                                    format: float
                                  wholesale_price:
                                    type: number
                                    format: float
                              unit_of_measure:
                                type: object
                                nullable: true
                                description: Unit of measure information (when loaded)
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  description:
                                    type: string
                                    nullable: true
                                  base_unit:
                                    type: boolean
                        priority_list:
                          type: object
                          nullable: true
                          description: Fulfillment priority list assigned to this product
                          properties:
                            id:
                              type: integer
                              description: Priority list ID
                            name:
                              type: string
                              description: Priority list name
                            description:
                              type: string
                              nullable: true
                              description: Priority list description
                        distribution_template:
                          type: object
                          nullable: true
                          description: |
                            The distribution template (size curve) directly assigned to this product.
                            Returns `null` when no template is assigned (the tenant default applies
                            when resolving for production-run drafting). Use the dedicated
                            `PUT /products/{productId}/distribution-template` endpoint to assign one.
                          properties:
                            id:
                              type: integer
                              description: Distribution template ID
                            name:
                              type: string
                              description: Distribution template name
                            source:
                              type: string
                              enum:
                                - assigned
                              description: Always `assigned` — only directly assigned templates are returned here.
                        distribution_template_category:
                          type: object
                          nullable: true
                          description: |
                            The size-curve category assigned to this master SKU, used for
                            category × warehouse resolution of a distribution template when no
                            template is directly pinned. Returns `null` when no category is assigned.
                            Use the dedicated `PUT /products/{productId}/distribution-template-category`
                            endpoint to assign one.
                          properties:
                            id:
                              type: integer
                              description: Size-curve category ID
                            name:
                              type: string
                              description: Size-curve category name
                        boms:
                          type: array
                          description: BOMs (Bills of Materials) associated with this product
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the BOM
                              name:
                                type: string
                                description: BOM name
                              items:
                                type: array
                                description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the BOM item
                                    bom_id:
                                      type: integer
                                      description: ID of the BOM this item belongs to
                                    product_id:
                                      type: integer
                                      description: ID of the product/component
                                    product:
                                      type: object
                                      nullable: true
                                      description: Product information (when loaded)
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        sku:
                                          type: string
                                        description:
                                          type: string
                                          nullable: true
                                    quantity:
                                      type: number
                                      format: float
                                      description: Quantity required for this item
                                    base_quantity:
                                      type: number
                                      format: float
                                      description: Base quantity (converted to base unit of measure)
                                    note:
                                      type: string
                                      nullable: true
                                      description: Optional note for this item
                                    uom_id:
                                      type: integer
                                      nullable: true
                                      description: Unit of measure ID
                                    unit_of_measure:
                                      type: object
                                      nullable: true
                                      description: Unit of measure information (when loaded)
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                    order:
                                      type: integer
                                      nullable: true
                                      description: Display order for this item
                                    consumption_basis:
                                      type: string
                                      enum:
                                        - planned
                                        - actual
                                      description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                    created_at:
                                      type: string
                                      format: date-time
                                      description: Timestamp when the item was created
                                    updated_at:
                                      type: string
                                      format: date-time
                                      description: Timestamp when the item was last updated
                                  required:
                                    - id
                                    - bom_id
                                    - product_id
                                    - quantity
                              extra_costs:
                                type: array
                                description: Additional costs associated with the BOM
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the extra cost
                                    name:
                                      type: string
                                      description: Name/description of the extra cost
                                    quantity:
                                      type: number
                                      format: float
                                      description: Quantity for this cost item
                                    unit_price:
                                      type: number
                                      format: float
                                      description: Unit price for this cost item
                                    line_total:
                                      type: number
                                      format: float
                                      description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                    created_at:
                                      type: string
                                      format: date-time
                                      description: Timestamp when the extra cost was created
                                    updated_at:
                                      type: string
                                      format: date-time
                                      description: Timestamp when the extra cost was last updated
                                  required:
                                    - id
                                    - name
                                    - quantity
                                    - unit_price
                                    - line_total
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the BOM was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the BOM was last updated
                            required:
                              - id
                              - name
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the product was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the product was last updated
                        created_by:
                          type: integer
                          description: |
                            ID of the user who created the product. `0` for products created before
                            provenance was recorded or by a system path with no attributable user.
                            Products created through the External API are stamped with the API token's user.
                        updated_by:
                          type: integer
                          description: ID of the user who last updated the product. `0` when never attributed.
                        created_via:
                          type: string
                          nullable: true
                          enum:
                            - user
                            - api
                            - import
                            - auto_create_sku
                            - job
                            - system
                          description: |
                            How the product was created, stamped once at creation and never changed:
                            `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                            `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                            console command), or `system` (other internal write). `null` for products created
                            before provenance was recorded (unknown source).

                            Always present on single-product responses. On product **list** endpoints
                            (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                            it is only returned when requested with `?include=created_via`.
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createProduct
      tags:
        - Products
      summary: Create a product
      description: |
        Create a new product with optional variants, custom fields, and tags.

        **Kit Products:**
        When creating a kit product (type = KIT), the `kit_items` field is required and must contain at least one kit item.
        Each kit item must specify either `product_id` or `sku`, along with a `quantity`.

        **SKU collisions:** the "SKU already in use" check matches an existing record of any type,
        kits included. Creating a product with a SKU that already belongs to a kit returns `409`
        instead of creating a duplicate product. Kit component SKUs (`kit_items[].sku`) still resolve
        to products only.

        **Working with variants**

        A product with options like Size or Color is modeled as a parent product plus one child SKU per
        option combination, nested under the parent's `variants` array. Each child variant is itself a
        product — it has its own SKU, prices, weights, and dimensions.

        **You don't need to declare the option taxonomy on the parent.** Just tag each child SKU with the
        terms it represents (Size = Large, Color = Red, etc.) on `variants[].product_variants`, and Luminous
        will figure out the parent's taxonomy for you — the union of every term you've used across the
        children becomes the parent's set of axes and allowed values. New term on a child? It's added to
        the parent automatically. New axis on a child? Same — the axis is created on the parent.

        The practical result: you can build a product with any number of variants in a single request,
        without a separate "define the options first" step, and you can keep adding new variants to it
        later without ever touching the parent's `product_variants` field. (The parent's
        `product_variants` field is still writable as an escape hatch — e.g. to seed an empty option set
        or trim an unused term — but day-to-day you can ignore it.)

        Each entry in a child's `product_variants` is one option axis: `variant_name` is the axis label
        ("Size", "Color", …) and `variant_terms` is the term(s) the child is assigned to on that axis
        (usually a single string, but the field is an array so a child can sit on more than one term of
        the same axis if that's how you model it).

        ```json
        {
          "name": "Classic Tee",
          "sku": "TEE-100",
          "category_id": 1,
          "variants": [
            {
              "name": "Classic Tee — Small / Red",
              "sku": "TEE-100-S-RED",
              "product_variants": [
                { "variant_name": "Size",  "variant_terms": ["Small"] },
                { "variant_name": "Color", "variant_terms": ["Red"] }
              ]
            },
            {
              "name": "Classic Tee — Large / Red",
              "sku": "TEE-100-L-RED",
              "product_variants": [
                { "variant_name": "Size",  "variant_terms": ["Large"] },
                { "variant_name": "Color", "variant_terms": ["Red"] }
              ]
            },
            {
              "name": "Classic Tee — Large / Blue",
              "sku": "TEE-100-L-BLU",
              "product_variants": [
                { "variant_name": "Size",  "variant_terms": ["Large"] },
                { "variant_name": "Color", "variant_terms": ["Blue"] }
              ]
            }
          ]
        }
        ```

        After this call, the parent ends up with taxonomy `Size: [Small, Large]`, `Color: [Red, Blue]` —
        even though you never wrote it down. The resulting taxonomy and each child's term assignments are
        returned in the `variant_attributes` field on the response (same shape, on both the parent and
        each variant).

        To add a new variant to the same product later, send just that one child in `variants[]` on a
        `PATCH /products` or `POST /products/{id}` — the parent's taxonomy will pick up any new axis or
        term it contains automatically. See those endpoints for more on upsert semantics.

        **Permissions**

        Creating a product requires the `skus.create` permission on the API token's role. Requests
        without it return `403` ("You do not have permission to create SKUs."). The same check applies
        to every new child SKU created through `variants[]`. Once a role holds `skus.create`, it can set
        the initial `sku` and `upc` on create without also holding `skus.update.sku` / `skus.update.upc`
        (those are only needed to change the values later).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - category_id
                - sku
              properties:
                name:
                  type: string
                  maxLength: 200
                  description: Product name
                category_id:
                  type: integer
                  description: ID of the product category
                category:
                  type: object
                  nullable: true
                  properties:
                    name:
                      type: string
                      description: 'Name of the product category. If the category is not found in Luminous, it will be created.'
                  description: Product category information
                sku:
                  type: string
                  maxLength: 100
                  description: Internal SKU
                supplier_id:
                  type: integer
                  nullable: true
                  description: ID of the preferred supplier
                supplier:
                  type: object
                  nullable: true
                  properties:
                    name:
                      type: string
                      description: 'Name of the preferred supplier. If the supplier is not found in Luminous, it will be created.'
                  description: Product preferred supplier information
                distribution_template_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the distribution template (size curve) to assign to this product.
                    Use `GET /products/{productId}/distribution-template/candidates` to find
                    compatible templates for a master SKU.
                grid_template_category_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the variant distribution group (size-curve category) to assign to
                    this product. Unlike `distribution_template_id`, this does not pin a single
                    curve: the group is combined with each destination warehouse to pick the
                    right curve per buy. Returned as `distribution_template_category` on the
                    product response. Returns `422` if the group's axes don't fit the product.
                image_url:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: URL to product image
                images:
                  type: array
                  nullable: true
                  maxItems: 20
                  description: |
                    Gallery images to add from links, in gallery order. A queued job downloads each link into the
                    product's gallery, so the images appear in `GET /products/{id}` shortly after the response.
                    - The entry marked `is_primary` (at most one) goes first; with none marked, the first entry is the
                      hero image channels receive first.
                    - Dropbox file share links and Google Drive file links work as pasted. A Dropbox **folder** link is
                      rejected; share each image file.
                    - Up to 20 per request. A bad entry fails the whole request with a `422` that names the link, and
                      nothing is saved.
                    - Links already in the gallery are re-ordered, not downloaded again. Images not listed stay, after
                      the listed ones.
                    - The hero also becomes `image_url`, unless the same request sends `image_url`.
                    - A link that cannot be downloaded (private, expired, not an image) is skipped; the other images
                      still land.
                  items:
                    type: object
                    required:
                      - url
                    properties:
                      url:
                        type: string
                        description: Link to the image file.
                        example: 'https://cdn.example.com/tee-front.jpg'
                      is_primary:
                        type: boolean
                        description: Make this image the hero (first in the gallery). At most one entry.
                sellable:
                  type: boolean
                  nullable: true
                  description: Whether the product can be sold
                lot_tracking:
                  type: boolean
                  nullable: true
                  description: Whether to track product by lots
                is_drop_ship_item:
                  type: boolean
                  nullable: true
                  description: Flag the product as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                taxable:
                  type: boolean
                  nullable: true
                  description: Whether the product is subject to sales tax. Defaults to true when omitted.
                sub_category_id:
                  type: integer
                  nullable: true
                  description: ID of the product subcategory
                subcategory:
                  type: object
                  nullable: true
                  properties:
                    name:
                      type: string
                      description: 'Name of the product sub-category, used when `sub_category_id` is not sent. If `category_id` or `category.name` is also sent, the sub-category is looked up in that category and created if missing. Without a category, the name must match exactly one existing sub-category; otherwise the request returns `422` and nothing is created.'
                  description: Product sub-category information
                default_receiving_location_id:
                  type: integer
                  nullable: true
                  description: Default location ID for receiving this product
                default_assembly_location_id:
                  type: integer
                  nullable: true
                  description: 'Default location (bin) ID where assembled goods (BOM output) are credited for this product. When set, it is used as the destination when defaulting assembly/disassembly work, falling back to `default_receiving_location_id` and then the warehouse default.'
                description:
                  type: string
                  nullable: true
                  description: Product description
                wholesale_price:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Wholesale price
                retail_price:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Retail price
                unit_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Cost per unit. Interpreted in the currency given by `unit_cost_currency`; when that is omitted, `unit_cost` is the tenant base-currency inventory cost.
                unit_cost_currency:
                  type: string
                  nullable: true
                  example: EUR
                  description: |
                    Optional ISO currency code for `unit_cost`. Omit (or send `null`) to treat `unit_cost` as the base-currency inventory cost (existing behavior; any stored supplier purchase price is left untouched). Send the tenant base currency to set the base cost explicitly and clear a foreign-currency purchase price on the preferred supplier. Send the preferred supplier's default currency to store `unit_cost` as the supplier purchase (FOB) price on that supplier's SKU; it is converted at today's exchange rate into the base-currency inventory cost. Any other currency, or a supplier currency without a preferred supplier that has a currency, returns `422` keyed on `unit_cost_currency`. Only applies when `unit_cost` is also sent.
                manufacturing_fee:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Manufacturing fee per unit
                estimated_landed_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Planner's estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. Uses the same currency as the product's other costs (there is no separate currency field). Send `null` to clear it.
                design_link:
                  type: string
                  maxLength: 2000
                  nullable: true
                  description: Product design URL or link. Send `null` to clear it.
                product_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                dimensional_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                product_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the product (in inches)
                product_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the product (in inches)
                product_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the product (in inches)
                box_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                box_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the box (in inches)
                box_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the box (in inches)
                box_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the box (in inches)
                carton_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                carton_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the carton (in inches)
                carton_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the carton (in inches)
                carton_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the carton (in inches)
                shipping_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                shipping_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping length (in inches)
                shipping_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping width (in inches)
                shipping_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping height (in inches)
                pallet_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                pallet_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the pallet (in inches)
                pallet_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the pallet (in inches)
                pallet_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the pallet (in inches)
                units_per_carton:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of units per carton (Shipping & Packing). Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                cartons_per_pallet:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of cartons per pallet (Shipping & Packing). Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                units_per_pallet:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of units per pallet (Shipping & Packing). Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                lead_time_days:
                  type: integer
                  minimum: 0
                  maximum: 2147483647
                  nullable: true
                  description: Supplier lead time in calendar days (the product's Lead Time). Returned as `lead_time_days` on the product.
                upc:
                  type: string
                  nullable: true
                  description: UPC/Barcode
                default_supply_method:
                  type: string
                  nullable: true
                  maxLength: 50
                  enum:
                    - purchase
                    - vendor_supplied
                    - assemble
                    - on_hand
                    - assembly_order
                    - buy_and_ship
                    - brand_supplied
                  description: |
                    Default supply mode used when planning replenishment for this product.
                    Determines whether the system expects to purchase, drop-ship, assemble,
                    or pull from on-hand stock when supplying demand.
                priority_list_id:
                  type: integer
                  nullable: true
                  description: 'ID of the fulfillment priority list to assign to this product. Only lists you manage are accepted; an unknown, deleted, or system-owned re-route list (named `Re-route: <channel>`) returns 400 "does not exist".'
                priority_list:
                  type: object
                  nullable: true
                  description: Priority list to assign by ID or name (alternative to priority_list_id)
                  properties:
                    id:
                      type: integer
                      nullable: true
                      description: 'Priority list ID. Same rules as `priority_list_id`: system-owned re-route lists are refused (400).'
                    name:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: 'Priority list name (exact match, trimmed). Only lists you manage are matched; system-owned re-route lists (named `Re-route: <channel>`) are ignored. Returns 400 if no matching list exists.'
                custom_fields:
                  type: object
                  nullable: true
                  description: Custom field values
                  additionalProperties:
                    type: string
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the product
                  items:
                    type: string
                default_selling_unit_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit of measure this product is sold in.

                    If omitted (along with `selling_uom`), Luminous defaults it to the account's
                    base unit of measure (e.g. `ea` under the `Quantity` unit class). The request is
                    rejected only if the account has no unit of measure configured at all.
                default_purchase_unit_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit of measure this product is purchased in.

                    If omitted (along with `purchase_uom`), Luminous defaults it to the account's
                    base unit of measure (e.g. `ea`).
                unit_class_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit class this product's units belong to (e.g. `Quantity`).

                    If omitted, Luminous defaults it to the unit class of the account's base unit.
                selling_uom:
                  type: object
                  nullable: true
                  description: |
                    Selling unit of measure by name — an alternative to `default_selling_unit_id`.
                    When `default_selling_unit_id` is not provided, the named UOM is resolved to its ID.
                  properties:
                    name:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: 'Name of the selling unit of measure (e.g. "ea", "case")'
                purchase_uom:
                  type: object
                  nullable: true
                  description: |
                    Purchase unit of measure by name — an alternative to `default_purchase_unit_id`.
                    When `default_purchase_unit_id` is not provided, the named UOM is resolved to its ID.
                  properties:
                    name:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: 'Name of the purchase unit of measure (e.g. "ea", "case")'
                product_variants:
                  type: array
                  nullable: true
                  description: |
                    Variant option taxonomy for the product — the axes (e.g. Size, Color) and the allowed terms
                    on each axis.

                    **You almost never need to set this.** Tag each child SKU under `variants[].product_variants`
                    with the terms it represents instead, and Luminous will derive the parent taxonomy
                    automatically as the union of every term used by the children. Setting this directly is only
                    useful as an escape hatch (e.g. seeding an empty option set, or pruning a term no child uses).

                    Returned on the response as `variant_attributes` (same shape).
                  items:
                    type: object
                    required:
                      - variant_name
                    properties:
                      variant_name:
                        type: string
                        description: 'Name of the variant axis (e.g. "Size", "Color")'
                      variant_terms:
                        type: array
                        nullable: true
                        description: Allowed terms for this variant axis
                        items:
                          type: string
                variant_template:
                  nullable: true
                  description: |
                    A variant template to expand into child SKUs, given as either the template's **id**
                    (integer) or its **name** (string). When set on a master product create, the template's
                    option axes are expanded into child variant SKUs — the same one-click "generate variants"
                    step available in the SKU form, reachable from the API.

                    Rules:
                    - **Ignored when you also send an explicit `variants` array** — being specific always wins
                      over a preset.
                    - **Idempotent** — skipped when the product already has child variants, so re-sending the
                      same request does not duplicate them.
                    - An unknown template name/id fails loudly with a `422` validation error rather than
                      silently producing a master with no variants.
                  oneOf:
                    - type: integer
                    - type: string
                variants:
                  type: array
                  nullable: true
                  description: Product variants
                  items:
                    type: object
                    required:
                      - name
                      - sku
                      - product_variants
                    properties:
                      name:
                        type: string
                        maxLength: 200
                        description: Variant name
                      sku:
                        type: string
                        maxLength: 100
                        description: Variant SKU
                      image_url:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: URL to variant image
                      supplier_id:
                        type: integer
                        nullable: true
                        description: ID of the variant's preferred supplier. Supplier must already exist in Luminous.
                      supplier:
                        type: object
                        nullable: true
                        properties:
                          name:
                            type: string
                            description: 'Name of the preferred supplier. If the supplier is not found in Luminous, it will be created.'
                        description: Product preferred supplier information
                      sellable:
                        type: boolean
                        nullable: true
                        description: Whether the variant can be sold
                      discontinued:
                        type: boolean
                        nullable: true
                        description: If an item is discontinued it will be hidden by default in the Luminous UI
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location ID for receiving this variant
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this variant
                      description:
                        type: string
                        nullable: true
                        description: Variant description
                      wholesale_price:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant wholesale price
                      retail_price:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant retail price
                      unit_cost:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant cost per unit
                      product_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      dimensional_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      product_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the variant (in inches)
                      product_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the variant (in inches)
                      product_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the variant (in inches) (in inches)
                      box_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      box_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      carton_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the carton (in inches)
                      shipping_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      shipping_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      pallet_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the pallet (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of units per carton (Shipping & Packing). Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      cartons_per_pallet:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of cartons per pallet (Shipping & Packing). Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      units_per_pallet:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of units per pallet (Shipping & Packing). Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      lead_time_days:
                        type: integer
                        minimum: 0
                        maximum: 2147483647
                        nullable: true
                        description: Supplier lead time in calendar days (the product's Lead Time). Returned as `lead_time_days` on the product.
                      upc:
                        type: string
                        nullable: true
                        description: Variant UPC/Barcode
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for the variant
                        additionalProperties:
                          type: string
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with the variant
                        items:
                          type: string
                      product_variants:
                        type: array
                        minItems: 1
                        description: |
                          The variant option term(s) this child SKU is assigned to (e.g. Size=Large, Color=Red).
                          Use one entry per axis, with the term(s) on `variant_terms`. Any terms used here that
                          aren't yet on the parent's taxonomy are added to it automatically.

                          **Required for every entry in `variants`.** Each child SKU must declare at least one
                          option (axis name + term), so an all-red run of shirts would send
                          `[{"variant_name": "Color", "variant_terms": ["Red"]}]`. A variant with no options is rejected.

                          You may send this under the alias `variant_attributes` instead (matching the GET response shape);
                          both are accepted on write. Returned on the response as the child variant's `variant_attributes`.
                        items:
                          type: object
                          required:
                            - variant_name
                            - variant_terms
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              minItems: 1
                              description: Term value(s) for this axis on this child SKU
                              items:
                                type: string
                type:
                  type: string
                  enum:
                    - PRODUCT
                    - KIT
                  nullable: true
                  default: PRODUCT
                  description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                kit_items:
                  type: array
                  nullable: true
                  description: |
                    Array of kit items (components) for kit products. Required when type = KIT. 
                    Each kit item must specify either product_id or sku, and quantity.
                  items:
                    type: object
                    required:
                      - quantity
                    properties:
                      product_id:
                        type: integer
                        nullable: true
                        description: ID of the product component. Either product_id or sku must be provided.
                      sku:
                        type: string
                        nullable: true
                        description: SKU of the product component. Either product_id or sku must be provided.
                      quantity:
                        type: number
                        format: float
                        minimum: 0
                        description: Quantity of this component in the kit
                      uom_id:
                        type: integer
                        nullable: true
                        description: 'Unit of measure ID for the quantity. If not provided, defaults to the product''s default selling unit.'
                      price:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Price for this kit item
                      original_price:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Original price for this kit item
                    oneOf:
                      - required:
                          - product_id
                      - required:
                          - sku
                boms:
                  type: array
                  nullable: true
                  description: |
                    Array of BOM IDs to attach to the product.
                    Omit this field entirely to leave the product's existing BOM associations unchanged (upserts do not touch BOMs unless `boms` is provided).
                    When the field **is** provided, it replaces all existing BOM associations: pass an array of IDs to set them, or `null`/an empty array to detach all BOMs.
                  items:
                    type: integer
                    description: BOM ID
                profile_id:
                  type: integer
                  nullable: true
                  description: |
                    Opt-in reference to a Product Builder Profile (`GET /product-profiles`).
                    When provided (and the profile is active), the product is validated against the profile before
                    any writes — SKU format, required variant preset / distribution group / custom fields — returning
                    a 422 on any violation, and the profile's fixed selections and hidden defaults are stamped onto
                    the product where you left them unset. Omit to create the product without profile enforcement.
                profile_slug:
                  type: string
                  nullable: true
                  description: 'The profile''s slug, an alternative to `profile_id` for referencing a Product Builder Profile.'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Forbidden - the API token's role lacks the skus.create permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: Conflict - SKU already in use by an existing product or kit
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    patch:
      operationId: createOrUpdateProduct
      tags:
        - Products
      summary: Create or update product
      description: |
        Create a new product or update an existing one by SKU or ID.

        When no `id` is sent, the `sku` is matched against existing records of every type, kits
        included — a `sku` that belongs to a kit updates that kit rather than creating a duplicate
        product.

        **Adding or updating variants**

        The `variants` array upserts by `sku` (or `id`) — include a child to create or update it,
        and omit children you don't want to change (they're left untouched, not deleted).

        To add a new variant to an existing product, PATCH the parent with just the new entry in
        `variants[]`. To change a variant's option assignment, PATCH the parent with that child's
        `sku` plus its new `product_variants` axis/terms — the parent's taxonomy will pick up any
        new terms automatically. See **Working with variants** under `POST /products` for the full
        parent/child model and a worked example.

        **Permissions**

        When no product matches the `sku`/`id`, this endpoint creates one and requires the
        `skus.create` permission (as do any new child SKUs in `variants[]`); without it the request
        returns `403`. Updating an existing product follows the field-level `sku`/`upc` permission rules
        described under `POST /products/{productId}`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  properties:
                    name:
                      type: string
                      maxLength: 200
                      description: Product name
                    category_id:
                      type: integer
                      description: ID of the product category
                    category:
                      type: object
                      nullable: true
                      properties:
                        name:
                          type: string
                          description: 'Name of the product category. If the category is not found in Luminous, it will be created.'
                      description: Product category information
                    sku:
                      type: string
                      maxLength: 100
                      description: Internal SKU. Changing this value requires the `skus.update.sku` permission; the request returns 403 if the authenticated token's role lacks it. Omitting the field or sending the same value as the current SKU skips the check.
                    qty_low_alert:
                      type: integer
                      nullable: true
                      description: Quantity threshold for low stock alerts
                    qty_reorder_threshold:
                      type: integer
                      nullable: true
                      description: Quantity threshold for reordering
                    qty_minimum:
                      type: integer
                      nullable: true
                      description: Minimum quantity to maintain
                    supplier_id:
                      type: integer
                      nullable: true
                      description: ID of the preferred supplier
                    supplier:
                      type: object
                      nullable: true
                      properties:
                        name:
                          type: string
                          description: 'Name of the preferred supplier. If the supplier is not found in Luminous, it will be created.'
                      description: Product preferred supplier information
                    distribution_template_id:
                      type: integer
                      nullable: true
                      description: |
                        ID of the distribution template (size curve) to assign to this product.
                        Pass `null` to clear the current assignment. Use
                        `GET /products/{productId}/distribution-template/candidates` to find
                        compatible templates for a master SKU.
                    grid_template_category_id:
                      type: integer
                      nullable: true
                      description: |
                        ID of the variant distribution group (size-curve category) to assign to
                        this product. Omitting it or passing `null` leaves the current group
                        unchanged. Unlike `distribution_template_id`, this does not pin a single
                        curve: the group is combined with each destination warehouse to pick the
                        right curve per buy. Returned as `distribution_template_category` on the
                        product response. Returns `422` if the group's axes don't fit the product.
                    image_url:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: URL to product image
                    images:
                      type: array
                      nullable: true
                      maxItems: 20
                      description: |
                        Gallery images to add from links, in gallery order. A queued job downloads each link into the
                        product's gallery, so the images appear in `GET /products/{id}` shortly after the response.
                        - The entry marked `is_primary` (at most one) goes first; with none marked, the first entry is the
                          hero image channels receive first.
                        - Dropbox file share links and Google Drive file links work as pasted. A Dropbox **folder** link is
                          rejected; share each image file.
                        - Up to 20 per request. A bad entry fails the whole request with a `422` that names the link, and
                          nothing is saved.
                        - Links already in the gallery are re-ordered, not downloaded again. Images not listed stay, after
                          the listed ones.
                        - The hero also becomes `image_url`, unless the same request sends `image_url`.
                        - A link that cannot be downloaded (private, expired, not an image) is skipped; the other images
                          still land.
                      items:
                        type: object
                        required:
                          - url
                        properties:
                          url:
                            type: string
                            description: Link to the image file.
                            example: 'https://cdn.example.com/tee-front.jpg'
                          is_primary:
                            type: boolean
                            description: Make this image the hero (first in the gallery). At most one entry.
                    sellable:
                      type: boolean
                      nullable: true
                      description: Whether the product can be sold
                    lot_tracking:
                      type: boolean
                      nullable: true
                      description: Whether to track product by lots
                    is_drop_ship_item:
                      type: boolean
                      nullable: true
                      description: Flag the product as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                    taxable:
                      type: boolean
                      nullable: true
                      description: Whether the product is subject to sales tax. Defaults to true when omitted.
                    sub_category_id:
                      type: integer
                      nullable: true
                      description: 'ID of the product subcategory. Takes precedence over `subcategory_id`, `subcategory.id` and `subcategory.name`.'
                    subcategory_id:
                      type: integer
                      nullable: true
                      description: 'Alias for `sub_category_id`. Used only when `sub_category_id` and `subcategory.name` are not sent. `0` or empty is ignored. Returns `422` if the ID doesn''t match an existing, non-deleted subcategory.'
                    subcategory:
                      type: object
                      nullable: true
                      properties:
                        id:
                          type: integer
                          nullable: true
                          description: 'Alias for `sub_category_id` (the shape returned by GET). Used only when `sub_category_id` and `subcategory.name` are not sent. `0` or empty is ignored. Returns `422` if the ID doesn''t match an existing, non-deleted subcategory.'
                        name:
                          type: string
                          maxLength: 200
                          description: 'Name of the product sub-category, used when `sub_category_id` is not sent. If `category_id` or `category.name` is also sent, the sub-category is looked up in that category and created if missing. Otherwise it must already exist: it is matched within the product''s current category, or, if the product has no category, the name must match exactly one sub-category. Returns `422` (and saves nothing) if the name is not found or is ambiguous.'
                      description: Product sub-category information
                    default_receiving_location_id:
                      type: integer
                      nullable: true
                      description: Default location ID for receiving this product
                    default_assembly_location_id:
                      type: integer
                      nullable: true
                      description: 'Default location (bin) ID where assembled goods (BOM output) are credited for this product. When set, it is used as the destination when defaulting assembly/disassembly work, falling back to `default_receiving_location_id` and then the warehouse default.'
                    description:
                      type: string
                      nullable: true
                      description: Product description
                    wholesale_price:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Wholesale price
                    retail_price:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Retail price
                    unit_cost:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: |
                        Cost per unit. Interpreted in the currency given by `unit_cost_currency`; when that is omitted, `unit_cost` is the tenant base-currency inventory cost.
                    unit_cost_currency:
                      type: string
                      nullable: true
                      example: EUR
                      description: |
                        Optional ISO currency code for `unit_cost`. Omit (or send `null`) to treat `unit_cost` as the base-currency inventory cost (existing behavior; any stored supplier purchase price is left untouched). Send the tenant base currency to set the base cost explicitly and clear a foreign-currency purchase price on the preferred supplier. Send the preferred supplier's default currency to store `unit_cost` as the supplier purchase (FOB) price on that supplier's SKU; it is converted at today's exchange rate into the base-currency inventory cost. Any other currency, or a supplier currency without a preferred supplier that has a currency, returns `422` keyed on `unit_cost_currency`. Only applies when `unit_cost` is also sent.
                    manufacturing_fee:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Manufacturing fee per unit
                    estimated_landed_cost:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: |
                        Planner's estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. Uses the same currency as the product's other costs (there is no separate currency field). Send `null` to clear it.
                    design_link:
                      type: string
                      maxLength: 2000
                      nullable: true
                      description: Product design URL or link. Send `null` to clear it.
                    product_weight:
                      nullable: true
                      description: |
                        Product weight. Accepts a single `{unit, value}` object or an array of such
                        segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                        **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                        `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                        at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                        metric is converted, the input unit is not round-tripped: a weight submitted in
                        grams or kilograms reads back in ounces.

                        **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                        (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                        value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                        repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                        written twice rather than a total.
                      oneOf:
                        - type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - lbs
                                - oz
                                - ozs
                                - g
                                - gram
                                - grams
                                - kg
                                - kgs
                                - kilogram
                                - kilograms
                              description: |
                                Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value (non-negative)
                        - type: array
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                              value:
                                type: number
                                format: float
                                minimum: 0
                          description: |
                            Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                    dimensional_weight:
                      nullable: true
                      description: |
                        Product weight. Accepts a single `{unit, value}` object or an array of such
                        segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                        **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                        `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                        at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                        metric is converted, the input unit is not round-tripped: a weight submitted in
                        grams or kilograms reads back in ounces.

                        **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                        (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                        value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                        repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                        written twice rather than a total.
                      oneOf:
                        - type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - lbs
                                - oz
                                - ozs
                                - g
                                - gram
                                - grams
                                - kg
                                - kgs
                                - kilogram
                                - kilograms
                              description: |
                                Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value (non-negative)
                        - type: array
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                              value:
                                type: number
                                format: float
                                minimum: 0
                          description: |
                            Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                    product_length:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Length of the product (in inches)
                    product_width:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Width of the product (in inches)
                    product_height:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Height of the product (in inches)
                    box_weight:
                      nullable: true
                      description: |
                        Product weight. Accepts a single `{unit, value}` object or an array of such
                        segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                        **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                        `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                        at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                        metric is converted, the input unit is not round-tripped: a weight submitted in
                        grams or kilograms reads back in ounces.

                        **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                        (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                        value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                        repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                        written twice rather than a total.
                      oneOf:
                        - type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - lbs
                                - oz
                                - ozs
                                - g
                                - gram
                                - grams
                                - kg
                                - kgs
                                - kilogram
                                - kilograms
                              description: |
                                Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value (non-negative)
                        - type: array
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                              value:
                                type: number
                                format: float
                                minimum: 0
                          description: |
                            Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                    box_length:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Length of the box (in inches)
                    box_width:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Width of the box (in inches)
                    box_height:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Height of the box (in inches)
                    carton_weight:
                      nullable: true
                      description: |
                        Product weight. Accepts a single `{unit, value}` object or an array of such
                        segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                        **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                        `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                        at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                        metric is converted, the input unit is not round-tripped: a weight submitted in
                        grams or kilograms reads back in ounces.

                        **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                        (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                        value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                        repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                        written twice rather than a total.
                      oneOf:
                        - type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - lbs
                                - oz
                                - ozs
                                - g
                                - gram
                                - grams
                                - kg
                                - kgs
                                - kilogram
                                - kilograms
                              description: |
                                Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value (non-negative)
                        - type: array
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                              value:
                                type: number
                                format: float
                                minimum: 0
                          description: |
                            Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                    carton_length:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Length of the carton (in inches)
                    carton_width:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Width of the carton (in inches)
                    carton_height:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Height of the carton (in inches)
                    shipping_weight:
                      nullable: true
                      description: |
                        Product weight. Accepts a single `{unit, value}` object or an array of such
                        segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                        **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                        `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                        at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                        metric is converted, the input unit is not round-tripped: a weight submitted in
                        grams or kilograms reads back in ounces.

                        **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                        (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                        value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                        repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                        written twice rather than a total.
                      oneOf:
                        - type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - lbs
                                - oz
                                - ozs
                                - g
                                - gram
                                - grams
                                - kg
                                - kgs
                                - kilogram
                                - kilograms
                              description: |
                                Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value (non-negative)
                        - type: array
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                              value:
                                type: number
                                format: float
                                minimum: 0
                          description: |
                            Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                    shipping_length:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Shipping length (in inches)
                    shipping_width:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Shipping width (in inches)
                    shipping_height:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Shipping height (in inches)
                    pallet_weight:
                      nullable: true
                      description: |
                        Product weight. Accepts a single `{unit, value}` object or an array of such
                        segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                        **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                        `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                        at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                        metric is converted, the input unit is not round-tripped: a weight submitted in
                        grams or kilograms reads back in ounces.

                        **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                        (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                        value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                        repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                        written twice rather than a total.
                      oneOf:
                        - type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - lbs
                                - oz
                                - ozs
                                - g
                                - gram
                                - grams
                                - kg
                                - kgs
                                - kilogram
                                - kilograms
                              description: |
                                Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value (non-negative)
                        - type: array
                          items:
                            type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                              value:
                                type: number
                                format: float
                                minimum: 0
                          description: |
                            Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                    pallet_length:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Length of the pallet (in inches)
                    pallet_width:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Width of the pallet (in inches)
                    pallet_height:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: Height of the pallet (in inches)
                    units_per_carton:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: 'Number of units per carton (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                    cartons_per_pallet:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: 'Number of cartons per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                    units_per_pallet:
                      type: number
                      format: float
                      minimum: 0
                      nullable: true
                      description: 'Number of units per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                    lead_time_days:
                      type: integer
                      minimum: 0
                      maximum: 2147483647
                      nullable: true
                      description: Supplier lead time in calendar days (the product's Lead Time). Returned as `lead_time_days` on the product. Omit to leave unchanged.
                    upc:
                      type: string
                      nullable: true
                      description: UPC/Barcode. Changing this value requires the `skus.update.upc` permission; the request returns 403 if the authenticated token's role lacks it. Omitting the field or sending the same value as the current UPC skips the check.
                    default_supply_method:
                      type: string
                      nullable: true
                      maxLength: 50
                      enum:
                        - purchase
                        - vendor_supplied
                        - assemble
                        - on_hand
                        - assembly_order
                        - buy_and_ship
                        - brand_supplied
                      description: |
                        Default supply mode used when planning replenishment for this product.
                        Determines whether the system expects to purchase, drop-ship, assemble,
                        or pull from on-hand stock when supplying demand.
                    priority_list_id:
                      type: integer
                      nullable: true
                      description: 'ID of the fulfillment priority list to assign to this product. Only lists you manage are accepted; an unknown, deleted, or system-owned re-route list (named `Re-route: <channel>`) returns 400 "does not exist".'
                    custom_fields:
                      type: object
                      nullable: true
                      description: |
                        Custom field values, keyed by label. Only the labels sent are changed. Sending `null`,
                        `""` or `[]` for a label clears that field's value (dropdown fields included);
                        an empty value for a label that is not defined is ignored.
                      additionalProperties:
                        type: string
                        nullable: true
                    tags:
                      type: array
                      nullable: true
                      description: Tags to associate with the product
                      items:
                        type: string
                    default_selling_unit_id:
                      type: integer
                      nullable: true
                      minimum: 1
                      description: |
                        ID of the unit of measure this product is sold in.

                        If omitted (along with `selling_uom`), Luminous defaults it to the account's
                        base unit of measure (e.g. `ea` under the `Quantity` unit class). The request is
                        rejected only if the account has no unit of measure configured at all.
                    default_purchase_unit_id:
                      type: integer
                      nullable: true
                      minimum: 1
                      description: |
                        ID of the unit of measure this product is purchased in.

                        If omitted (along with `purchase_uom`), Luminous defaults it to the account's
                        base unit of measure (e.g. `ea`).
                    unit_class_id:
                      type: integer
                      nullable: true
                      minimum: 1
                      description: |
                        ID of the unit class this product's units belong to (e.g. `Quantity`).

                        If omitted, Luminous defaults it to the unit class of the account's base unit.
                    selling_uom:
                      type: object
                      nullable: true
                      description: |
                        Selling unit of measure by name — an alternative to `default_selling_unit_id`.
                        When `default_selling_unit_id` is not provided, the named UOM is resolved to its ID.
                      properties:
                        name:
                          type: string
                          nullable: true
                          maxLength: 255
                          description: 'Name of the selling unit of measure (e.g. "ea", "case")'
                    purchase_uom:
                      type: object
                      nullable: true
                      description: |
                        Purchase unit of measure by name — an alternative to `default_purchase_unit_id`.
                        When `default_purchase_unit_id` is not provided, the named UOM is resolved to its ID.
                      properties:
                        name:
                          type: string
                          nullable: true
                          maxLength: 255
                          description: 'Name of the purchase unit of measure (e.g. "ea", "case")'
                    product_variants:
                      type: array
                      nullable: true
                      description: |
                        Variant option taxonomy for the product — the axes (e.g. Size, Color) and the allowed terms
                        on each axis.

                        **You almost never need to set this.** Tag each child SKU under `variants[].product_variants`
                        with the terms it represents instead, and Luminous will extend the parent taxonomy
                        automatically as the union of every term used by the children. Setting this directly is only
                        useful as an escape hatch (e.g. seeding an empty option set, or pruning a term no child uses).

                        Returned on the response as `variant_attributes` (same shape).
                      items:
                        type: object
                        required:
                          - variant_name
                        properties:
                          variant_name:
                            type: string
                            description: 'Name of the variant axis (e.g. "Size", "Color")'
                          variant_terms:
                            type: array
                            nullable: true
                            description: Allowed terms for this variant axis
                            items:
                              type: string
                    variant_template:
                      nullable: true
                      description: |
                        A variant template to expand into child SKUs, given as either the template's **id**
                        (integer) or its **name** (string). When set on a master product, the template's option
                        axes are expanded into child variant SKUs — the same one-click "generate variants" step
                        available in the SKU form, reachable from the API.

                        Rules:
                        - **Ignored when you also send an explicit `variants` array** — being specific always wins
                          over a preset.
                        - **Idempotent** — skipped when the product already has child variants, so re-sending the
                          same request does not duplicate them.
                        - An unknown template name/id fails loudly with a `422` validation error rather than
                          silently producing a master with no variants.
                      oneOf:
                        - type: integer
                        - type: string
                    variants:
                      type: array
                      nullable: true
                      description: Product variants
                      items:
                        type: object
                        required:
                          - sku
                          - product_variants
                        properties:
                          name:
                            type: string
                            maxLength: 200
                            description: Variant name
                          sku:
                            type: string
                            maxLength: 100
                            description: Variant SKU
                          image_url:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: URL to variant image
                          qty_low_alert:
                            type: integer
                            nullable: true
                            description: Quantity threshold for low stock alerts
                          qty_reorder_threshold:
                            type: integer
                            nullable: true
                            description: Quantity threshold for reordering
                          qty_minimum:
                            type: integer
                            nullable: true
                            description: Minimum quantity to maintain
                          supplier_id:
                            type: integer
                            nullable: true
                            description: ID of the variant's preferred supplier
                          supplier:
                            type: object
                            nullable: true
                            properties:
                              name:
                                type: string
                                description: 'Name of the preferred supplier. If the supplier is not found in Luminous, it will be created.'
                            description: Product preferred supplier information
                          sellable:
                            type: boolean
                            nullable: true
                            description: Whether the variant can be sold
                          discontinued:
                            type: boolean
                            nullable: true
                            description: If an item is discontinued it will be hidden by default in the Luminous UI
                          default_receiving_location_id:
                            type: integer
                            nullable: true
                            description: Default location ID for receiving this variant
                          default_assembly_location_id:
                            type: integer
                            nullable: true
                            description: Default location (bin) ID where assembled goods (BOM output) are credited for this variant
                          description:
                            type: string
                            nullable: true
                            description: Variant description
                          wholesale_price:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Variant wholesale price
                          retail_price:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Variant retail price
                          unit_cost:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Variant cost per unit
                          product_weight:
                            nullable: true
                            description: |
                              Product weight. Accepts a single `{unit, value}` object or an array of such
                              segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                              **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                              `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                              at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                              metric is converted, the input unit is not round-tripped: a weight submitted in
                              grams or kilograms reads back in ounces.

                              **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                              (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                              value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                              repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                              written twice rather than a total.
                            oneOf:
                              - type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - lbs
                                      - oz
                                      - ozs
                                      - g
                                      - gram
                                      - grams
                                      - kg
                                      - kgs
                                      - kilogram
                                      - kilograms
                                    description: |
                                      Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value (non-negative)
                              - type: array
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - lbs
                                        - oz
                                        - ozs
                                        - g
                                        - gram
                                        - grams
                                        - kg
                                        - kgs
                                        - kilogram
                                        - kilograms
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                description: |
                                  Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                          dimensional_weight:
                            nullable: true
                            description: |
                              Product weight. Accepts a single `{unit, value}` object or an array of such
                              segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                              **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                              `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                              at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                              metric is converted, the input unit is not round-tripped: a weight submitted in
                              grams or kilograms reads back in ounces.

                              **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                              (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                              value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                              repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                              written twice rather than a total.
                            oneOf:
                              - type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - lbs
                                      - oz
                                      - ozs
                                      - g
                                      - gram
                                      - grams
                                      - kg
                                      - kgs
                                      - kilogram
                                      - kilograms
                                    description: |
                                      Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value (non-negative)
                              - type: array
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - lbs
                                        - oz
                                        - ozs
                                        - g
                                        - gram
                                        - grams
                                        - kg
                                        - kgs
                                        - kilogram
                                        - kilograms
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                description: |
                                  Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                          product_length:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Length of the variant (in inches)
                          product_width:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Width of the variant (in inches)
                          product_height:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Height of the variant (in inches)
                          box_weight:
                            nullable: true
                            description: |
                              Product weight. Accepts a single `{unit, value}` object or an array of such
                              segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                              **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                              `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                              at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                              metric is converted, the input unit is not round-tripped: a weight submitted in
                              grams or kilograms reads back in ounces.

                              **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                              (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                              value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                              repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                              written twice rather than a total.
                            oneOf:
                              - type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - lbs
                                      - oz
                                      - ozs
                                      - g
                                      - gram
                                      - grams
                                      - kg
                                      - kgs
                                      - kilogram
                                      - kilograms
                                    description: |
                                      Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value (non-negative)
                              - type: array
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - lbs
                                        - oz
                                        - ozs
                                        - g
                                        - gram
                                        - grams
                                        - kg
                                        - kgs
                                        - kilogram
                                        - kilograms
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                description: |
                                  Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                          box_length:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Length of the box (in inches)
                          box_width:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Width of the box (in inches)
                          box_height:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Height of the box (in inches)
                          carton_weight:
                            nullable: true
                            description: |
                              Product weight. Accepts a single `{unit, value}` object or an array of such
                              segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                              **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                              `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                              at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                              metric is converted, the input unit is not round-tripped: a weight submitted in
                              grams or kilograms reads back in ounces.

                              **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                              (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                              value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                              repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                              written twice rather than a total.
                            oneOf:
                              - type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - lbs
                                      - oz
                                      - ozs
                                      - g
                                      - gram
                                      - grams
                                      - kg
                                      - kgs
                                      - kilogram
                                      - kilograms
                                    description: |
                                      Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value (non-negative)
                              - type: array
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - lbs
                                        - oz
                                        - ozs
                                        - g
                                        - gram
                                        - grams
                                        - kg
                                        - kgs
                                        - kilogram
                                        - kilograms
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                description: |
                                  Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                          carton_length:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Length of the carton (in inches)
                          carton_width:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Width of the carton (in inches)
                          carton_height:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Height of the carton (in inches)
                          shipping_weight:
                            nullable: true
                            description: |
                              Product weight. Accepts a single `{unit, value}` object or an array of such
                              segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                              **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                              `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                              at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                              metric is converted, the input unit is not round-tripped: a weight submitted in
                              grams or kilograms reads back in ounces.

                              **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                              (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                              value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                              repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                              written twice rather than a total.
                            oneOf:
                              - type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - lbs
                                      - oz
                                      - ozs
                                      - g
                                      - gram
                                      - grams
                                      - kg
                                      - kgs
                                      - kilogram
                                      - kilograms
                                    description: |
                                      Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value (non-negative)
                              - type: array
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - lbs
                                        - oz
                                        - ozs
                                        - g
                                        - gram
                                        - grams
                                        - kg
                                        - kgs
                                        - kilogram
                                        - kilograms
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                description: |
                                  Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                          shipping_length:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Shipping length (in inches)
                          shipping_width:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Shipping width (in inches)
                          shipping_height:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Shipping height (in inches)
                          pallet_weight:
                            nullable: true
                            description: |
                              Product weight. Accepts a single `{unit, value}` object or an array of such
                              segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                              **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                              `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                              at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                              metric is converted, the input unit is not round-tripped: a weight submitted in
                              grams or kilograms reads back in ounces.

                              **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                              (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                              value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                              repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                              written twice rather than a total.
                            oneOf:
                              - type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - lbs
                                      - oz
                                      - ozs
                                      - g
                                      - gram
                                      - grams
                                      - kg
                                      - kgs
                                      - kilogram
                                      - kilograms
                                    description: |
                                      Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value (non-negative)
                              - type: array
                                items:
                                  type: object
                                  required:
                                    - unit
                                    - value
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - lb
                                        - lbs
                                        - oz
                                        - ozs
                                        - g
                                        - gram
                                        - grams
                                        - kg
                                        - kgs
                                        - kilogram
                                        - kilograms
                                    value:
                                      type: number
                                      format: float
                                      minimum: 0
                                description: |
                                  Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                          pallet_length:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Length of the pallet (in inches)
                          pallet_width:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Width of the pallet (in inches)
                          pallet_height:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: Height of the pallet (in inches)
                          units_per_carton:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: 'Number of units per carton (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                          cartons_per_pallet:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: 'Number of cartons per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                          units_per_pallet:
                            type: number
                            format: float
                            minimum: 0
                            nullable: true
                            description: 'Number of units per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                          lead_time_days:
                            type: integer
                            minimum: 0
                            maximum: 2147483647
                            nullable: true
                            description: Supplier lead time in calendar days (the product's Lead Time). Returned as `lead_time_days` on the product. Omit to leave unchanged.
                          upc:
                            type: string
                            nullable: true
                            description: Variant UPC/Barcode
                          custom_fields:
                            type: object
                            nullable: true
                            description: Custom field values for the variant
                            additionalProperties:
                              type: string
                          tags:
                            type: array
                            nullable: true
                            description: Tags to associate with the variant
                            items:
                              type: string
                          product_variants:
                            type: array
                            minItems: 1
                            description: |
                              The variant option term(s) this child SKU is assigned to (e.g. Size=Large, Color=Red).
                              Use one entry per axis, with the term(s) on `variant_terms`. Any terms used here that
                              aren't yet on the parent's taxonomy are added to it automatically.

                              **Required for every entry in `variants`.** Each child SKU must declare at least one
                              option (axis name + term); a variant with no options is rejected.

                              You may send this under the alias `variant_attributes` instead (matching the GET response shape);
                              both are accepted on write. Returned on the response as the child variant's `variant_attributes`.
                            items:
                              type: object
                              required:
                                - variant_name
                                - variant_terms
                              properties:
                                variant_name:
                                  type: string
                                  description: 'Name of the variant axis (e.g. "Size", "Color")'
                                variant_terms:
                                  type: array
                                  minItems: 1
                                  description: Term value(s) for this axis on this child SKU
                                  items:
                                    type: string
                    boms:
                      type: array
                      nullable: true
                      description: |
                        Array of BOM IDs to attach to the product.
                        Omit this field entirely to leave the product's existing BOM associations unchanged (partial updates do not touch BOMs unless `boms` is provided).
                        When the field **is** provided, it replaces all existing BOM associations: pass an array of IDs to set them, or `null`/an empty array to detach all BOMs.
                      items:
                        type: integer
                        description: BOM ID
                - type: object
                  properties:
                    id:
                      type: integer
                      description: Product ID (required if SKU not provided)
                    sku:
                      type: string
                      description: Product SKU (required if ID not provided)
                  oneOf:
                    - required:
                        - id
                    - required:
                        - sku
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: 'Forbidden - creating a product without skus.create, or changing sku/upc without the field-level permission'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /products/export:
    get:
      operationId: exportProducts
      tags:
        - Products
      summary: Export products (cursor pagination)
      description: |
        Bulk-export active products (`status = 1`) using cursor-based keyset
        pagination. Designed for bulk catalog syncs and pipelines.

        Each run is anchored to a **fixed cutoff time** (set on the first request),
        so pages are stable even if records are updated mid-run. Order is ascending
        by `(updated_at, id)`.

        ## Pagination

        | Parameter | Description |
        |-----------|-------------|
        | `since`   | Lower bound for `updated_at` (inclusive). Required on the **first** page. ISO 8601 date or datetime, UTC recommended. |
        | `cursor`  | Opaque token from `next_cursor` on the previous response. Required on **follow-up** pages. Do not send with `since`. |
        | `limit`   | Max records per page. Default `100`, maximum `1000`. |

        ## Example flow

        ```
        # 1. Start a run
        GET /products/export?since=1970-01-01T00:00:00Z&limit=1000

        # 2. Continue while has_more is true
        GET /products/export?cursor=<next_cursor>

        # 3. Stop when has_more is false
        ```

        ## Notes

        - The cursor is cryptographically signed; do not modify it.
        - Nested data omitted for performance: full BOM line items, variant SKU
          rows, attachments, substitutions, priority list, alternate-SKU unit
          conversion rule expansion. Use `GET /products/{id}` for full detail.
        - Some deployments rewrite to `index.php?q=$uri&$args`; the server ignores
          the `q` query parameter during validation.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: since
          schema:
            type: string
            format: date-time
            example: '1970-01-01T00:00:00Z'
          description: |
            Lower bound for `updated_at` (inclusive). Required on the **first** page;
            omit when using `cursor`.
        - in: query
          name: cursor
          schema:
            type: string
            example: eyJ2IjoxLCJtb2RlIjoiZXhwb3J0In0.abc123
          description: |
            Signed continuation token from a previous response's `next_cursor`.
            Required on **follow-up** pages; cannot be combined with `since`.
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 100
          description: Maximum number of products to return per page.
      responses:
        '200':
          description: Successful export page
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - next_cursor
                  - has_more
                  - meta
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        One product row from the bulk export. Shares core fields with the list/detail
                        product resource but omits expensive nested data (full BOM line items, variant
                        SKU rows, attachments, substitutions, priority list, alternate-SKU unit
                        conversion rule expansion). Use `GET /products/{id}` for full detail.
                      properties:
                        id:
                          type: integer
                        name:
                          type: string
                        description:
                          type: string
                          nullable: true
                        retail_price:
                          type: number
                          format: float
                        wholesale_price:
                          type: number
                          format: float
                        unit_cost:
                          type: number
                          format: float
                          description: From the base weighted price column; `0` when unset.
                        landed_cost:
                          type: number
                          format: float
                          nullable: true
                          description: Weighted landed cost across remaining cost layers. `null` when no positive-cost layer exists.
                        estimated_landed_cost:
                          type: number
                          format: float
                          nullable: true
                          description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                        design_link:
                          type: string
                          nullable: true
                          description: Product design URL or link. `null` when unset or empty.
                        product_length:
                          type: number
                          format: float
                          nullable: true
                        product_width:
                          type: number
                          format: float
                          nullable: true
                        product_height:
                          type: number
                          format: float
                          nullable: true
                        box_length:
                          type: number
                          format: float
                          nullable: true
                        box_width:
                          type: number
                          format: float
                          nullable: true
                        box_height:
                          type: number
                          format: float
                          nullable: true
                        carton_length:
                          type: number
                          format: float
                          nullable: true
                        carton_width:
                          type: number
                          format: float
                          nullable: true
                        carton_height:
                          type: number
                          format: float
                          nullable: true
                        units_per_carton:
                          type: number
                          format: float
                          nullable: true
                          description: Number of units per carton.
                        shipping_length:
                          type: number
                          format: float
                          nullable: true
                        shipping_width:
                          type: number
                          format: float
                          nullable: true
                        shipping_height:
                          type: number
                          format: float
                          nullable: true
                        pallet_length:
                          type: number
                          format: float
                          nullable: true
                        pallet_width:
                          type: number
                          format: float
                          nullable: true
                        pallet_height:
                          type: number
                          format: float
                          nullable: true
                        cartons_per_pallet:
                          type: number
                          format: float
                          nullable: true
                          description: Number of cartons per pallet.
                        units_per_pallet:
                          type: number
                          format: float
                          nullable: true
                          description: Number of units per pallet.
                        product_weight:
                          nullable: true
                          description: |
                            API weight format: `null`, a single `{unit, value}` object, or an array of
                            segments. `unit` is typically `lb`, `lbs`, or `oz`.
                          oneOf:
                            - type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - oz
                                    - lbs
                                value:
                                  type: number
                                  format: float
                            - type: array
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                      - lbs
                                  value:
                                    type: number
                                    format: float
                        product_weight_oz:
                          type: number
                          format: float
                          nullable: true
                        product_weight_lb:
                          type: number
                          format: float
                          nullable: true
                        box_weight:
                          nullable: true
                          description: |
                            API weight format: `null`, a single `{unit, value}` object, or an array of
                            segments. `unit` is typically `lb`, `lbs`, or `oz`.
                          oneOf:
                            - type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - oz
                                    - lbs
                                value:
                                  type: number
                                  format: float
                            - type: array
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                      - lbs
                                  value:
                                    type: number
                                    format: float
                        box_weight_oz:
                          type: number
                          format: float
                          nullable: true
                        box_weight_lb:
                          type: number
                          format: float
                          nullable: true
                        carton_weight:
                          nullable: true
                          description: |
                            API weight format: `null`, a single `{unit, value}` object, or an array of
                            segments. `unit` is typically `lb`, `lbs`, or `oz`.
                          oneOf:
                            - type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - oz
                                    - lbs
                                value:
                                  type: number
                                  format: float
                            - type: array
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                      - lbs
                                  value:
                                    type: number
                                    format: float
                        carton_weight_oz:
                          type: number
                          format: float
                          nullable: true
                        carton_weight_lb:
                          type: number
                          format: float
                          nullable: true
                        shipping_weight:
                          nullable: true
                          description: |
                            API weight format: `null`, a single `{unit, value}` object, or an array of
                            segments. `unit` is typically `lb`, `lbs`, or `oz`.
                          oneOf:
                            - type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - oz
                                    - lbs
                                value:
                                  type: number
                                  format: float
                            - type: array
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                      - lbs
                                  value:
                                    type: number
                                    format: float
                        shipping_weight_oz:
                          type: number
                          format: float
                          nullable: true
                        shipping_weight_lb:
                          type: number
                          format: float
                          nullable: true
                        pallet_weight:
                          nullable: true
                          description: |
                            API weight format: `null`, a single `{unit, value}` object, or an array of
                            segments. `unit` is typically `lb`, `lbs`, or `oz`.
                          oneOf:
                            - type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - oz
                                    - lbs
                                value:
                                  type: number
                                  format: float
                            - type: array
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                      - lbs
                                  value:
                                    type: number
                                    format: float
                        pallet_weight_oz:
                          type: number
                          format: float
                          nullable: true
                        pallet_weight_lb:
                          type: number
                          format: float
                          nullable: true
                        dimensional_weight:
                          nullable: true
                          description: |
                            API weight format: `null`, a single `{unit, value}` object, or an array of
                            segments. `unit` is typically `lb`, `lbs`, or `oz`.
                          oneOf:
                            - type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - oz
                                    - lbs
                                value:
                                  type: number
                                  format: float
                            - type: array
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                      - lbs
                                  value:
                                    type: number
                                    format: float
                        dimensional_weight_oz:
                          type: number
                          format: float
                          nullable: true
                        dimensional_weight_lb:
                          type: number
                          format: float
                          nullable: true
                        qty_low_alert:
                          type: integer
                        qty_reorder_threshold:
                          type: integer
                        qty_minimum:
                          type: integer
                        lead_time_days:
                          type: integer
                          nullable: true
                          description: 'Lead time stored on the product, in calendar days. `null` when not set.'
                        sellable:
                          type: boolean
                        discontinued:
                          type: boolean
                        image_url:
                          type: string
                          nullable: true
                        category:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                          required:
                            - id
                            - name
                        subcategory:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                          required:
                            - id
                            - name
                        custom_fields:
                          type: object
                          description: 'Keyed by custom field label; empty object when none. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field with no numeric value is left out.'
                          additionalProperties: true
                        variant_attributes:
                          description: 'Decoded `product_variants` JSON; shape varies (object, array, or null).'
                          nullable: true
                        sku:
                          type: string
                          description: Internal (master) SKU.
                        alternate_skus:
                          type: array
                          items:
                            type: object
                            required:
                              - id
                              - sku
                              - unit_conversion_rule_id
                            properties:
                              id:
                                type: integer
                              sku:
                                type: string
                              unit_conversion_rule_id:
                                type: integer
                                nullable: true
                                description: ID only; the rule object is not expanded in export rows.
                        upc:
                          type: string
                          nullable: true
                        tags:
                          type: array
                          items:
                            type: object
                            required:
                              - id
                              - name
                              - description
                              - icon
                              - color
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              icon:
                                type: string
                                nullable: true
                              color:
                                type: string
                                nullable: true
                        supplier:
                          type: object
                          nullable: true
                          description: Preferred supplier (factory) when set.
                          properties:
                            id:
                              type: integer
                            status:
                              type: integer
                              nullable: true
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            street_address:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                            state:
                              type: string
                              nullable: true
                            zip:
                              type: string
                              nullable: true
                            country:
                              type: string
                              nullable: true
                            supplier_admin_id:
                              type: integer
                              nullable: true
                            contact_name:
                              type: string
                              nullable: true
                            contact_email:
                              type: string
                              nullable: true
                            contact_phone:
                              type: string
                              nullable: true
                            created_by:
                              type: string
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_by:
                              type: string
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                        substitutions:
                          type: array
                          description: 'Always empty in export; use `GET /products/{id}` for substitutions.'
                          items:
                            type: object
                        boms:
                          type: array
                          description: 'Shallow BOM assignments only (IDs). Use `GET /boms/{bomId}` for full detail.'
                          items:
                            type: object
                            required:
                              - id
                            properties:
                              id:
                                type: integer
                        type:
                          type: string
                          description: '`PRODUCT` or `KIT` (and other RFQ types if present).'
                          example: PRODUCT
                        kit_items:
                          type: array
                          description: Populated when `type` is `KIT`; otherwise empty.
                          items:
                            type: object
                            required:
                              - id
                              - product_id
                              - quantity
                              - uom_id
                              - base_uom_quantity
                              - price
                              - original_price
                              - total
                            properties:
                              id:
                                type: integer
                              product_id:
                                type: integer
                              quantity:
                                type: number
                                format: float
                              uom_id:
                                type: integer
                              base_uom_quantity:
                                type: number
                                format: float
                              price:
                                type: number
                                format: float
                              original_price:
                                type: number
                                format: float
                              total:
                                type: number
                                format: float
                                description: '`quantity × price`'
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                      required:
                        - id
                        - name
                        - description
                        - retail_price
                        - wholesale_price
                        - unit_cost
                        - sku
                        - upc
                        - sellable
                        - discontinued
                        - alternate_skus
                        - tags
                        - custom_fields
                        - substitutions
                        - boms
                        - type
                        - kit_items
                        - created_at
                        - updated_at
                  next_cursor:
                    type: string
                    nullable: true
                    description: Signed cursor token to fetch the next page. `null` when the export is complete.
                    example: eyJ2IjoxLCJtb2RlIjoiZXhwb3J0In0.abc123
                  has_more:
                    type: boolean
                    description: '`true` when the page is full (`data.length === limit`), indicating more rows may exist.'
                  meta:
                    type: object
                    required:
                      - rows
                    properties:
                      rows:
                        type: integer
                        minimum: 0
                        description: Number of items in `data` for this response.
        '400':
          description: Invalid or malformed cursor
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
                    example: invalid_cursor
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /products/bulk-attach-boms:
    post:
      operationId: bulkAttachBomsToProducts
      tags:
        - Products
      summary: Bulk attach BOMs to products
      description: |
        Attach BOMs to many products in a single request by matching each
        product's `internal_sku` to a BOM `bom_name`. Each item is an independent
        SKU + BOM pair (this is not a one-BOM-to-many-SKUs operation), and every
        row is reported individually so partial success is possible.

        Rows whose SKU or BOM cannot be resolved are skipped and returned with an
        `error` status and a `reason`; the rest are still attached. The overall
        request returns `200` even when some rows fail — inspect the `results`
        array and the `failed` count to detect per-row problems.

        **Modes**
        - `add` (default): preserves existing BOM attachments on each touched SKU
          (`syncWithoutDetaching`).
        - `replace`: replaces all BOMs on each touched SKU with the ones supplied
          in this request (`sync`).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  minItems: 1
                  maxItems: 10000
                  description: SKU + BOM name pairs to attach.
                  items:
                    type: object
                    required:
                      - internal_sku
                      - bom_name
                    properties:
                      internal_sku:
                        type: string
                        maxLength: 255
                        description: The product's internal SKU.
                      bom_name:
                        type: string
                        maxLength: 255
                        description: The name of the BOM to attach.
                mode:
                  type: string
                  enum:
                    - add
                    - replace
                  default: add
                  nullable: true
                  description: |
                    Attachment mode. `add` (default) preserves existing BOM
                    attachments; `replace` replaces all BOMs on each touched SKU.
            example:
              items:
                - internal_sku: RED-S
                  bom_name: BOM-RED-S
                - internal_sku: RED-M
                  bom_name: BOM-RED-M
              mode: add
      responses:
        '200':
          description: |
            Processing summary. Returned even when some rows fail; inspect
            `results` and `failed` for per-row outcomes.
          content:
            application/json:
              schema:
                type: object
                properties:
                  processed:
                    type: integer
                    description: Total number of items in the request.
                  succeeded:
                    type: integer
                    description: Number of SKU + BOM pairs successfully attached.
                  failed:
                    type: integer
                    description: Number of pairs that could not be attached.
                  mode:
                    type: string
                    enum:
                      - add
                      - replace
                    description: The mode used for this request.
                  results:
                    type: array
                    description: 'Per-row outcome, one entry per input pair.'
                    items:
                      type: object
                      properties:
                        internal_sku:
                          type: string
                          description: The product internal SKU for this row.
                        bom_name:
                          type: string
                          description: The BOM name for this row.
                        status:
                          type: string
                          enum:
                            - attached
                            - error
                          description: Outcome for this pair.
                        reason:
                          type: string
                          description: |
                            Failure reason when `status` is `error` (e.g.
                            `SKU not found`, `BOM not found`). Absent on success.
              example:
                processed: 2
                succeeded: 1
                failed: 1
                mode: add
                results:
                  - internal_sku: RED-S
                    bom_name: BOM-RED-S
                    status: attached
                  - internal_sku: RED-M
                    bom_name: BOM-RED-M
                    status: error
                    reason: BOM not found
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/products/{id}':
    get:
      operationId: getProductById
      tags:
        - Products
      summary: Single product
      description: |
        Get detailed information about a specific product by its ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Product ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: updateProductById
      tags:
        - Products
      summary: Update a product
      description: |
        Update a specific product's information. Both `POST` and `PUT` are accepted
        against this path and behave identically.

        **Adding or updating variants**

        The `variants` array upserts by `sku` (or `id`) — include a child to create or update it,
        and omit children you don't want to change (they're left untouched, not deleted).

        To add a new variant to an existing product, send just the new entry in `variants[]`. To
        change a variant's option assignment, send that child's `sku` plus its new `product_variants`
        axis/terms — the parent's taxonomy will pick up any new terms automatically. See
        **Working with variants** under `POST /products` for the full parent/child model and a worked
        example.

        **Field-level permissions for SKU and UPC**

        Changing the product's `sku` field requires the `skus.update.sku` permission on the API
        token's role. Changing the `upc` field requires `skus.update.upc`. Requests that attempt
        to change either field without the appropriate permission return `403`. These checks are
        skipped when the field is omitted or the incoming value matches the current value.
        Adding a new child SKU through `variants[]` creates a product, so it also requires
        `skus.create` (see `POST /products`).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 200
                  description: Product name
                category_id:
                  type: integer
                  description: ID of the product category
                category:
                  type: object
                  nullable: true
                  properties:
                    name:
                      type: string
                      description: 'Name of the product category. If the category is not found in Luminous, it will be created.'
                  description: Product category information
                sku:
                  type: string
                  maxLength: 100
                  description: Internal SKU. Changing this value requires the `skus.update.sku` permission; the request returns 403 if the authenticated token's role lacks it. Omitting the field or sending the same value as the current SKU skips the check.
                qty_low_alert:
                  type: integer
                  nullable: true
                  description: Quantity threshold for low stock alerts
                qty_reorder_threshold:
                  type: integer
                  nullable: true
                  description: Quantity threshold for reordering
                qty_minimum:
                  type: integer
                  nullable: true
                  description: Minimum quantity to maintain
                supplier_id:
                  type: integer
                  nullable: true
                  description: ID of the preferred supplier
                supplier:
                  type: object
                  nullable: true
                  properties:
                    name:
                      type: string
                      description: 'Name of the preferred supplier. If the supplier is not found in Luminous, it will be created.'
                  description: Product preferred supplier information
                distribution_template_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the distribution template (size curve) to assign to this product.
                    Pass `null` to clear the current assignment. Use
                    `GET /products/{productId}/distribution-template/candidates` to find
                    compatible templates for a master SKU.
                grid_template_category_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the variant distribution group (size-curve category) to assign to
                    this product. Omitting it or passing `null` leaves the current group
                    unchanged. Unlike `distribution_template_id`, this does not pin a single
                    curve: the group is combined with each destination warehouse to pick the
                    right curve per buy. Returned as `distribution_template_category` on the
                    product response. Returns `422` if the group's axes don't fit the product.
                image_url:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: URL to product image
                images:
                  type: array
                  nullable: true
                  maxItems: 20
                  description: |
                    Gallery images to add from links, in gallery order. A queued job downloads each link into the
                    product's gallery, so the images appear in `GET /products/{id}` shortly after the response.
                    - The entry marked `is_primary` (at most one) goes first; with none marked, the first entry is the
                      hero image channels receive first.
                    - Dropbox file share links and Google Drive file links work as pasted. A Dropbox **folder** link is
                      rejected; share each image file.
                    - Up to 20 per request. A bad entry fails the whole request with a `422` that names the link, and
                      nothing is saved.
                    - Links already in the gallery are re-ordered, not downloaded again. Images not listed stay, after
                      the listed ones.
                    - The hero also becomes `image_url`, unless the same request sends `image_url`.
                    - A link that cannot be downloaded (private, expired, not an image) is skipped; the other images
                      still land.
                  items:
                    type: object
                    required:
                      - url
                    properties:
                      url:
                        type: string
                        description: Link to the image file.
                        example: 'https://cdn.example.com/tee-front.jpg'
                      is_primary:
                        type: boolean
                        description: Make this image the hero (first in the gallery). At most one entry.
                sellable:
                  type: boolean
                  nullable: true
                  description: Whether the product can be sold
                lot_tracking:
                  type: boolean
                  nullable: true
                  description: Whether to track product by lots
                is_drop_ship_item:
                  type: boolean
                  nullable: true
                  description: Flag the product as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                taxable:
                  type: boolean
                  nullable: true
                  description: Whether the product is subject to sales tax. Defaults to true when omitted.
                sub_category_id:
                  type: integer
                  nullable: true
                  description: 'ID of the product subcategory. Takes precedence over `subcategory_id`, `subcategory.id` and `subcategory.name`.'
                subcategory_id:
                  type: integer
                  nullable: true
                  description: 'Alias for `sub_category_id`. Used only when `sub_category_id` and `subcategory.name` are not sent. `0` or empty is ignored. Returns `422` if the ID doesn''t match an existing, non-deleted subcategory.'
                subcategory:
                  type: object
                  nullable: true
                  properties:
                    id:
                      type: integer
                      nullable: true
                      description: 'Alias for `sub_category_id` (the shape returned by GET). Used only when `sub_category_id` and `subcategory.name` are not sent. `0` or empty is ignored. Returns `422` if the ID doesn''t match an existing, non-deleted subcategory.'
                    name:
                      type: string
                      maxLength: 200
                      description: 'Name of the product sub-category, used when `sub_category_id` is not sent. If `category_id` or `category.name` is also sent, the sub-category is looked up in that category and created if missing. Otherwise it must already exist: it is matched within the product''s current category, or, if the product has no category, the name must match exactly one sub-category. Returns `422` (and saves nothing) if the name is not found or is ambiguous.'
                  description: Product sub-category information
                default_receiving_location_id:
                  type: integer
                  nullable: true
                  description: Default location ID for receiving this product
                default_assembly_location_id:
                  type: integer
                  nullable: true
                  description: 'Default location (bin) ID where assembled goods (BOM output) are credited for this product. When set, it is used as the destination when defaulting assembly/disassembly work, falling back to `default_receiving_location_id` and then the warehouse default.'
                description:
                  type: string
                  nullable: true
                  description: Product description
                wholesale_price:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Wholesale price
                retail_price:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Retail price
                unit_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Cost per unit. Interpreted in the currency given by `unit_cost_currency`; when that is omitted, `unit_cost` is the tenant base-currency inventory cost.
                unit_cost_currency:
                  type: string
                  nullable: true
                  example: EUR
                  description: |
                    Optional ISO currency code for `unit_cost`. Omit (or send `null`) to treat `unit_cost` as the base-currency inventory cost (existing behavior; any stored supplier purchase price is left untouched). Send the tenant base currency to set the base cost explicitly and clear a foreign-currency purchase price on the preferred supplier. Send the preferred supplier's default currency to store `unit_cost` as the supplier purchase (FOB) price on that supplier's SKU; it is converted at today's exchange rate into the base-currency inventory cost. Any other currency, or a supplier currency without a preferred supplier that has a currency, returns `422` keyed on `unit_cost_currency`. Only applies when `unit_cost` is also sent.
                manufacturing_fee:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Manufacturing fee per unit
                estimated_landed_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Planner's estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. Uses the same currency as the product's other costs (there is no separate currency field). Send `null` to clear it.
                design_link:
                  type: string
                  maxLength: 2000
                  nullable: true
                  description: Product design URL or link. Send `null` to clear it.
                product_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                dimensional_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                product_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the product (in inches)
                product_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the product (in inches)
                product_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the product (in inches)
                box_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                box_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the box (in inches)
                box_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the box (in inches)
                box_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the box (in inches)
                carton_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                carton_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the carton (in inches)
                carton_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the carton (in inches)
                carton_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the carton (in inches)
                shipping_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                shipping_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping length (in inches)
                shipping_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping width (in inches)
                shipping_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping height (in inches)
                pallet_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                pallet_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the pallet (in inches)
                pallet_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the pallet (in inches)
                pallet_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the pallet (in inches)
                units_per_carton:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of units per carton (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                cartons_per_pallet:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of cartons per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                units_per_pallet:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of units per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                lead_time_days:
                  type: integer
                  minimum: 0
                  maximum: 2147483647
                  nullable: true
                  description: Supplier lead time in calendar days (the product's Lead Time). Returned as `lead_time_days` on the product. Omit to leave unchanged.
                upc:
                  type: string
                  nullable: true
                  description: UPC/Barcode. Changing this value requires the `skus.update.upc` permission; the request returns 403 if the authenticated token's role lacks it. Omitting the field or sending the same value as the current UPC skips the check.
                default_supply_method:
                  type: string
                  nullable: true
                  maxLength: 50
                  enum:
                    - purchase
                    - vendor_supplied
                    - assemble
                    - on_hand
                    - assembly_order
                    - buy_and_ship
                    - brand_supplied
                  description: |
                    Default supply mode used when planning replenishment for this product.
                    Determines whether the system expects to purchase, drop-ship, assemble,
                    or pull from on-hand stock when supplying demand.
                priority_list_id:
                  type: integer
                  nullable: true
                  description: 'ID of the fulfillment priority list to assign to this product. Only lists you manage are accepted; an unknown, deleted, or system-owned re-route list (named `Re-route: <channel>`) returns 400 "does not exist".'
                custom_fields:
                  type: object
                  nullable: true
                  description: |
                    Custom field values, keyed by label. Only the labels sent are changed. Sending `null`,
                    `""` or `[]` for a label clears that field's value (dropdown fields included);
                    an empty value for a label that is not defined is ignored.
                  additionalProperties:
                    type: string
                    nullable: true
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the product
                  items:
                    type: string
                default_selling_unit_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit of measure this product is sold in.

                    If omitted (along with `selling_uom`), Luminous defaults it to the account's
                    base unit of measure (e.g. `ea` under the `Quantity` unit class). The request is
                    rejected only if the account has no unit of measure configured at all.
                default_purchase_unit_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit of measure this product is purchased in.

                    If omitted (along with `purchase_uom`), Luminous defaults it to the account's
                    base unit of measure (e.g. `ea`).
                unit_class_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit class this product's units belong to (e.g. `Quantity`).

                    If omitted, Luminous defaults it to the unit class of the account's base unit.
                selling_uom:
                  type: object
                  nullable: true
                  description: |
                    Selling unit of measure by name — an alternative to `default_selling_unit_id`.
                    When `default_selling_unit_id` is not provided, the named UOM is resolved to its ID.
                  properties:
                    name:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: 'Name of the selling unit of measure (e.g. "ea", "case")'
                purchase_uom:
                  type: object
                  nullable: true
                  description: |
                    Purchase unit of measure by name — an alternative to `default_purchase_unit_id`.
                    When `default_purchase_unit_id` is not provided, the named UOM is resolved to its ID.
                  properties:
                    name:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: 'Name of the purchase unit of measure (e.g. "ea", "case")'
                product_variants:
                  type: array
                  nullable: true
                  description: |
                    Variant option taxonomy for the product — the axes (e.g. Size, Color) and the allowed terms
                    on each axis.

                    **You almost never need to set this.** Tag each child SKU under `variants[].product_variants`
                    with the terms it represents instead, and Luminous will extend the parent taxonomy
                    automatically as the union of every term used by the children. Setting this directly is only
                    useful as an escape hatch (e.g. seeding an empty option set, or pruning a term no child uses).

                    Returned on the response as `variant_attributes` (same shape).
                  items:
                    type: object
                    required:
                      - variant_name
                    properties:
                      variant_name:
                        type: string
                        description: 'Name of the variant axis (e.g. "Size", "Color")'
                      variant_terms:
                        type: array
                        nullable: true
                        description: Allowed terms for this variant axis
                        items:
                          type: string
                variant_template:
                  nullable: true
                  description: |
                    A variant template to expand into child SKUs, given as either the template's **id**
                    (integer) or its **name** (string). When set on a master product, the template's option
                    axes are expanded into child variant SKUs — the same one-click "generate variants" step
                    available in the SKU form, reachable from the API.

                    Rules:
                    - **Ignored when you also send an explicit `variants` array** — being specific always wins
                      over a preset.
                    - **Idempotent** — skipped when the product already has child variants, so re-sending the
                      same request does not duplicate them.
                    - An unknown template name/id fails loudly with a `422` validation error rather than
                      silently producing a master with no variants.
                  oneOf:
                    - type: integer
                    - type: string
                variants:
                  type: array
                  nullable: true
                  description: Product variants
                  items:
                    type: object
                    required:
                      - sku
                      - product_variants
                    properties:
                      name:
                        type: string
                        maxLength: 200
                        description: Variant name
                      sku:
                        type: string
                        maxLength: 100
                        description: Variant SKU
                      image_url:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: URL to variant image
                      qty_low_alert:
                        type: integer
                        nullable: true
                        description: Quantity threshold for low stock alerts
                      qty_reorder_threshold:
                        type: integer
                        nullable: true
                        description: Quantity threshold for reordering
                      qty_minimum:
                        type: integer
                        nullable: true
                        description: Minimum quantity to maintain
                      supplier_id:
                        type: integer
                        nullable: true
                        description: ID of the variant's preferred supplier
                      supplier:
                        type: object
                        nullable: true
                        properties:
                          name:
                            type: string
                            description: 'Name of the preferred supplier. If the supplier is not found in Luminous, it will be created.'
                        description: Product preferred supplier information
                      sellable:
                        type: boolean
                        nullable: true
                        description: Whether the variant can be sold
                      discontinued:
                        type: boolean
                        nullable: true
                        description: If an item is discontinued it will be hidden by default in the Luminous UI
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location ID for receiving this variant
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this variant
                      description:
                        type: string
                        nullable: true
                        description: Variant description
                      wholesale_price:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant wholesale price
                      retail_price:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant retail price
                      unit_cost:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant cost per unit
                      product_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      dimensional_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      product_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the variant (in inches)
                      product_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the variant (in inches)
                      product_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the variant (in inches)
                      box_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      box_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      carton_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the carton (in inches)
                      shipping_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      shipping_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      pallet_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the pallet (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of units per carton (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      cartons_per_pallet:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of cartons per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      units_per_pallet:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of units per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      lead_time_days:
                        type: integer
                        minimum: 0
                        maximum: 2147483647
                        nullable: true
                        description: Supplier lead time in calendar days (the product's Lead Time). Returned as `lead_time_days` on the product. Omit to leave unchanged.
                      upc:
                        type: string
                        nullable: true
                        description: Variant UPC/Barcode
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for the variant
                        additionalProperties:
                          type: string
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with the variant
                        items:
                          type: string
                      product_variants:
                        type: array
                        minItems: 1
                        description: |
                          The variant option term(s) this child SKU is assigned to (e.g. Size=Large, Color=Red).
                          Use one entry per axis, with the term(s) on `variant_terms`. Any terms used here that
                          aren't yet on the parent's taxonomy are added to it automatically.

                          **Required for every entry in `variants`.** Each child SKU must declare at least one
                          option (axis name + term); a variant with no options is rejected.

                          You may send this under the alias `variant_attributes` instead (matching the GET response shape);
                          both are accepted on write. Returned on the response as the child variant's `variant_attributes`.
                        items:
                          type: object
                          required:
                            - variant_name
                            - variant_terms
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              minItems: 1
                              description: Term value(s) for this axis on this child SKU
                              items:
                                type: string
                boms:
                  type: array
                  nullable: true
                  description: |
                    Array of BOM IDs to attach to the product.
                    Omit this field entirely to leave the product's existing BOM associations unchanged (partial updates do not touch BOMs unless `boms` is provided).
                    When the field **is** provided, it replaces all existing BOM associations: pass an array of IDs to set them, or `null`/an empty array to detach all BOMs.
                  items:
                    type: integer
                    description: BOM ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Forbidden - insufficient field-write permissions (e.g. changing sku without skus.update.sku)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: Conflict - SKU already exists
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    put:
      operationId: updateProductByIdPut
      tags:
        - Products
      summary: Update a product (PUT)
      description: |
        Identical to `POST /products/{productId}` — provided so clients that prefer the
        standard `PUT` verb for updates can use it. See that endpoint for variant-handling
        notes and the field-level permission requirements for `sku` and `upc`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 200
                  description: Product name
                category_id:
                  type: integer
                  description: ID of the product category
                category:
                  type: object
                  nullable: true
                  properties:
                    name:
                      type: string
                      description: 'Name of the product category. If the category is not found in Luminous, it will be created.'
                  description: Product category information
                sku:
                  type: string
                  maxLength: 100
                  description: Internal SKU. Changing this value requires the `skus.update.sku` permission; the request returns 403 if the authenticated token's role lacks it. Omitting the field or sending the same value as the current SKU skips the check.
                qty_low_alert:
                  type: integer
                  nullable: true
                  description: Quantity threshold for low stock alerts
                qty_reorder_threshold:
                  type: integer
                  nullable: true
                  description: Quantity threshold for reordering
                qty_minimum:
                  type: integer
                  nullable: true
                  description: Minimum quantity to maintain
                supplier_id:
                  type: integer
                  nullable: true
                  description: ID of the preferred supplier
                supplier:
                  type: object
                  nullable: true
                  properties:
                    name:
                      type: string
                      description: 'Name of the preferred supplier. If the supplier is not found in Luminous, it will be created.'
                  description: Product preferred supplier information
                distribution_template_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the distribution template (size curve) to assign to this product.
                    Pass `null` to clear the current assignment. Use
                    `GET /products/{productId}/distribution-template/candidates` to find
                    compatible templates for a master SKU.
                grid_template_category_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the variant distribution group (size-curve category) to assign to
                    this product. Omitting it or passing `null` leaves the current group
                    unchanged. Unlike `distribution_template_id`, this does not pin a single
                    curve: the group is combined with each destination warehouse to pick the
                    right curve per buy. Returned as `distribution_template_category` on the
                    product response. Returns `422` if the group's axes don't fit the product.
                image_url:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: URL to product image
                images:
                  type: array
                  nullable: true
                  maxItems: 20
                  description: |
                    Gallery images to add from links, in gallery order. A queued job downloads each link into the
                    product's gallery, so the images appear in `GET /products/{id}` shortly after the response.
                    - The entry marked `is_primary` (at most one) goes first; with none marked, the first entry is the
                      hero image channels receive first.
                    - Dropbox file share links and Google Drive file links work as pasted. A Dropbox **folder** link is
                      rejected; share each image file.
                    - Up to 20 per request. A bad entry fails the whole request with a `422` that names the link, and
                      nothing is saved.
                    - Links already in the gallery are re-ordered, not downloaded again. Images not listed stay, after
                      the listed ones.
                    - The hero also becomes `image_url`, unless the same request sends `image_url`.
                    - A link that cannot be downloaded (private, expired, not an image) is skipped; the other images
                      still land.
                  items:
                    type: object
                    required:
                      - url
                    properties:
                      url:
                        type: string
                        description: Link to the image file.
                        example: 'https://cdn.example.com/tee-front.jpg'
                      is_primary:
                        type: boolean
                        description: Make this image the hero (first in the gallery). At most one entry.
                sellable:
                  type: boolean
                  nullable: true
                  description: Whether the product can be sold
                lot_tracking:
                  type: boolean
                  nullable: true
                  description: Whether to track product by lots
                is_drop_ship_item:
                  type: boolean
                  nullable: true
                  description: Flag the product as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                taxable:
                  type: boolean
                  nullable: true
                  description: Whether the product is subject to sales tax. Defaults to true when omitted.
                sub_category_id:
                  type: integer
                  nullable: true
                  description: 'ID of the product subcategory. Takes precedence over `subcategory_id`, `subcategory.id` and `subcategory.name`.'
                subcategory_id:
                  type: integer
                  nullable: true
                  description: 'Alias for `sub_category_id`. Used only when `sub_category_id` and `subcategory.name` are not sent. `0` or empty is ignored. Returns `422` if the ID doesn''t match an existing, non-deleted subcategory.'
                subcategory:
                  type: object
                  nullable: true
                  properties:
                    id:
                      type: integer
                      nullable: true
                      description: 'Alias for `sub_category_id` (the shape returned by GET). Used only when `sub_category_id` and `subcategory.name` are not sent. `0` or empty is ignored. Returns `422` if the ID doesn''t match an existing, non-deleted subcategory.'
                    name:
                      type: string
                      maxLength: 200
                      description: 'Name of the product sub-category, used when `sub_category_id` is not sent. If `category_id` or `category.name` is also sent, the sub-category is looked up in that category and created if missing. Otherwise it must already exist: it is matched within the product''s current category, or, if the product has no category, the name must match exactly one sub-category. Returns `422` (and saves nothing) if the name is not found or is ambiguous.'
                  description: Product sub-category information
                default_receiving_location_id:
                  type: integer
                  nullable: true
                  description: Default location ID for receiving this product
                default_assembly_location_id:
                  type: integer
                  nullable: true
                  description: 'Default location (bin) ID where assembled goods (BOM output) are credited for this product. When set, it is used as the destination when defaulting assembly/disassembly work, falling back to `default_receiving_location_id` and then the warehouse default.'
                description:
                  type: string
                  nullable: true
                  description: Product description
                wholesale_price:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Wholesale price
                retail_price:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Retail price
                unit_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Cost per unit. Interpreted in the currency given by `unit_cost_currency`; when that is omitted, `unit_cost` is the tenant base-currency inventory cost.
                unit_cost_currency:
                  type: string
                  nullable: true
                  example: EUR
                  description: |
                    Optional ISO currency code for `unit_cost`. Omit (or send `null`) to treat `unit_cost` as the base-currency inventory cost (existing behavior; any stored supplier purchase price is left untouched). Send the tenant base currency to set the base cost explicitly and clear a foreign-currency purchase price on the preferred supplier. Send the preferred supplier's default currency to store `unit_cost` as the supplier purchase (FOB) price on that supplier's SKU; it is converted at today's exchange rate into the base-currency inventory cost. Any other currency, or a supplier currency without a preferred supplier that has a currency, returns `422` keyed on `unit_cost_currency`. Only applies when `unit_cost` is also sent.
                manufacturing_fee:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Manufacturing fee per unit
                estimated_landed_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Planner's estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. Uses the same currency as the product's other costs (there is no separate currency field). Send `null` to clear it.
                design_link:
                  type: string
                  maxLength: 2000
                  nullable: true
                  description: Product design URL or link. Send `null` to clear it.
                product_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                dimensional_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                product_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the product (in inches)
                product_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the product (in inches)
                product_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the product (in inches)
                box_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                box_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the box (in inches)
                box_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the box (in inches)
                box_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the box (in inches)
                carton_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                carton_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the carton (in inches)
                carton_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the carton (in inches)
                carton_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the carton (in inches)
                shipping_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                shipping_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping length (in inches)
                shipping_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping width (in inches)
                shipping_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Shipping height (in inches)
                pallet_weight:
                  nullable: true
                  description: |
                    Product weight. Accepts a single `{unit, value}` object or an array of such
                    segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                    **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                    `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                    at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                    metric is converted, the input unit is not round-tripped: a weight submitted in
                    grams or kilograms reads back in ounces.

                    **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                    (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                    value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                    repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                    written twice rather than a total.
                  oneOf:
                    - type: object
                      required:
                        - unit
                        - value
                      properties:
                        unit:
                          type: string
                          enum:
                            - lb
                            - lbs
                            - oz
                            - ozs
                            - g
                            - gram
                            - grams
                            - kg
                            - kgs
                            - kilogram
                            - kilograms
                          description: |
                            Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                        value:
                          type: number
                          format: float
                          minimum: 0
                          description: Weight value (non-negative)
                    - type: array
                      items:
                        type: object
                        required:
                          - unit
                          - value
                        properties:
                          unit:
                            type: string
                            enum:
                              - lb
                              - lbs
                              - oz
                              - ozs
                              - g
                              - gram
                              - grams
                              - kg
                              - kgs
                              - kilogram
                              - kilograms
                          value:
                            type: number
                            format: float
                            minimum: 0
                      description: |
                        Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                pallet_length:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Length of the pallet (in inches)
                pallet_width:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Width of the pallet (in inches)
                pallet_height:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Height of the pallet (in inches)
                units_per_carton:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of units per carton (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                cartons_per_pallet:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of cartons per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                units_per_pallet:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Number of units per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                lead_time_days:
                  type: integer
                  minimum: 0
                  maximum: 2147483647
                  nullable: true
                  description: Supplier lead time in calendar days (the product's Lead Time). Returned as `lead_time_days` on the product. Omit to leave unchanged.
                upc:
                  type: string
                  nullable: true
                  description: UPC/Barcode. Changing this value requires the `skus.update.upc` permission; the request returns 403 if the authenticated token's role lacks it. Omitting the field or sending the same value as the current UPC skips the check.
                default_supply_method:
                  type: string
                  nullable: true
                  maxLength: 50
                  enum:
                    - purchase
                    - vendor_supplied
                    - assemble
                    - on_hand
                    - assembly_order
                    - buy_and_ship
                    - brand_supplied
                  description: |
                    Default supply mode used when planning replenishment for this product.
                    Determines whether the system expects to purchase, drop-ship, assemble,
                    or pull from on-hand stock when supplying demand.
                priority_list_id:
                  type: integer
                  nullable: true
                  description: 'ID of the fulfillment priority list to assign to this product. Only lists you manage are accepted; an unknown, deleted, or system-owned re-route list (named `Re-route: <channel>`) returns 400 "does not exist".'
                custom_fields:
                  type: object
                  nullable: true
                  description: |
                    Custom field values, keyed by label. Only the labels sent are changed. Sending `null`,
                    `""` or `[]` for a label clears that field's value (dropdown fields included);
                    an empty value for a label that is not defined is ignored.
                  additionalProperties:
                    type: string
                    nullable: true
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the product
                  items:
                    type: string
                default_selling_unit_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit of measure this product is sold in.

                    If omitted (along with `selling_uom`), Luminous defaults it to the account's
                    base unit of measure (e.g. `ea` under the `Quantity` unit class). The request is
                    rejected only if the account has no unit of measure configured at all.
                default_purchase_unit_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit of measure this product is purchased in.

                    If omitted (along with `purchase_uom`), Luminous defaults it to the account's
                    base unit of measure (e.g. `ea`).
                unit_class_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of the unit class this product's units belong to (e.g. `Quantity`).

                    If omitted, Luminous defaults it to the unit class of the account's base unit.
                selling_uom:
                  type: object
                  nullable: true
                  description: |
                    Selling unit of measure by name — an alternative to `default_selling_unit_id`.
                    When `default_selling_unit_id` is not provided, the named UOM is resolved to its ID.
                  properties:
                    name:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: 'Name of the selling unit of measure (e.g. "ea", "case")'
                purchase_uom:
                  type: object
                  nullable: true
                  description: |
                    Purchase unit of measure by name — an alternative to `default_purchase_unit_id`.
                    When `default_purchase_unit_id` is not provided, the named UOM is resolved to its ID.
                  properties:
                    name:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: 'Name of the purchase unit of measure (e.g. "ea", "case")'
                product_variants:
                  type: array
                  nullable: true
                  description: |
                    Variant option taxonomy for the product — the axes (e.g. Size, Color) and the allowed terms
                    on each axis.

                    **You almost never need to set this.** Tag each child SKU under `variants[].product_variants`
                    with the terms it represents instead, and Luminous will extend the parent taxonomy
                    automatically as the union of every term used by the children. Setting this directly is only
                    useful as an escape hatch (e.g. seeding an empty option set, or pruning a term no child uses).

                    Returned on the response as `variant_attributes` (same shape).
                  items:
                    type: object
                    required:
                      - variant_name
                    properties:
                      variant_name:
                        type: string
                        description: 'Name of the variant axis (e.g. "Size", "Color")'
                      variant_terms:
                        type: array
                        nullable: true
                        description: Allowed terms for this variant axis
                        items:
                          type: string
                variant_template:
                  nullable: true
                  description: |
                    A variant template to expand into child SKUs, given as either the template's **id**
                    (integer) or its **name** (string). When set on a master product, the template's option
                    axes are expanded into child variant SKUs — the same one-click "generate variants" step
                    available in the SKU form, reachable from the API.

                    Rules:
                    - **Ignored when you also send an explicit `variants` array** — being specific always wins
                      over a preset.
                    - **Idempotent** — skipped when the product already has child variants, so re-sending the
                      same request does not duplicate them.
                    - An unknown template name/id fails loudly with a `422` validation error rather than
                      silently producing a master with no variants.
                  oneOf:
                    - type: integer
                    - type: string
                variants:
                  type: array
                  nullable: true
                  description: Product variants
                  items:
                    type: object
                    required:
                      - sku
                      - product_variants
                    properties:
                      name:
                        type: string
                        maxLength: 200
                        description: Variant name
                      sku:
                        type: string
                        maxLength: 100
                        description: Variant SKU
                      image_url:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: URL to variant image
                      qty_low_alert:
                        type: integer
                        nullable: true
                        description: Quantity threshold for low stock alerts
                      qty_reorder_threshold:
                        type: integer
                        nullable: true
                        description: Quantity threshold for reordering
                      qty_minimum:
                        type: integer
                        nullable: true
                        description: Minimum quantity to maintain
                      supplier_id:
                        type: integer
                        nullable: true
                        description: ID of the variant's preferred supplier
                      supplier:
                        type: object
                        nullable: true
                        properties:
                          name:
                            type: string
                            description: 'Name of the preferred supplier. If the supplier is not found in Luminous, it will be created.'
                        description: Product preferred supplier information
                      sellable:
                        type: boolean
                        nullable: true
                        description: Whether the variant can be sold
                      discontinued:
                        type: boolean
                        nullable: true
                        description: If an item is discontinued it will be hidden by default in the Luminous UI
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location ID for receiving this variant
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this variant
                      description:
                        type: string
                        nullable: true
                        description: Variant description
                      wholesale_price:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant wholesale price
                      retail_price:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant retail price
                      unit_cost:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Variant cost per unit
                      product_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      dimensional_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      product_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the variant (in inches)
                      product_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the variant (in inches)
                      product_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the variant (in inches)
                      box_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      box_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      carton_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the carton (in inches)
                      shipping_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      shipping_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        nullable: true
                        description: |
                          Product weight. Accepts a single `{unit, value}` object or an array of such
                          segments (a compound weight like 4 lb + 6 oz is written as two entries and summed).

                          **Accepted units.** Imperial units are stored as-is: `lb`/`lbs` (pounds) and
                          `oz`/`ozs` (ounces). Metric units are accepted on input and **converted to ounces
                          at storage** — `g`/`gram`/`grams` and `kg`/`kgs`/`kilogram`/`kilograms`. Because
                          metric is converted, the input unit is not round-tripped: a weight submitted in
                          grams or kilograms reads back in ounces.

                          **Rejected input (`400`).** A bare number with no unit; a comma inside a number
                          (`2,5kg` — ambiguous decimal vs. thousands separator, use `2.5kg`); a negative
                          value; mixing metric and imperial units in one weight (e.g. `1 lb (454 g)`); or
                          repeating a metric unit (e.g. `3kg / 2.8kg`) — these read as the same weight
                          written twice rather than a total.
                        oneOf:
                          - type: object
                            required:
                              - unit
                              - value
                            properties:
                              unit:
                                type: string
                                enum:
                                  - lb
                                  - lbs
                                  - oz
                                  - ozs
                                  - g
                                  - gram
                                  - grams
                                  - kg
                                  - kgs
                                  - kilogram
                                  - kilograms
                                description: |
                                  Weight unit. Imperial (`lb`/`lbs`, `oz`/`ozs`) is stored as-is; metric (`g`/`gram`/`grams`, `kg`/`kgs`/`kilogram`/`kilograms`) is converted to ounces on storage.
                              value:
                                type: number
                                format: float
                                minimum: 0
                                description: Weight value (non-negative)
                          - type: array
                            items:
                              type: object
                              required:
                                - unit
                                - value
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - lb
                                    - lbs
                                    - oz
                                    - ozs
                                    - g
                                    - gram
                                    - grams
                                    - kg
                                    - kgs
                                    - kilogram
                                    - kilograms
                                value:
                                  type: number
                                  format: float
                                  minimum: 0
                            description: |
                              Array of weight entries, summed into one total (e.g. 4 lb + 6 oz as [{"unit":"lb","value":4},{"unit":"oz","value":6}]). Do not restate one weight in two units — metric+imperial or repeated metric entries are rejected.
                      pallet_length:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Height of the pallet (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of units per carton (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      cartons_per_pallet:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of cartons per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      units_per_pallet:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: 'Number of units per pallet (Shipping & Packing). Omit to leave unchanged. Setting `units_per_carton` or `units_per_pallet` also updates the product''s Carton / Pallet unit conversion, as saving in the app does.'
                      lead_time_days:
                        type: integer
                        minimum: 0
                        maximum: 2147483647
                        nullable: true
                        description: Supplier lead time in calendar days (the product's Lead Time). Returned as `lead_time_days` on the product. Omit to leave unchanged.
                      upc:
                        type: string
                        nullable: true
                        description: Variant UPC/Barcode
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for the variant
                        additionalProperties:
                          type: string
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with the variant
                        items:
                          type: string
                      product_variants:
                        type: array
                        minItems: 1
                        description: |
                          The variant option term(s) this child SKU is assigned to (e.g. Size=Large, Color=Red).
                          Use one entry per axis, with the term(s) on `variant_terms`. Any terms used here that
                          aren't yet on the parent's taxonomy are added to it automatically.

                          **Required for every entry in `variants`.** Each child SKU must declare at least one
                          option (axis name + term); a variant with no options is rejected.

                          You may send this under the alias `variant_attributes` instead (matching the GET response shape);
                          both are accepted on write. Returned on the response as the child variant's `variant_attributes`.
                        items:
                          type: object
                          required:
                            - variant_name
                            - variant_terms
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              minItems: 1
                              description: Term value(s) for this axis on this child SKU
                              items:
                                type: string
                boms:
                  type: array
                  nullable: true
                  description: |
                    Array of BOM IDs to attach to the product.
                    Omit this field entirely to leave the product's existing BOM associations unchanged (partial updates do not touch BOMs unless `boms` is provided).
                    When the field **is** provided, it replaces all existing BOM associations: pass an array of IDs to set them, or `null`/an empty array to detach all BOMs.
                  items:
                    type: integer
                    description: BOM ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Forbidden - insufficient field-write permissions (e.g. changing sku without skus.update.sku)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: Conflict - SKU already exists
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteProduct
      tags:
        - Products
      summary: Delete product
      description: Delete a product by ID. An error will be thrown if the item is part of a kit or BOM
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Product ID
      responses:
        '200':
          description: Product successfully deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Product deleted
        '400':
          description: Error deleting product
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/products/{productId}/images/{imageId}':
    delete:
      operationId: deleteProductImage
      tags:
        - Products
      summary: Delete a product image
      description: |
        Remove one image from a product's gallery (the same removal the product page does). The image's
        ID is in `images[].id` on `GET /products/{id}`. When the removed image was the primary photo, the
        next gallery image from Drive becomes the photo; with none, `image_url` is cleared.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Product ID
        - in: path
          name: imageId
          required: true
          schema:
            type: integer
          description: Gallery image ID
      responses:
        '200':
          description: Image removed
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Image deleted
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Product not found, or the image does not belong to this product.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /products/pricing:
    get:
      operationId: getAllProductsPricing
      tags:
        - Products
        - Pricing
      summary: All products pricing
      description: |
        Retrieve comprehensive pricing information for products, including base prices, 
        pricing tiers, price levels, and any company-specific pricing overrides.

        This endpoint returns detailed pricing information that shows volume-based pricing tiers
        across different price levels as configured in each product's pricing schedule.

        This endpoint supports filtering with the same parameters as the products endpoint, 
        allowing you to retrieve pricing data for specific sets of products.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Product name
        - `description`: Product description
        - `sku`: Product SKU (searches both internal SKU and alternate SKUs)
        - `upc`: Product UPC/Barcode
        - `tag`: Product tags
        - `q`: General search matches name OR upc OR sku
        - `category.name`: Filter by category name
        - `sub_category.name`: Filter by sub-category name
        - `supplier.name`: Filter by supplier name

        ### Integer Filters
        - `category.id`: Filter by category ID
        - `sub_category.id`: Filter by sub-category ID
        - `supplier.id`: Filter by supplier ID

        ### Float Filters
        - `retail_price`: Product retail price
        - `wholesale_price`: Product wholesale price

        ### Boolean Filters
        - `sellable`: If the product is sellable or not
        - `discontinued`: If the product is discontinued

        ### DateTime Filters
        - `created_at`: When the product was created
        - `updated_at`: When the product was last updated

        ## Examples
        ```
        # Find products by SKU with pricing details
        ?sku[eq]=SKU-001

        # Find products with specific price range
        ?retail_price[gte]=50.00&retail_price[lte]=100.00

        # Find products by category and sub-category with pricing details
        ?category.name[eq]=Electronics&sub_category.name[eq]=Smartphones
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: q
          schema:
            type: string
          description: Filter by name OR upc OR sku
        - in: query
          name: name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: description
          schema:
            type: string
          description: Filter by product description
        - in: query
          name: sku
          schema:
            type: string
          description: Filter by SKU (searches both internal and alternate SKUs)
        - in: query
          name: upc
          schema:
            type: string
          description: Filter by UPC/Barcode
        - in: query
          name: sellable
          schema:
            type: boolean
          description: Filter by sellable status
        - in: query
          name: discontinued
          schema:
            type: boolean
          description: Filter by whether the product is discontinued
        - in: query
          name: retail_price
          schema:
            type: number
            format: float
          description: Filter by retail price
        - in: query
          name: wholesale_price
          schema:
            type: number
            format: float
          description: Filter by wholesale price
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by product tags
        - in: query
          name: category.id
          schema:
            type: integer
          description: Filter by category ID
        - in: query
          name: category.name
          schema:
            type: string
          description: Filter by category name
        - in: query
          name: sub_category.id
          schema:
            type: integer
          description: Filter by sub-category ID
        - in: query
          name: sub_category.name
          schema:
            type: string
          description: Filter by sub-category name
        - in: query
          name: supplier.id
          schema:
            type: integer
          description: Filter by supplier ID
        - in: query
          name: supplier.name
          schema:
            type: string
          description: Filter by supplier name
      responses:
        '200':
          description: List of products with pricing information
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Product ID
                          example: 1
                        name:
                          type: string
                          description: Product name
                          example: Basic Product
                        sku:
                          type: string
                          description: Product SKU
                          example: BASIC-001
                        is_active:
                          type: boolean
                          description: Whether the product is active
                          example: true
                        wholesale_price:
                          type: number
                          format: float
                          description: The wholesale price of the product
                          example: 100
                        retail_price:
                          type: number
                          format: float
                          description: The retail price of the product
                          example: 150
                        pricing_schedule:
                          type: object
                          description: Pricing schedule configuration for the product
                          properties:
                            id:
                              type: integer
                              description: Pricing schedule ID
                              example: 1
                            name:
                              type: string
                              description: Pricing schedule name
                              example: Standard Volume Discount
                            modification_type:
                              type: string
                              enum:
                                - PERCENTAGE
                                - FIXED
                              description: Type of price modification
                              example: PERCENTAGE
                            price_levels:
                              type: array
                              description: Different price levels available
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Price level ID
                                    example: 1
                                  name:
                                    type: string
                                    description: Price level name
                                    example: Standard
                                  amount:
                                    type: number
                                    format: float
                                    description: Discount amount (percentage or fixed)
                                    example: 0
                                  tiers:
                                    type: array
                                    description: Quantity-based pricing tiers
                                    items:
                                      type: object
                                      properties:
                                        min_quantity:
                                          type: integer
                                          description: Minimum quantity for this tier
                                          example: 0
                                        price:
                                          type: number
                                          format: float
                                          description: Price at this quantity tier
                                          example: 100
                                        is_overridden:
                                          type: boolean
                                          description: Whether this tier price has been manually overridden to a specific value or not
                                          example: false
                        company_pricing:
                          type: array
                          nullable: true
                          description: Company-specific pricing overrides (if applicable)
                          items:
                            type: object
                            properties:
                              company:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Company ID
                                    example: 1
                                  name:
                                    type: string
                                    description: Company name
                                    example: Test Business 1
                              price:
                                type: number
                                format: float
                                description: Company-specific price
                                example: 140
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  '/products/{productId}/pricing':
    get:
      operationId: getSingleProductPricing
      tags:
        - Products
        - Pricing
      summary: Single product pricing
      description: |
        Retrieve comprehensive pricing information for a specific product, including base price, 
        pricing tiers, price levels, and any company-specific pricing overrides.

        This endpoint returns detailed pricing information that shows volume-based pricing tiers
        across different price levels as configured in the product's pricing schedule.
      security:
        - BearerAuth: []
      parameters:
        - name: productId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the product
      responses:
        '200':
          description: Detailed pricing information for the product
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Product ID
                    example: 1
                  name:
                    type: string
                    description: Product name
                    example: Basic Product
                  sku:
                    type: string
                    description: Product SKU
                    example: BASIC-001
                  is_active:
                    type: boolean
                    description: Whether the product is active
                    example: true
                  wholesale_price:
                    type: number
                    format: float
                    description: The wholesale price of the product
                    example: 100
                  retail_price:
                    type: number
                    format: float
                    description: The retail price of the product
                    example: 150
                  pricing_schedule:
                    type: object
                    description: Pricing schedule configuration for the product
                    properties:
                      id:
                        type: integer
                        description: Pricing schedule ID
                        example: 1
                      name:
                        type: string
                        description: Pricing schedule name
                        example: Standard Volume Discount
                      modification_type:
                        type: string
                        enum:
                          - PERCENTAGE
                          - FIXED
                        description: Type of price modification
                        example: PERCENTAGE
                      price_levels:
                        type: array
                        description: Different price levels available
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Price level ID
                              example: 1
                            name:
                              type: string
                              description: Price level name
                              example: Standard
                            amount:
                              type: number
                              format: float
                              description: Discount amount (percentage or fixed)
                              example: 0
                            tiers:
                              type: array
                              description: Quantity-based pricing tiers
                              items:
                                type: object
                                properties:
                                  min_quantity:
                                    type: integer
                                    description: Minimum quantity for this tier
                                    example: 0
                                  price:
                                    type: number
                                    format: float
                                    description: Price at this quantity tier
                                    example: 100
                                  is_overridden:
                                    type: boolean
                                    description: Whether this tier price has been manually overridden to a specific value or not
                                    example: false
                  company_pricing:
                    type: array
                    nullable: true
                    description: Company-specific pricing overrides (if applicable)
                    items:
                      type: object
                      properties:
                        company:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Company ID
                              example: 1
                            name:
                              type: string
                              description: Company name
                              example: Test Business 1
                        price:
                          type: number
                          format: float
                          description: Company-specific price
                          example: 140
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  /products/company-pricing:
    get:
      operationId: getAllProductsWithCompanyPricing
      tags:
        - Products
      summary: All products with company pricing
      description: |
        Retrieve ALL products in the system with pricing calculated for all active companies 
        or filtered by specific company IDs. Unlike company-specific endpoints, this returns 
        comprehensive pricing information for multiple companies in a single request.

        Each product will include a `company_prices` array containing pricing for each company 
        based on their assigned price levels, price groups, and applicable discounts or markups.

        This endpoint supports all the same filtering parameters as the regular products endpoint,
        allowing you to retrieve company pricing data for specific sets of products.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Product name
        - `description`: Product description
        - `sku`: Product SKU (searches both internal SKU and alternate SKUs)
        - `upc`: Product UPC/Barcode
        - `tag`: Product tags
        - `q`: General search matches name OR upc OR sku
        - `category.name`: Filter by category name
        - `sub_category.name`: Filter by sub-category name
        - `supplier.name`: Filter by supplier name

        ### Integer Filters
        - `category.id`: Filter by category ID
        - `sub_category.id`: Filter by sub-category ID
        - `supplier.id`: Filter by supplier ID

        ### Float Filters
        - `retail_price`: Product retail price
        - `wholesale_price`: Product wholesale price

        ### Boolean Filters
        - `sellable`: If the product is sellable or not
        - `discontinued`: If the product is discontinued

        ### DateTime Filters
        - `created_at`: When the product was created
        - `updated_at`: When the product was last updated

        ## Company Filtering
        Use the `company_id` parameter to filter pricing to specific companies:
        - Single company: `?company_id=1`
        - Multiple companies: `?company_id=1,2,3`

        ## Examples
        ```
        # Get all products with pricing for all companies
        /products/company-pricing

        # Get products with pricing for specific companies only
        /products/company-pricing?company_id=1,2

        # Find products by SKU with company pricing
        /products/company-pricing?sku[eq]=SKU-001

        # Find products with specific price range and company pricing
        /products/company-pricing?retail_price[gte]=50.00&retail_price[lte]=100.00

        # Find products by category with company pricing
        /products/company-pricing?category.name[eq]=Electronics
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: company_id
          schema:
            type: string
          description: |
            Filter pricing to specific company IDs. Can be a single ID or comma-separated list.
            If not provided, pricing for all active companies will be included.
          example: '1,2,3'
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: include
          schema:
            type: string
          example: created_via
          description: |
            Comma-separated list of optional fields to include on each product. Pass
            `created_via` to include the product's creation source (omitted from list
            responses by default; always present on single-product responses).
        - in: query
          name: q
          schema:
            type: string
          description: Filter by name OR upc OR sku
        - in: query
          name: name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: description
          schema:
            type: string
          description: Filter by product description
        - in: query
          name: sku
          schema:
            type: string
          description: Filter by SKU (searches both internal and alternate SKUs)
        - in: query
          name: upc
          schema:
            type: string
          description: Filter by UPC/Barcode
        - in: query
          name: sellable
          schema:
            type: boolean
          description: Filter by sellable status
        - in: query
          name: discontinued
          schema:
            type: boolean
          description: Filter by whether the product is discontinued
        - in: query
          name: retail_price
          schema:
            type: number
            format: float
          description: Filter by retail price
        - in: query
          name: wholesale_price
          schema:
            type: number
            format: float
          description: Filter by wholesale price
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by product tags
        - in: query
          name: category.id
          schema:
            type: integer
          description: Filter by category ID
        - in: query
          name: category.name
          schema:
            type: string
          description: Filter by category name
        - in: query
          name: sub_category.id
          schema:
            type: integer
          description: Filter by sub-category ID
        - in: query
          name: sub_category.name
          schema:
            type: string
          description: Filter by sub-category name
        - in: query
          name: supplier.id
          schema:
            type: integer
          description: Filter by supplier ID
        - in: query
          name: supplier.name
          schema:
            type: string
          description: Filter by supplier name
      responses:
        '200':
          description: List of products with company pricing information
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the product
                        name:
                          type: string
                          description: Product name
                        description:
                          type: string
                          nullable: true
                          description: Product description
                        retail_price:
                          type: number
                          format: float
                          description: Retail price
                        wholesale_price:
                          type: number
                          format: float
                          description: Wholesale price
                        unit_cost:
                          type: number
                          format: float
                          description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                        purchase_unit_cost:
                          type: number
                          format: float
                          nullable: true
                          description: |
                            Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                        purchase_currency:
                          type: string
                          nullable: true
                          description: |
                            ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                        landed_cost:
                          type: number
                          format: float
                          nullable: true
                          description: Landed cost per unit
                        estimated_landed_cost:
                          type: number
                          format: float
                          nullable: true
                          description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                        design_link:
                          type: string
                          nullable: true
                          description: Product design URL or link. `null` when unset or empty.
                        manufacturing_fee:
                          type: number
                          format: float
                          nullable: true
                          description: Manufacturing fee per unit
                        company_prices:
                          type: array
                          description: |
                            Array of company-specific pricing for this product. Each object contains pricing 
                            calculated based on the company's price level, price group assignments, and any 
                            applicable discounts or markups based on product category.
                          items:
                            type: object
                            description: Company-specific pricing information
                            properties:
                              company_id:
                                type: integer
                                description: The unique identifier of the company
                                example: 1
                              company_name:
                                type: string
                                description: The name of the company
                                example: Electronics Retailer Pro
                              price:
                                type: number
                                format: float
                                description: |
                                  The calculated price for this company based on their price level, price group assignments,
                                  and any applicable discounts or markups based on product category.
                                example: 91.99
                        product_weight:
                          type: number
                          format: float
                          description: Weight of the product
                        product_length:
                          type: number
                          format: float
                          description: Length of the product (in inches)
                        product_width:
                          type: number
                          format: float
                          description: Width of the product (in inches)
                        product_height:
                          type: number
                          format: float
                          description: Height of the product (in inches)
                        qty_low_alert:
                          type: integer
                          description: Low stock alert threshold
                        qty_reorder_threshold:
                          type: integer
                          description: Reorder threshold quantity
                        qty_minimum:
                          type: integer
                          description: Minimum stock quantity
                        sellable:
                          type: boolean
                          description: Whether the product can be sold
                        discontinued:
                          type: boolean
                          description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                        image_url:
                          type: string
                          nullable: true
                          description: URL to the product's main image
                        category:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                          description: Product category information
                        subcategory:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                          description: Product subcategory information
                        custom_fields:
                          type: object
                          description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties:
                            type: string
                        attachments:
                          type: array
                          description: Product attachments
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the attachment
                              name:
                                type: string
                                description: Filename of the attachment
                              type:
                                type: string
                                description: MIME type of the attachment
                              size:
                                type: integer
                                description: File size in bytes
                              full_url:
                                type: string
                                description: Full resolution URL of the attachment
                              thumb_url:
                                type: string
                                description: Thumbnail URL of the attachment (if applicable)
                            required:
                              - id
                              - name
                              - type
                              - size
                              - full_url
                        variants:
                          type: array
                          description: Product variants with company-specific pricing
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              attachments:
                                type: array
                                description: Variant-specific attachments
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the attachment
                                    name:
                                      type: string
                                      description: Filename of the attachment
                                    type:
                                      type: string
                                      description: MIME type of the attachment
                                    size:
                                      type: integer
                                      description: File size in bytes
                                    full_url:
                                      type: string
                                      description: Full resolution URL of the attachment
                                    thumb_url:
                                      type: string
                                      description: Thumbnail URL of the attachment (if applicable)
                                  required:
                                    - id
                                    - name
                                    - type
                                    - size
                                    - full_url
                              retail_price:
                                type: number
                                format: float
                              wholesale_price:
                                type: number
                                format: float
                              company_prices:
                                type: array
                                description: |
                                  Array of company-specific pricing for this variant. Each object contains pricing 
                                  calculated using the same pricing logic as the main product but applied to the variant.
                                items:
                                  type: object
                                  description: Company-specific pricing information
                                  properties:
                                    company_id:
                                      type: integer
                                      description: The unique identifier of the company
                                      example: 1
                                    company_name:
                                      type: string
                                      description: The name of the company
                                      example: Electronics Retailer Pro
                                    price:
                                      type: number
                                      format: float
                                      description: |
                                        The calculated price for this company based on their price level, price group assignments,
                                        and any applicable discounts or markups based on product category.
                                      example: 91.99
                              custom_fields:
                                type: array
                                items:
                                  type: object
                              variant_attributes:
                                type: object
                                additionalProperties:
                                  type: string
                              sku:
                                type: string
                              upc:
                                type: string
                              sellable:
                                type: boolean
                                description: Whether the variant can be sold
                              discontinued:
                                type: boolean
                                description: Whether the variant is discontinued
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        variant_attributes:
                          type: object
                          nullable: true
                          description: Available variant attributes
                        sku:
                          type: string
                          description: Internal SKU
                        alternate_skus:
                          type: array
                          description: Alternate SKUs
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              sku:
                                type: string
                        upc:
                          type: string
                          description: UPC/Barcode
                        tags:
                          type: array
                          description: Tags associated with the product
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the tag
                              name:
                                type: string
                                description: Name of the tag
                              description:
                                type: string
                                nullable: true
                                description: Description of the tag
                              icon:
                                type: string
                                nullable: true
                                description: Icon identifier or URL for the tag
                              color:
                                type: string
                                nullable: true
                                description: Color code for the tag
                            required:
                              - id
                              - name
                        substitutions:
                          type: array
                          description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Substitution record ID
                              priority:
                                type: integer
                                description: Substitution priority (lower number = higher priority)
                              product:
                                type: object
                                description: The substitute product
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the product
                                  name:
                                    type: string
                                    description: Product name
                                  description:
                                    type: string
                                    nullable: true
                                    description: Product description
                                  retail_price:
                                    type: number
                                    format: float
                                    description: Retail price
                                  wholesale_price:
                                    type: number
                                    format: float
                                    description: Wholesale price
                                  unit_cost:
                                    type: number
                                    format: float
                                    description: Cost per unit
                                  product_weight:
                                    type: number
                                    format: float
                                    description: Weight of the product
                                  product_length:
                                    type: number
                                    format: float
                                    description: Length of the product (in inches)
                                  product_width:
                                    type: number
                                    format: float
                                    description: Width of the product (in inches)
                                  product_height:
                                    type: number
                                    format: float
                                    description: Height of the product (in inches)
                                  sellable:
                                    type: boolean
                                    description: Whether the product can be sold
                                  discontinued:
                                    type: boolean
                                    description: Whether the product is discontinued
                                  image_url:
                                    type: string
                                    nullable: true
                                    description: URL to the product's main image
                                  sku:
                                    type: string
                                    description: Internal SKU
                                  upc:
                                    type: string
                                    description: UPC/Barcode
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was last updated
                        supplier:
                          type: object
                          nullable: true
                          description: Supplier information
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the product was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the product was last updated
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  '/products/{productId}/company-pricing':
    get:
      operationId: getSingleProductWithCompanyPricing
      tags:
        - Products
      summary: Single product with company pricing
      description: |
        Retrieve a single product by ID with pricing calculated for all active companies 
        or filtered by specific company IDs. This provides comprehensive pricing information 
        for the product across multiple companies in a single request.

        The product will include a `company_prices` array containing pricing for each company 
        based on their assigned price levels, price groups, and applicable discounts or markups.

        This endpoint returns complete product information including variants, substitutions, 
        custom fields, and tags, with company pricing calculated for both the main product 
        and any variants.

        ## Pricing Calculation
        The pricing system considers multiple factors for each company:
        - **Price Levels**: Standard, Premium, VIP, Wholesale, etc.
        - **Price Groups**: Customer segments like "Electronics Retailers", "Bulk Distributors"
        - **Category Rules**: Different pricing rules can apply to different product categories
        - **Markups/Discounts**: Percentage increases or decreases based on customer type

        ## Company Filtering
        Use the `company_id` parameter to filter pricing to specific companies:
        - Single company: `?company_id=1`
        - Multiple companies: `?company_id=1,2,3`

        ## Example Response
        The response includes all standard product fields plus the `company_prices` array:
        ```json
        {
          "data": {
            "id": 1,
            "name": "Test Product 1",
            "sku": "SKU-001",
            "retail_price": 99.99,
            "wholesale_price": 79.99,
            "company_prices": [
              {
                "company_id": 1,
                "company_name": "Electronics Retailer Pro",
                "price": 91.99
              },
              {
                "company_id": 2,
                "company_name": "Bulk Distribution Corp", 
                "price": 63.99
              }
            ],
            "variants": [
              {
                "id": 2,
                "name": "Test Product 1 - Large",
                "sku": "SKU-001-L",
                "company_prices": [
                  {
                    "company_id": 1,
                    "company_name": "Electronics Retailer Pro",
                    "price": 101.99
                  }
                ]
              }
            ]
          }
        }
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: The ID of the product to retrieve
        - in: query
          name: company_id
          schema:
            type: string
          description: |
            Filter pricing to specific company IDs. Can be a single ID or comma-separated list.
            If not provided, pricing for all active companies will be included.
          example: '1,2,3'
      responses:
        '200':
          description: Product with company pricing information
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      company_prices:
                        type: array
                        description: |
                          Array of company-specific pricing for this product. Each object contains pricing 
                          calculated based on the company's price level, price group assignments, and any 
                          applicable discounts or markups based on product category.
                        items:
                          type: object
                          description: Company-specific pricing information
                          properties:
                            company_id:
                              type: integer
                              description: The unique identifier of the company
                              example: 1
                            company_name:
                              type: string
                              description: The name of the company
                              example: Electronics Retailer Pro
                            price:
                              type: number
                              format: float
                              description: |
                                The calculated price for this company based on their price level, price group assignments,
                                and any applicable discounts or markups based on product category.
                              example: 91.99
                      product_weight:
                        type: number
                        format: float
                        description: Weight of the product
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      qty_low_alert:
                        type: integer
                        description: Low stock alert threshold
                      qty_reorder_threshold:
                        type: integer
                        description: Reorder threshold quantity
                      qty_minimum:
                        type: integer
                        description: Minimum stock quantity
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants with company-specific pricing
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            company_prices:
                              type: array
                              description: |
                                Array of company-specific pricing for this variant. Each object contains pricing 
                                calculated using the same pricing logic as the main product but applied to the variant.
                              items:
                                type: object
                                description: Company-specific pricing information
                                properties:
                                  company_id:
                                    type: integer
                                    description: The unique identifier of the company
                                    example: 1
                                  company_name:
                                    type: string
                                    description: The name of the company
                                    example: Electronics Retailer Pro
                                  price:
                                    type: number
                                    format: float
                                    description: |
                                      The calculated price for this company based on their price level, price group assignments,
                                      and any applicable discounts or markups based on product category.
                                    example: 91.99
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: object
                              additionalProperties:
                                type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            sellable:
                              type: boolean
                              description: Whether the variant can be sold
                            discontinued:
                              type: boolean
                              description: Whether the variant is discontinued
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: object
                        nullable: true
                        description: Available variant attributes
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: number
                                  format: float
                                  description: Weight of the product
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/products/{productId}/push':
    post:
      operationId: pushProductToIntegration
      tags:
        - Products
      summary: Push a product to an OMS/WMS integration
      description: |
        Pushes a single Luminous product (RFQ) to a destination OMS/WMS integration account — for example
        creating or updating the matching product/variant in a connected TrackStar-backed system.

        Set `debug` to `true` to enable request tracing; the response then includes a `debug` object with the
        outbound HTTP requests made to the third party (the same pattern as the External fulfillment-order push).

        Returns `200` when the push succeeds and `422` when it fails; inspect `data.success` and `data.message`
        for the outcome in both cases.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Luminous product (RFQ) ID to push.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - destination_integration_account_id
              properties:
                destination_integration_account_id:
                  type: integer
                  description: ID of the destination integration account to push the product to.
                update_existing_variants:
                  type: boolean
                  default: true
                  description: |
                    When `true` (the default), variants (child SKUs) that are already linked to the destination
                    integration are re-synced on push, so product-level changes propagate to existing mappings.
                    Set to `false` to only create newly added variants and leave already-mapped variants untouched
                    (the push then reports success without updating existing variants).
                debug:
                  type: boolean
                  default: false
                  description: 'When `true`, enables request tracing and returns a `debug` object in the response.'
      responses:
        '200':
          description: Push completed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                        nullable: true
                      data:
                        type: object
                        nullable: true
                        additionalProperties: true
                        description: 'Push result payload from the integration, when present.'
                      debug:
                        type: object
                        nullable: true
                        additionalProperties: true
                        description: Outbound HTTP request trace; only present when `debug=true`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Push failed (see `data.message`), or validation error'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                        nullable: true
  /product-profiles:
    get:
      operationId: listProductProfiles
      tags:
        - Products
      summary: List product builder profiles
      description: |
        Return all Product Builder Profiles, ordered by name. Profiles are reusable configurations
        that drive a simplified product-create screen and can be referenced from a product create
        (via `profile_id` or `profile_slug`) to enforce SKU format, required variant preset /
        distribution group / custom fields, and to stamp fixed defaults.

        The response is a bare array (not wrapped or paginated).
      security:
        - BearerAuth: []
      responses:
        '200':
          description: List of product profiles
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  description: |
                    A Product Builder Profile — a reusable configuration that drives a simplified product-create
                    screen and, when referenced from a product create, enforces its constraints (SKU format,
                    required variant preset / distribution group / custom fields) and stamps its fixed defaults.
                  properties:
                    id:
                      type: integer
                      description: Unique identifier for the profile
                    name:
                      type: string
                      description: Human-readable profile name (unique among non-deleted profiles)
                    slug:
                      type: string
                      nullable: true
                      description: Optional URL-friendly identifier (unique among non-deleted profiles). Can be used in place of `profile_id` when referencing the profile from a product create via `profile_slug`.
                    is_active:
                      type: boolean
                      description: Whether the profile is active. Inactive profiles are ignored by enforcement.
                    config:
                      type: object
                      nullable: true
                      description: |
                        The heterogeneous builder specification for a Product Builder Profile. Unknown keys are
                        permitted so the schema can grow without a code change; the keys enforcement and the builder
                        screen actually read are documented below.
                      properties:
                        sku_format:
                          type: object
                          nullable: true
                          description: A regular expression the product SKU must match on create.
                          properties:
                            regex:
                              type: string
                              maxLength: 255
                              description: The pattern the SKU must match (validated as a valid regex on save).
                            hint:
                              type: string
                              maxLength: 255
                              description: Human-readable hint shown when a SKU fails the format check.
                        required_variant_template:
                          type: object
                          nullable: true
                          description: Requires a variant preset (variant options template) on create.
                          properties:
                            mode:
                              type: string
                              enum:
                                - must_pick
                                - fixed
                              description: |
                                `must_pick` — the user must choose a variant preset on the screen.
                                `fixed` — the profile pins the preset; it is coerced onto the product and not shown.
                            variant_template_id:
                              type: integer
                              description: The variant preset (template) ID. Required when `mode` is `fixed`.
                        required_distribution_template:
                          type: object
                          nullable: true
                          description: |
                            Requires a pinned distribution curve (grid template) on create. Cannot be combined with
                            `required_distribution_group` — setting both returns `422`.
                          properties:
                            mode:
                              type: string
                              enum:
                                - must_pick
                                - fixed
                              description: Same semantics as `required_variant_template.mode`.
                            grid_template_id:
                              type: integer
                              description: The distribution (grid) template ID. Required when `mode` is `fixed`.
                        required_distribution_group:
                          type: object
                          nullable: true
                          description: |
                            Requires a variant distribution group (size-curve category) on create. `must_pick` makes
                            `grid_template_category_id` required on `POST /products`; `fixed` assigns the group to the
                            product automatically. Cannot be combined with `required_distribution_template` — setting
                            both returns `422`.
                          properties:
                            mode:
                              type: string
                              enum:
                                - must_pick
                                - fixed
                              description: Same semantics as `required_variant_template.mode`.
                            grid_template_category_id:
                              type: integer
                              description: The distribution group (grid template category) ID. Required when `mode` is `fixed`.
                        required_category:
                          type: object
                          nullable: true
                          description: Requires a product category (and optionally a subcategory) on create.
                          properties:
                            mode:
                              type: string
                              enum:
                                - must_pick
                                - fixed
                              description: Same semantics as `required_variant_template.mode`.
                            category_id:
                              type: integer
                              description: The product category ID. Required when `mode` is `fixed`.
                            sub_category_id:
                              type: integer
                              description: The product subcategory ID (must belong to `category_id`).
                        required_custom_field_ids:
                          type: array
                          nullable: true
                          description: |
                            Product custom-field IDs that must be provided. Null or a blank string counts as missing; a supplied `0`
                            counts as answered. Required fields are always shown on the builder screen, even if not listed in
                            `visible_custom_field_ids`.
                          items:
                            type: integer
                        visible_custom_field_ids:
                          type: array
                          nullable: true
                          description: |
                            Product custom-field IDs the builder screen shows without requiring an answer, in display order. Shown
                            fields are the visible IDs followed by any required IDs not already listed. A blank optional field is
                            accepted, but a non-blank answer to a dropdown field (optional or required) must be one of its declared
                            choices.
                          items:
                            type: integer
                        hidden_defaults:
                          type: object
                          nullable: true
                          description: Default field values stamped onto the product that the user never sees. Applied only where the caller left the field unset.
                        fields:
                          type: object
                          nullable: true
                          description: 'Controls which product fields the builder screen shows, hides, orders, relabels, or force-requires.'
                          properties:
                            visible:
                              type: array
                              items:
                                type: string
                            hidden:
                              type: array
                              items:
                                type: string
                            order:
                              type: array
                              items:
                                type: string
                            labels:
                              type: object
                            required_overrides:
                              type: object
                        context:
                          type: object
                          nullable: true
                          description: Free-form context bag for the builder screen.
                      additionalProperties: true
                    created_at:
                      type: string
                      format: date-time
                      nullable: true
                    updated_at:
                      type: string
                      format: date-time
                      nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createProductProfile
      tags:
        - Products
      summary: Create a product builder profile
      description: |
        Create a Product Builder Profile. The heterogeneous builder specification lives under
        `config`; unknown `config` keys are permitted so the schema can grow without a code change.
        `name` must be unique among non-deleted profiles, and `slug` (if provided) likewise.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Profile name (unique among non-deleted profiles)
                slug:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Optional URL-friendly identifier (unique among non-deleted profiles)
                is_active:
                  type: boolean
                  nullable: true
                  description: Whether the profile is active. Defaults to the model default when omitted.
                config:
                  type: object
                  nullable: true
                  description: |
                    The heterogeneous builder specification for a Product Builder Profile. Unknown keys are
                    permitted so the schema can grow without a code change; the keys enforcement and the builder
                    screen actually read are documented below.
                  properties:
                    sku_format:
                      type: object
                      nullable: true
                      description: A regular expression the product SKU must match on create.
                      properties:
                        regex:
                          type: string
                          maxLength: 255
                          description: The pattern the SKU must match (validated as a valid regex on save).
                        hint:
                          type: string
                          maxLength: 255
                          description: Human-readable hint shown when a SKU fails the format check.
                    required_variant_template:
                      type: object
                      nullable: true
                      description: Requires a variant preset (variant options template) on create.
                      properties:
                        mode:
                          type: string
                          enum:
                            - must_pick
                            - fixed
                          description: |
                            `must_pick` — the user must choose a variant preset on the screen.
                            `fixed` — the profile pins the preset; it is coerced onto the product and not shown.
                        variant_template_id:
                          type: integer
                          description: The variant preset (template) ID. Required when `mode` is `fixed`.
                    required_distribution_template:
                      type: object
                      nullable: true
                      description: |
                        Requires a pinned distribution curve (grid template) on create. Cannot be combined with
                        `required_distribution_group` — setting both returns `422`.
                      properties:
                        mode:
                          type: string
                          enum:
                            - must_pick
                            - fixed
                          description: Same semantics as `required_variant_template.mode`.
                        grid_template_id:
                          type: integer
                          description: The distribution (grid) template ID. Required when `mode` is `fixed`.
                    required_distribution_group:
                      type: object
                      nullable: true
                      description: |
                        Requires a variant distribution group (size-curve category) on create. `must_pick` makes
                        `grid_template_category_id` required on `POST /products`; `fixed` assigns the group to the
                        product automatically. Cannot be combined with `required_distribution_template` — setting
                        both returns `422`.
                      properties:
                        mode:
                          type: string
                          enum:
                            - must_pick
                            - fixed
                          description: Same semantics as `required_variant_template.mode`.
                        grid_template_category_id:
                          type: integer
                          description: The distribution group (grid template category) ID. Required when `mode` is `fixed`.
                    required_category:
                      type: object
                      nullable: true
                      description: Requires a product category (and optionally a subcategory) on create.
                      properties:
                        mode:
                          type: string
                          enum:
                            - must_pick
                            - fixed
                          description: Same semantics as `required_variant_template.mode`.
                        category_id:
                          type: integer
                          description: The product category ID. Required when `mode` is `fixed`.
                        sub_category_id:
                          type: integer
                          description: The product subcategory ID (must belong to `category_id`).
                    required_custom_field_ids:
                      type: array
                      nullable: true
                      description: |
                        Product custom-field IDs that must be provided. Null or a blank string counts as missing; a supplied `0`
                        counts as answered. Required fields are always shown on the builder screen, even if not listed in
                        `visible_custom_field_ids`.
                      items:
                        type: integer
                    visible_custom_field_ids:
                      type: array
                      nullable: true
                      description: |
                        Product custom-field IDs the builder screen shows without requiring an answer, in display order. Shown
                        fields are the visible IDs followed by any required IDs not already listed. A blank optional field is
                        accepted, but a non-blank answer to a dropdown field (optional or required) must be one of its declared
                        choices.
                      items:
                        type: integer
                    hidden_defaults:
                      type: object
                      nullable: true
                      description: Default field values stamped onto the product that the user never sees. Applied only where the caller left the field unset.
                    fields:
                      type: object
                      nullable: true
                      description: 'Controls which product fields the builder screen shows, hides, orders, relabels, or force-requires.'
                      properties:
                        visible:
                          type: array
                          items:
                            type: string
                        hidden:
                          type: array
                          items:
                            type: string
                        order:
                          type: array
                          items:
                            type: string
                        labels:
                          type: object
                        required_overrides:
                          type: object
                    context:
                      type: object
                      nullable: true
                      description: Free-form context bag for the builder screen.
                  additionalProperties: true
            example:
              name: Apparel — Simplified
              slug: apparel-simplified
              is_active: true
              config:
                sku_format:
                  regex: '^APP-[A-Z0-9]{4,}$'
                  hint: APP- followed by 4+ letters or digits
                required_variant_template:
                  mode: must_pick
                required_custom_field_ids:
                  - 42
                  - 51
                visible_custom_field_ids:
                  - 63
      responses:
        '201':
          description: Profile created
          content:
            application/json:
              schema:
                type: object
                description: |
                  A Product Builder Profile — a reusable configuration that drives a simplified product-create
                  screen and, when referenced from a product create, enforces its constraints (SKU format,
                  required variant preset / distribution group / custom fields) and stamps its fixed defaults.
                properties:
                  id:
                    type: integer
                    description: Unique identifier for the profile
                  name:
                    type: string
                    description: Human-readable profile name (unique among non-deleted profiles)
                  slug:
                    type: string
                    nullable: true
                    description: Optional URL-friendly identifier (unique among non-deleted profiles). Can be used in place of `profile_id` when referencing the profile from a product create via `profile_slug`.
                  is_active:
                    type: boolean
                    description: Whether the profile is active. Inactive profiles are ignored by enforcement.
                  config:
                    type: object
                    nullable: true
                    description: |
                      The heterogeneous builder specification for a Product Builder Profile. Unknown keys are
                      permitted so the schema can grow without a code change; the keys enforcement and the builder
                      screen actually read are documented below.
                    properties:
                      sku_format:
                        type: object
                        nullable: true
                        description: A regular expression the product SKU must match on create.
                        properties:
                          regex:
                            type: string
                            maxLength: 255
                            description: The pattern the SKU must match (validated as a valid regex on save).
                          hint:
                            type: string
                            maxLength: 255
                            description: Human-readable hint shown when a SKU fails the format check.
                      required_variant_template:
                        type: object
                        nullable: true
                        description: Requires a variant preset (variant options template) on create.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: |
                              `must_pick` — the user must choose a variant preset on the screen.
                              `fixed` — the profile pins the preset; it is coerced onto the product and not shown.
                          variant_template_id:
                            type: integer
                            description: The variant preset (template) ID. Required when `mode` is `fixed`.
                      required_distribution_template:
                        type: object
                        nullable: true
                        description: |
                          Requires a pinned distribution curve (grid template) on create. Cannot be combined with
                          `required_distribution_group` — setting both returns `422`.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          grid_template_id:
                            type: integer
                            description: The distribution (grid) template ID. Required when `mode` is `fixed`.
                      required_distribution_group:
                        type: object
                        nullable: true
                        description: |
                          Requires a variant distribution group (size-curve category) on create. `must_pick` makes
                          `grid_template_category_id` required on `POST /products`; `fixed` assigns the group to the
                          product automatically. Cannot be combined with `required_distribution_template` — setting
                          both returns `422`.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          grid_template_category_id:
                            type: integer
                            description: The distribution group (grid template category) ID. Required when `mode` is `fixed`.
                      required_category:
                        type: object
                        nullable: true
                        description: Requires a product category (and optionally a subcategory) on create.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          category_id:
                            type: integer
                            description: The product category ID. Required when `mode` is `fixed`.
                          sub_category_id:
                            type: integer
                            description: The product subcategory ID (must belong to `category_id`).
                      required_custom_field_ids:
                        type: array
                        nullable: true
                        description: |
                          Product custom-field IDs that must be provided. Null or a blank string counts as missing; a supplied `0`
                          counts as answered. Required fields are always shown on the builder screen, even if not listed in
                          `visible_custom_field_ids`.
                        items:
                          type: integer
                      visible_custom_field_ids:
                        type: array
                        nullable: true
                        description: |
                          Product custom-field IDs the builder screen shows without requiring an answer, in display order. Shown
                          fields are the visible IDs followed by any required IDs not already listed. A blank optional field is
                          accepted, but a non-blank answer to a dropdown field (optional or required) must be one of its declared
                          choices.
                        items:
                          type: integer
                      hidden_defaults:
                        type: object
                        nullable: true
                        description: Default field values stamped onto the product that the user never sees. Applied only where the caller left the field unset.
                      fields:
                        type: object
                        nullable: true
                        description: 'Controls which product fields the builder screen shows, hides, orders, relabels, or force-requires.'
                        properties:
                          visible:
                            type: array
                            items:
                              type: string
                          hidden:
                            type: array
                            items:
                              type: string
                          order:
                            type: array
                            items:
                              type: string
                          labels:
                            type: object
                          required_overrides:
                            type: object
                      context:
                        type: object
                        nullable: true
                        description: Free-form context bag for the builder screen.
                    additionalProperties: true
                  created_at:
                    type: string
                    format: date-time
                    nullable: true
                  updated_at:
                    type: string
                    format: date-time
                    nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (e.g., duplicate name/slug, invalid regex, or unknown template/custom-field ID)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/product-profiles/{productProfileId}/resolved':
    get:
      operationId: getResolvedProductProfile
      tags:
        - Products
      summary: Get a product profile with builder metadata
      description: |
        Return a Product Builder Profile together with the metadata a builder screen needs to render
        in a single round-trip: the available variant presets and distribution groups, the profile's
        required custom-field definitions, and the catalog of product fields an author can
        show/hide/label.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productProfileId
          required: true
          schema:
            type: integer
          description: ID of the product profile to resolve
      responses:
        '200':
          description: The profile plus builder metadata
          content:
            application/json:
              schema:
                type: object
                properties:
                  profile:
                    type: object
                    description: |
                      A Product Builder Profile — a reusable configuration that drives a simplified product-create
                      screen and, when referenced from a product create, enforces its constraints (SKU format,
                      required variant preset / distribution group / custom fields) and stamps its fixed defaults.
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the profile
                      name:
                        type: string
                        description: Human-readable profile name (unique among non-deleted profiles)
                      slug:
                        type: string
                        nullable: true
                        description: Optional URL-friendly identifier (unique among non-deleted profiles). Can be used in place of `profile_id` when referencing the profile from a product create via `profile_slug`.
                      is_active:
                        type: boolean
                        description: Whether the profile is active. Inactive profiles are ignored by enforcement.
                      config:
                        type: object
                        nullable: true
                        description: |
                          The heterogeneous builder specification for a Product Builder Profile. Unknown keys are
                          permitted so the schema can grow without a code change; the keys enforcement and the builder
                          screen actually read are documented below.
                        properties:
                          sku_format:
                            type: object
                            nullable: true
                            description: A regular expression the product SKU must match on create.
                            properties:
                              regex:
                                type: string
                                maxLength: 255
                                description: The pattern the SKU must match (validated as a valid regex on save).
                              hint:
                                type: string
                                maxLength: 255
                                description: Human-readable hint shown when a SKU fails the format check.
                          required_variant_template:
                            type: object
                            nullable: true
                            description: Requires a variant preset (variant options template) on create.
                            properties:
                              mode:
                                type: string
                                enum:
                                  - must_pick
                                  - fixed
                                description: |
                                  `must_pick` — the user must choose a variant preset on the screen.
                                  `fixed` — the profile pins the preset; it is coerced onto the product and not shown.
                              variant_template_id:
                                type: integer
                                description: The variant preset (template) ID. Required when `mode` is `fixed`.
                          required_distribution_template:
                            type: object
                            nullable: true
                            description: |
                              Requires a pinned distribution curve (grid template) on create. Cannot be combined with
                              `required_distribution_group` — setting both returns `422`.
                            properties:
                              mode:
                                type: string
                                enum:
                                  - must_pick
                                  - fixed
                                description: Same semantics as `required_variant_template.mode`.
                              grid_template_id:
                                type: integer
                                description: The distribution (grid) template ID. Required when `mode` is `fixed`.
                          required_distribution_group:
                            type: object
                            nullable: true
                            description: |
                              Requires a variant distribution group (size-curve category) on create. `must_pick` makes
                              `grid_template_category_id` required on `POST /products`; `fixed` assigns the group to the
                              product automatically. Cannot be combined with `required_distribution_template` — setting
                              both returns `422`.
                            properties:
                              mode:
                                type: string
                                enum:
                                  - must_pick
                                  - fixed
                                description: Same semantics as `required_variant_template.mode`.
                              grid_template_category_id:
                                type: integer
                                description: The distribution group (grid template category) ID. Required when `mode` is `fixed`.
                          required_category:
                            type: object
                            nullable: true
                            description: Requires a product category (and optionally a subcategory) on create.
                            properties:
                              mode:
                                type: string
                                enum:
                                  - must_pick
                                  - fixed
                                description: Same semantics as `required_variant_template.mode`.
                              category_id:
                                type: integer
                                description: The product category ID. Required when `mode` is `fixed`.
                              sub_category_id:
                                type: integer
                                description: The product subcategory ID (must belong to `category_id`).
                          required_custom_field_ids:
                            type: array
                            nullable: true
                            description: |
                              Product custom-field IDs that must be provided. Null or a blank string counts as missing; a supplied `0`
                              counts as answered. Required fields are always shown on the builder screen, even if not listed in
                              `visible_custom_field_ids`.
                            items:
                              type: integer
                          visible_custom_field_ids:
                            type: array
                            nullable: true
                            description: |
                              Product custom-field IDs the builder screen shows without requiring an answer, in display order. Shown
                              fields are the visible IDs followed by any required IDs not already listed. A blank optional field is
                              accepted, but a non-blank answer to a dropdown field (optional or required) must be one of its declared
                              choices.
                            items:
                              type: integer
                          hidden_defaults:
                            type: object
                            nullable: true
                            description: Default field values stamped onto the product that the user never sees. Applied only where the caller left the field unset.
                          fields:
                            type: object
                            nullable: true
                            description: 'Controls which product fields the builder screen shows, hides, orders, relabels, or force-requires.'
                            properties:
                              visible:
                                type: array
                                items:
                                  type: string
                              hidden:
                                type: array
                                items:
                                  type: string
                              order:
                                type: array
                                items:
                                  type: string
                              labels:
                                type: object
                              required_overrides:
                                type: object
                          context:
                            type: object
                            nullable: true
                            description: Free-form context bag for the builder screen.
                        additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                  metadata:
                    type: object
                    description: Everything the builder screen needs to populate its pickers.
                    properties:
                      variant_templates:
                        type: array
                        description: Available variant presets (variant options templates) to choose from.
                        items:
                          type: object
                          additionalProperties: true
                      distribution_templates:
                        type: array
                        description: Available distribution groups (grid templates) to choose from.
                        items:
                          type: object
                          additionalProperties: true
                      custom_fields:
                        type: array
                        description: |
                          The custom-field definitions this profile shows: the profile's `visible_custom_field_ids` in order,
                          then any `required_custom_field_ids` not already listed. Each entry's `required` flag says whether
                          an answer is mandatory.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            label:
                              type: string
                            type:
                              type: string
                            options:
                              nullable: true
                              description: Field-type-specific options (e.g. choices for a select).
                            category:
                              type: string
                              nullable: true
                            required:
                              type: boolean
                              description: Whether the field is in the profile's `required_custom_field_ids` (true) or only shown (false).
                      field_catalog:
                        type: array
                        description: |
                          The canonical catalog of product fields an author can show/hide/label/require/default
                          on the builder screen, grouped and typed. Each entry maps to a create-payload key.
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                              description: 'The create-payload field key (e.g. `name`, `category_id`, `wholesale_price`).'
                            label:
                              type: string
                            group:
                              type: string
                              description: 'Display group (e.g. `Identity`, `Classification`, `Pricing`).'
                            type:
                              type: string
                              description: |
                                Render/validation type: one of `string`, `text`, `number`, `money`, `integer`, `boolean`, `select`, `multiselect`, `weight`, `dimension`.
                            required_capable:
                              type: boolean
                              description: Whether an author can mark this field must-pick / required.
                            default_capable:
                              type: boolean
                              description: Whether an author can pin a hidden default value for this field.
                            options_key:
                              type: string
                              nullable: true
                              description: 'For `select`/`multiselect` fields, the `options` key that populates its choices.'
                            parent:
                              type: string
                              nullable: true
                              description: 'For dependent selects, the field whose value filters this field''s options.'
                      options:
                        type: object
                        description: |
                          Option lists (and dependent lookups) that populate the `select`/`multiselect`
                          fields in `field_catalog`. Simple lists are arrays of `{value, label}`; dependent
                          lookups (`subcategories`, `units`) are keyed by their parent's id so the screen can
                          filter without another round-trip.
                        additionalProperties: true
                        properties:
                          product_types:
                            type: array
                            items:
                              type: object
                              additionalProperties: true
                          categories:
                            type: array
                            items:
                              type: object
                              additionalProperties: true
                          subcategories:
                            type: object
                            description: 'Subcategory `{value, label}` lists keyed by parent category id.'
                            additionalProperties: true
                          unit_classes:
                            type: array
                            items:
                              type: object
                              additionalProperties: true
                          units:
                            type: object
                            description: 'Unit `{value, label}` lists keyed by parent unit-class id.'
                            additionalProperties: true
                          suppliers:
                            type: array
                            description: Supplier options. Each carries the supplier's default currency so a cost can be entered in it (see `unit_cost_currency` on product create).
                            items:
                              type: object
                              additionalProperties: true
                              properties:
                                value:
                                  type: integer
                                  description: Supplier id.
                                label:
                                  type: string
                                  description: Supplier name.
                                currency:
                                  type: string
                                  nullable: true
                                  description: 'Supplier default currency code, or `null` if none is set.'
                          supply_methods:
                            type: array
                            items:
                              type: object
                              additionalProperties: true
                          priority_lists:
                            type: array
                            items:
                              type: object
                              additionalProperties: true
                          boms:
                            type: array
                            items:
                              type: object
                              additionalProperties: true
                          variant_templates:
                            type: array
                            items:
                              type: object
                              additionalProperties: true
                          distribution_templates:
                            type: array
                            items:
                              type: object
                              additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product profile not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/product-profiles/{productProfileId}':
    get:
      operationId: getProductProfile
      tags:
        - Products
      summary: Get a product builder profile
      description: Return a single Product Builder Profile by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productProfileId
          required: true
          schema:
            type: integer
          description: ID of the product profile
      responses:
        '200':
          description: The product profile
          content:
            application/json:
              schema:
                type: object
                description: |
                  A Product Builder Profile — a reusable configuration that drives a simplified product-create
                  screen and, when referenced from a product create, enforces its constraints (SKU format,
                  required variant preset / distribution group / custom fields) and stamps its fixed defaults.
                properties:
                  id:
                    type: integer
                    description: Unique identifier for the profile
                  name:
                    type: string
                    description: Human-readable profile name (unique among non-deleted profiles)
                  slug:
                    type: string
                    nullable: true
                    description: Optional URL-friendly identifier (unique among non-deleted profiles). Can be used in place of `profile_id` when referencing the profile from a product create via `profile_slug`.
                  is_active:
                    type: boolean
                    description: Whether the profile is active. Inactive profiles are ignored by enforcement.
                  config:
                    type: object
                    nullable: true
                    description: |
                      The heterogeneous builder specification for a Product Builder Profile. Unknown keys are
                      permitted so the schema can grow without a code change; the keys enforcement and the builder
                      screen actually read are documented below.
                    properties:
                      sku_format:
                        type: object
                        nullable: true
                        description: A regular expression the product SKU must match on create.
                        properties:
                          regex:
                            type: string
                            maxLength: 255
                            description: The pattern the SKU must match (validated as a valid regex on save).
                          hint:
                            type: string
                            maxLength: 255
                            description: Human-readable hint shown when a SKU fails the format check.
                      required_variant_template:
                        type: object
                        nullable: true
                        description: Requires a variant preset (variant options template) on create.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: |
                              `must_pick` — the user must choose a variant preset on the screen.
                              `fixed` — the profile pins the preset; it is coerced onto the product and not shown.
                          variant_template_id:
                            type: integer
                            description: The variant preset (template) ID. Required when `mode` is `fixed`.
                      required_distribution_template:
                        type: object
                        nullable: true
                        description: |
                          Requires a pinned distribution curve (grid template) on create. Cannot be combined with
                          `required_distribution_group` — setting both returns `422`.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          grid_template_id:
                            type: integer
                            description: The distribution (grid) template ID. Required when `mode` is `fixed`.
                      required_distribution_group:
                        type: object
                        nullable: true
                        description: |
                          Requires a variant distribution group (size-curve category) on create. `must_pick` makes
                          `grid_template_category_id` required on `POST /products`; `fixed` assigns the group to the
                          product automatically. Cannot be combined with `required_distribution_template` — setting
                          both returns `422`.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          grid_template_category_id:
                            type: integer
                            description: The distribution group (grid template category) ID. Required when `mode` is `fixed`.
                      required_category:
                        type: object
                        nullable: true
                        description: Requires a product category (and optionally a subcategory) on create.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          category_id:
                            type: integer
                            description: The product category ID. Required when `mode` is `fixed`.
                          sub_category_id:
                            type: integer
                            description: The product subcategory ID (must belong to `category_id`).
                      required_custom_field_ids:
                        type: array
                        nullable: true
                        description: |
                          Product custom-field IDs that must be provided. Null or a blank string counts as missing; a supplied `0`
                          counts as answered. Required fields are always shown on the builder screen, even if not listed in
                          `visible_custom_field_ids`.
                        items:
                          type: integer
                      visible_custom_field_ids:
                        type: array
                        nullable: true
                        description: |
                          Product custom-field IDs the builder screen shows without requiring an answer, in display order. Shown
                          fields are the visible IDs followed by any required IDs not already listed. A blank optional field is
                          accepted, but a non-blank answer to a dropdown field (optional or required) must be one of its declared
                          choices.
                        items:
                          type: integer
                      hidden_defaults:
                        type: object
                        nullable: true
                        description: Default field values stamped onto the product that the user never sees. Applied only where the caller left the field unset.
                      fields:
                        type: object
                        nullable: true
                        description: 'Controls which product fields the builder screen shows, hides, orders, relabels, or force-requires.'
                        properties:
                          visible:
                            type: array
                            items:
                              type: string
                          hidden:
                            type: array
                            items:
                              type: string
                          order:
                            type: array
                            items:
                              type: string
                          labels:
                            type: object
                          required_overrides:
                            type: object
                      context:
                        type: object
                        nullable: true
                        description: Free-form context bag for the builder screen.
                    additionalProperties: true
                  created_at:
                    type: string
                    format: date-time
                    nullable: true
                  updated_at:
                    type: string
                    format: date-time
                    nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product profile not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateProductProfile
      tags:
        - Products
      summary: Update a product builder profile
      description: |
        Full update of a Product Builder Profile. Same body shape as create; the name/slug
        uniqueness checks ignore the profile being edited. Only `name`, `slug`, `config`, and
        `is_active` are persisted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productProfileId
          required: true
          schema:
            type: integer
          description: ID of the product profile to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: 'Profile name (unique among non-deleted profiles, ignoring this profile)'
                slug:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: 'Optional URL-friendly identifier (unique among non-deleted profiles, ignoring this profile)'
                is_active:
                  type: boolean
                  nullable: true
                  description: Whether the profile is active
                config:
                  type: object
                  nullable: true
                  description: |
                    The heterogeneous builder specification for a Product Builder Profile. Unknown keys are
                    permitted so the schema can grow without a code change; the keys enforcement and the builder
                    screen actually read are documented below.
                  properties:
                    sku_format:
                      type: object
                      nullable: true
                      description: A regular expression the product SKU must match on create.
                      properties:
                        regex:
                          type: string
                          maxLength: 255
                          description: The pattern the SKU must match (validated as a valid regex on save).
                        hint:
                          type: string
                          maxLength: 255
                          description: Human-readable hint shown when a SKU fails the format check.
                    required_variant_template:
                      type: object
                      nullable: true
                      description: Requires a variant preset (variant options template) on create.
                      properties:
                        mode:
                          type: string
                          enum:
                            - must_pick
                            - fixed
                          description: |
                            `must_pick` — the user must choose a variant preset on the screen.
                            `fixed` — the profile pins the preset; it is coerced onto the product and not shown.
                        variant_template_id:
                          type: integer
                          description: The variant preset (template) ID. Required when `mode` is `fixed`.
                    required_distribution_template:
                      type: object
                      nullable: true
                      description: |
                        Requires a pinned distribution curve (grid template) on create. Cannot be combined with
                        `required_distribution_group` — setting both returns `422`.
                      properties:
                        mode:
                          type: string
                          enum:
                            - must_pick
                            - fixed
                          description: Same semantics as `required_variant_template.mode`.
                        grid_template_id:
                          type: integer
                          description: The distribution (grid) template ID. Required when `mode` is `fixed`.
                    required_distribution_group:
                      type: object
                      nullable: true
                      description: |
                        Requires a variant distribution group (size-curve category) on create. `must_pick` makes
                        `grid_template_category_id` required on `POST /products`; `fixed` assigns the group to the
                        product automatically. Cannot be combined with `required_distribution_template` — setting
                        both returns `422`.
                      properties:
                        mode:
                          type: string
                          enum:
                            - must_pick
                            - fixed
                          description: Same semantics as `required_variant_template.mode`.
                        grid_template_category_id:
                          type: integer
                          description: The distribution group (grid template category) ID. Required when `mode` is `fixed`.
                    required_category:
                      type: object
                      nullable: true
                      description: Requires a product category (and optionally a subcategory) on create.
                      properties:
                        mode:
                          type: string
                          enum:
                            - must_pick
                            - fixed
                          description: Same semantics as `required_variant_template.mode`.
                        category_id:
                          type: integer
                          description: The product category ID. Required when `mode` is `fixed`.
                        sub_category_id:
                          type: integer
                          description: The product subcategory ID (must belong to `category_id`).
                    required_custom_field_ids:
                      type: array
                      nullable: true
                      description: |
                        Product custom-field IDs that must be provided. Null or a blank string counts as missing; a supplied `0`
                        counts as answered. Required fields are always shown on the builder screen, even if not listed in
                        `visible_custom_field_ids`.
                      items:
                        type: integer
                    visible_custom_field_ids:
                      type: array
                      nullable: true
                      description: |
                        Product custom-field IDs the builder screen shows without requiring an answer, in display order. Shown
                        fields are the visible IDs followed by any required IDs not already listed. A blank optional field is
                        accepted, but a non-blank answer to a dropdown field (optional or required) must be one of its declared
                        choices.
                      items:
                        type: integer
                    hidden_defaults:
                      type: object
                      nullable: true
                      description: Default field values stamped onto the product that the user never sees. Applied only where the caller left the field unset.
                    fields:
                      type: object
                      nullable: true
                      description: 'Controls which product fields the builder screen shows, hides, orders, relabels, or force-requires.'
                      properties:
                        visible:
                          type: array
                          items:
                            type: string
                        hidden:
                          type: array
                          items:
                            type: string
                        order:
                          type: array
                          items:
                            type: string
                        labels:
                          type: object
                        required_overrides:
                          type: object
                    context:
                      type: object
                      nullable: true
                      description: Free-form context bag for the builder screen.
                  additionalProperties: true
      responses:
        '200':
          description: The updated product profile
          content:
            application/json:
              schema:
                type: object
                description: |
                  A Product Builder Profile — a reusable configuration that drives a simplified product-create
                  screen and, when referenced from a product create, enforces its constraints (SKU format,
                  required variant preset / distribution group / custom fields) and stamps its fixed defaults.
                properties:
                  id:
                    type: integer
                    description: Unique identifier for the profile
                  name:
                    type: string
                    description: Human-readable profile name (unique among non-deleted profiles)
                  slug:
                    type: string
                    nullable: true
                    description: Optional URL-friendly identifier (unique among non-deleted profiles). Can be used in place of `profile_id` when referencing the profile from a product create via `profile_slug`.
                  is_active:
                    type: boolean
                    description: Whether the profile is active. Inactive profiles are ignored by enforcement.
                  config:
                    type: object
                    nullable: true
                    description: |
                      The heterogeneous builder specification for a Product Builder Profile. Unknown keys are
                      permitted so the schema can grow without a code change; the keys enforcement and the builder
                      screen actually read are documented below.
                    properties:
                      sku_format:
                        type: object
                        nullable: true
                        description: A regular expression the product SKU must match on create.
                        properties:
                          regex:
                            type: string
                            maxLength: 255
                            description: The pattern the SKU must match (validated as a valid regex on save).
                          hint:
                            type: string
                            maxLength: 255
                            description: Human-readable hint shown when a SKU fails the format check.
                      required_variant_template:
                        type: object
                        nullable: true
                        description: Requires a variant preset (variant options template) on create.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: |
                              `must_pick` — the user must choose a variant preset on the screen.
                              `fixed` — the profile pins the preset; it is coerced onto the product and not shown.
                          variant_template_id:
                            type: integer
                            description: The variant preset (template) ID. Required when `mode` is `fixed`.
                      required_distribution_template:
                        type: object
                        nullable: true
                        description: |
                          Requires a pinned distribution curve (grid template) on create. Cannot be combined with
                          `required_distribution_group` — setting both returns `422`.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          grid_template_id:
                            type: integer
                            description: The distribution (grid) template ID. Required when `mode` is `fixed`.
                      required_distribution_group:
                        type: object
                        nullable: true
                        description: |
                          Requires a variant distribution group (size-curve category) on create. `must_pick` makes
                          `grid_template_category_id` required on `POST /products`; `fixed` assigns the group to the
                          product automatically. Cannot be combined with `required_distribution_template` — setting
                          both returns `422`.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          grid_template_category_id:
                            type: integer
                            description: The distribution group (grid template category) ID. Required when `mode` is `fixed`.
                      required_category:
                        type: object
                        nullable: true
                        description: Requires a product category (and optionally a subcategory) on create.
                        properties:
                          mode:
                            type: string
                            enum:
                              - must_pick
                              - fixed
                            description: Same semantics as `required_variant_template.mode`.
                          category_id:
                            type: integer
                            description: The product category ID. Required when `mode` is `fixed`.
                          sub_category_id:
                            type: integer
                            description: The product subcategory ID (must belong to `category_id`).
                      required_custom_field_ids:
                        type: array
                        nullable: true
                        description: |
                          Product custom-field IDs that must be provided. Null or a blank string counts as missing; a supplied `0`
                          counts as answered. Required fields are always shown on the builder screen, even if not listed in
                          `visible_custom_field_ids`.
                        items:
                          type: integer
                      visible_custom_field_ids:
                        type: array
                        nullable: true
                        description: |
                          Product custom-field IDs the builder screen shows without requiring an answer, in display order. Shown
                          fields are the visible IDs followed by any required IDs not already listed. A blank optional field is
                          accepted, but a non-blank answer to a dropdown field (optional or required) must be one of its declared
                          choices.
                        items:
                          type: integer
                      hidden_defaults:
                        type: object
                        nullable: true
                        description: Default field values stamped onto the product that the user never sees. Applied only where the caller left the field unset.
                      fields:
                        type: object
                        nullable: true
                        description: 'Controls which product fields the builder screen shows, hides, orders, relabels, or force-requires.'
                        properties:
                          visible:
                            type: array
                            items:
                              type: string
                          hidden:
                            type: array
                            items:
                              type: string
                          order:
                            type: array
                            items:
                              type: string
                          labels:
                            type: object
                          required_overrides:
                            type: object
                      context:
                        type: object
                        nullable: true
                        description: Free-form context bag for the builder screen.
                    additionalProperties: true
                  created_at:
                    type: string
                    format: date-time
                    nullable: true
                  updated_at:
                    type: string
                    format: date-time
                    nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product profile not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (e.g., duplicate name/slug, invalid regex, or unknown template/custom-field ID)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteProductProfile
      tags:
        - Products
      summary: Delete a product builder profile
      description: Soft-delete a Product Builder Profile by ID. Returns 204 No Content on success.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productProfileId
          required: true
          schema:
            type: integer
          description: ID of the product profile to delete
      responses:
        '204':
          description: Profile deleted (no content)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product profile not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /b2b-product-templates:
    get:
      operationId: listB2bProductTemplates
      tags:
        - Products
      summary: List B2B product templates
      description: |
        Return every B2B Product Template (the SKU lists wholesale customers see on the B2B Portal),
        ordered by name, with how many SKUs and kits each one holds.

        The response is not paginated.
      security:
        - BearerAuth: []
      parameters:
        - name: name
          in: query
          required: false
          description: Case-insensitive partial match on the template name.
          schema:
            type: string
      responses:
        '200':
          description: 'Every matching template, ordered by name'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 12
                        name:
                          type: string
                          example: Private Label — West
                        description:
                          type: string
                          nullable: true
                        sku_count:
                          type: integer
                          description: Number of SKUs on the template
                          example: 48
                        kit_count:
                          type: integer
                          description: Number of kits on the template
                          example: 3
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createB2bProductTemplate
      tags:
        - Products
      summary: Create B2B product template
      description: |
        Create a B2B Product Template and, optionally, attach its initial SKUs in the same call.

        SKUs can be given by product ID (`product_ids`), by SKU code (`skus`), or both. Only active,
        non-discontinued standalone or master SKUs can be added — variants, kits, and discontinued
        products are rejected with a 422 listing the offending IDs, and an unknown SKU code returns a
        422. The template and its SKUs are saved together: if any SKU is rejected, nothing is created.

        Requires the permission to update B2B Product Templates.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 255
                  example: Private Label — West
                description:
                  type: string
                  nullable: true
                product_ids:
                  type: array
                  nullable: true
                  description: Product IDs to add to the new template.
                  items:
                    type: integer
                  example:
                    - 1042
                    - 1043
                skus:
                  type: array
                  nullable: true
                  description: SKU codes to add to the new template.
                  items:
                    type: string
                  example:
                    - TEE-BLK
      responses:
        '201':
          description: Template created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        example: Private Label — West
                      description:
                        type: string
                        nullable: true
                      sku_count:
                        type: integer
                        description: Number of SKUs on the template
                        example: 48
                      kit_count:
                        type: integer
                        description: Number of kits on the template
                        example: 3
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '422':
          description: 'Validation error (missing name, unknown SKU, or a product that cannot be added to a template)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /b2b-product-templates/bulk-items:
    post:
      operationId: bulkUpdateB2bProductTemplateItems
      tags:
        - Products
      summary: Add or remove SKUs across B2B product templates
      description: |
        Add or remove SKUs on many B2B Product Templates in one call.

        **Choosing templates:** send explicit `template_ids`, or `all_templates: true`.
        `exclude_template_ids` always wins, so "every template except the private-label ones" is
        `all_templates: true` plus the private-label IDs from `GET /b2b-product-templates`.

        **Choosing SKUs:** send product IDs in `sku_ids`, internal SKU strings in `skus`, or both.
        Deleted SKUs count as unknown. On `add`, SKUs the template editor would not offer
        (not a SKU product type, a variant child, or discontinued) are left out and listed in
        `skipped_sku_ids`.

        **Safe to retry:** an add skips SKUs a template already holds (`already_present`), and a
        remove skips SKUs it does not hold. An unknown template ID or SKU rejects the whole call
        with 400 before anything is written.

        Requires the `clientSkuTemplates.update` permission on the token's user; without it the
        request returns 403 and nothing changes.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - action
              properties:
                action:
                  type: string
                  enum:
                    - add
                    - remove
                  description: Whether to add or remove the SKUs (case-insensitive)
                template_ids:
                  type: array
                  maxItems: 1000
                  items:
                    type: integer
                  description: 'Template IDs to change (distinct, must exist). Required unless `all_templates` is true.'
                exclude_template_ids:
                  type: array
                  items:
                    type: integer
                  description: Template IDs to leave untouched. Always wins over `template_ids` and `all_templates`.
                all_templates:
                  type: boolean
                  default: false
                  description: Apply to every template (minus `exclude_template_ids`)
                sku_ids:
                  type: array
                  maxItems: 1000
                  items:
                    type: integer
                  description: 'Product IDs (distinct, must exist and not be deleted). At least one of `sku_ids` or `skus` is required.'
                skus:
                  type: array
                  maxItems: 1000
                  items:
                    type: string
                  description: 'Internal SKU strings (distinct, must exist and not be deleted). At least one of `sku_ids` or `skus` is required.'
            example:
              action: add
              all_templates: true
              exclude_template_ids:
                - 12
                - 15
              skus:
                - COLD-BREW-32OZ
      responses:
        '200':
          description: One result per template that was considered
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      action:
                        type: string
                        enum:
                          - add
                          - remove
                      sku_count:
                        type: integer
                        description: 'SKUs the call acted on, after skipped ones are left out'
                      skipped_sku_ids:
                        type: array
                        items:
                          type: integer
                        description: 'On add, SKU IDs left out because the template editor would not offer them (not a SKU product type, a variant child, or discontinued). Always empty on remove.'
                      templates_changed:
                        type: integer
                      templates_unchanged:
                        type: integer
                      results:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Template ID
                            name:
                              type: string
                            added:
                              type: integer
                            already_present:
                              type: integer
                            removed:
                              type: integer
                            changed:
                              type: boolean
        '400':
          description: 'Validation failed (unknown template ID or SKU, no SKUs, no templates chosen). Nothing was changed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's user lacks the `clientSkuTemplates.update` permission. Nothing was changed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/b2b-product-templates/{templateId}':
    post:
      operationId: updateB2bProductTemplate
      tags:
        - Products
      summary: Update B2B product template
      description: |
        Rename a B2B Product Template, change its description, or add SKUs to it. Send at least one
        of `name`, `description`, `product_ids`, or `skus`; an empty body returns a 422.

        SKUs already on the template stay in place — `product_ids` and `skus` only add (SKUs already
        on the template are skipped). To remove SKUs, use `POST /b2b-product-templates/bulk-items`.
        The same eligibility rules as create apply: only active, non-discontinued standalone or master
        SKUs can be added, and any rejected SKU fails the whole request.

        Requires the permission to update B2B Product Templates.
      security:
        - BearerAuth: []
      parameters:
        - name: templateId
          in: path
          required: true
          description: ID of the template
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: New template name. Cannot be blank when sent.
                description:
                  type: string
                  nullable: true
                  description: New description. Pass `null` to clear.
                product_ids:
                  type: array
                  nullable: true
                  description: Product IDs to add to the template.
                  items:
                    type: integer
                skus:
                  type: array
                  nullable: true
                  description: SKU codes to add to the template.
                  items:
                    type: string
      responses:
        '200':
          description: The updated template
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        example: Private Label — West
                      description:
                        type: string
                        nullable: true
                      sku_count:
                        type: integer
                        description: Number of SKUs on the template
                        example: 48
                      kit_count:
                        type: integer
                        description: Number of kits on the template
                        example: 3
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: Template not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (empty body, unknown SKU, or a product that cannot be added to a template)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/b2b-product-templates/{templateId}/items':
    get:
      operationId: getB2bProductTemplateItems
      tags:
        - Products
      summary: Get the SKUs and kits on a B2B product template
      description: Return the SKUs and kits one B2B Product Template holds.
      security:
        - BearerAuth: []
      parameters:
        - name: templateId
          in: path
          required: true
          description: B2B Product Template ID (up to 18 digits; longer ids return 404)
          schema:
            type: integer
      responses:
        '200':
          description: The template's SKUs and kits
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        example: Private Label — West
                      skus:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Product (SKU) ID
                            internal_sku:
                              type: string
                              example: COLD-BREW-32OZ
                      kits:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Kit ID
                            sku:
                              type: string
                            title:
                              type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: No template with that ID
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /carton-templates:
    get:
      operationId: listCartonTemplates
      tags:
        - Carton Templates
      summary: List carton templates
      description: |
        Return the carton catalog — the boxes, envelopes, and packer-custom containers the
        cartonization engine chooses from when packing a shipment. Results are ordered by
        `priority` (descending) then `name`.

        The response is wrapped in `data` and is not paginated.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: active_only
          schema:
            type: boolean
          description: 'When `true`, return only active cartons (`is_active = true`).'
        - in: query
          name: search
          schema:
            type: string
          description: Filter to cartons whose `name` contains this value (LIKE).
      responses:
        '200':
          description: A list of carton templates.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A carton template — a shipping box, envelope, or packer-custom container in the carton
                        catalog that the cartonization engine can choose from when packing a shipment. Dimensions
                        are stored in inches and weights in ounces.
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the carton template.
                        name:
                          type: string
                          description: Carton name (unique among non-deleted templates).
                        type:
                          type: string
                          enum:
                            - box
                            - envelope
                            - custom
                          description: Container type. Defaults to `box`.
                        inner_length_in:
                          type: number
                          format: float
                          nullable: true
                          description: 'Usable interior length, in inches.'
                        inner_width_in:
                          type: number
                          format: float
                          nullable: true
                          description: 'Usable interior width, in inches.'
                        inner_height_in:
                          type: number
                          format: float
                          nullable: true
                          description: 'Usable interior height, in inches.'
                        tare_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: 'The empty carton''s own weight, in ounces.'
                        max_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: 'Maximum content weight the carton can hold, in ounces.'
                        cost:
                          type: number
                          format: float
                          nullable: true
                          description: Cost of the carton itself.
                        fill_limit_pct:
                          type: integer
                          nullable: true
                          description: Maximum fill (1–100) of the carton's volume the engine will pack. Defaults to `100`.
                        allowed_packing_classes:
                          type: array
                          nullable: true
                          items:
                            type: string
                          description: List of packing-class values this carton accepts. `null` means any class is allowed.
                        requires_dry_ice:
                          type: boolean
                          description: Whether shipments packed in this carton require dry ice.
                        dry_ice_weight_oz:
                          type: number
                          format: float
                          nullable: true
                          description: 'Weight of dry ice to add, in ounces.'
                        default_package_code:
                          type: string
                          nullable: true
                          description: Carrier package-type code used when buying a label for this carton.
                        priority:
                          type: integer
                          description: Selection priority. Higher-priority cartons are preferred by the engine. Defaults to `0`.
                        is_active:
                          type: boolean
                          description: Whether the carton is active and available for cartonization. Defaults to `true`.
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createCartonTemplate
      tags:
        - Carton Templates
      summary: Create a carton template
      description: |
        Add a carton to the catalog. Only `name` is required; every other field falls back to its
        default (`type` = `box`, `fill_limit_pct` = `100`, `priority` = `0`, `is_active` = `true`,
        `requires_dry_ice` = `false`). `name` must be unique among non-deleted cartons.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  description: |
                    Create/update payload for a carton template. On create, only `name` is required; all other
                    fields fall back to their column defaults. On update every field is optional — send only the
                    fields you intend to change.
                  properties:
                    name:
                      type: string
                      maxLength: 255
                      description: Carton name (unique among non-deleted templates). Required on create.
                    type:
                      type: string
                      enum:
                        - box
                        - envelope
                        - custom
                      description: Container type. Defaults to `box`.
                    inner_length_in:
                      type: number
                      format: float
                      nullable: true
                      minimum: 0
                      description: 'Usable interior length, in inches.'
                    inner_width_in:
                      type: number
                      format: float
                      nullable: true
                      minimum: 0
                      description: 'Usable interior width, in inches.'
                    inner_height_in:
                      type: number
                      format: float
                      nullable: true
                      minimum: 0
                      description: 'Usable interior height, in inches.'
                    tare_weight_oz:
                      type: number
                      format: float
                      nullable: true
                      minimum: 0
                      description: 'The empty carton''s own weight, in ounces.'
                    max_weight_oz:
                      type: number
                      format: float
                      nullable: true
                      minimum: 0
                      description: 'Maximum content weight the carton can hold, in ounces.'
                    cost:
                      type: number
                      format: float
                      nullable: true
                      minimum: 0
                      description: Cost of the carton itself.
                    fill_limit_pct:
                      type: integer
                      nullable: true
                      minimum: 1
                      maximum: 100
                      description: Maximum fill (1–100) of the carton's volume the engine will pack. Defaults to `100`.
                    allowed_packing_classes:
                      type: array
                      nullable: true
                      items:
                        type: string
                      description: List of packing-class values this carton accepts. `null` (or omitted) means any class.
                    requires_dry_ice:
                      type: boolean
                      description: Whether shipments packed in this carton require dry ice. Defaults to `false`.
                    dry_ice_weight_oz:
                      type: number
                      format: float
                      nullable: true
                      minimum: 0
                      description: 'Weight of dry ice to add, in ounces.'
                    default_package_code:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Carrier package-type code used when buying a label for this carton.
                    priority:
                      type: integer
                      description: Selection priority. Higher-priority cartons are preferred by the engine. Defaults to `0`.
                    is_active:
                      type: boolean
                      description: Whether the carton is active and available for cartonization. Defaults to `true`.
                - required:
                    - name
            example:
              name: Small Mailer Box
              type: box
              inner_length_in: 8
              inner_width_in: 6
              inner_height_in: 4
              tare_weight_oz: 3.5
              max_weight_oz: 160
              cost: 0.85
              fill_limit_pct: 90
              allowed_packing_classes:
                - standard
              priority: 10
              is_active: true
      responses:
        '201':
          description: Carton template created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A carton template — a shipping box, envelope, or packer-custom container in the carton
                      catalog that the cartonization engine can choose from when packing a shipment. Dimensions
                      are stored in inches and weights in ounces.
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the carton template.
                      name:
                        type: string
                        description: Carton name (unique among non-deleted templates).
                      type:
                        type: string
                        enum:
                          - box
                          - envelope
                          - custom
                        description: Container type. Defaults to `box`.
                      inner_length_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior length, in inches.'
                      inner_width_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior width, in inches.'
                      inner_height_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior height, in inches.'
                      tare_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'The empty carton''s own weight, in ounces.'
                      max_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'Maximum content weight the carton can hold, in ounces.'
                      cost:
                        type: number
                        format: float
                        nullable: true
                        description: Cost of the carton itself.
                      fill_limit_pct:
                        type: integer
                        nullable: true
                        description: Maximum fill (1–100) of the carton's volume the engine will pack. Defaults to `100`.
                      allowed_packing_classes:
                        type: array
                        nullable: true
                        items:
                          type: string
                        description: List of packing-class values this carton accepts. `null` means any class is allowed.
                      requires_dry_ice:
                        type: boolean
                        description: Whether shipments packed in this carton require dry ice.
                      dry_ice_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'Weight of dry ice to add, in ounces.'
                      default_package_code:
                        type: string
                        nullable: true
                        description: Carrier package-type code used when buying a label for this carton.
                      priority:
                        type: integer
                        description: Selection priority. Higher-priority cartons are preferred by the engine. Defaults to `0`.
                      is_active:
                        type: boolean
                        description: Whether the carton is active and available for cartonization. Defaults to `true`.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error — e.g. missing `name`, duplicate `name`, or an invalid `type`.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/carton-templates/{cartonTemplateId}':
    get:
      operationId: getCartonTemplateById
      tags:
        - Carton Templates
      summary: Single carton template
      description: Get a single carton template by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: cartonTemplateId
          required: true
          schema:
            type: integer
          description: Carton template ID.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A carton template — a shipping box, envelope, or packer-custom container in the carton
                      catalog that the cartonization engine can choose from when packing a shipment. Dimensions
                      are stored in inches and weights in ounces.
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the carton template.
                      name:
                        type: string
                        description: Carton name (unique among non-deleted templates).
                      type:
                        type: string
                        enum:
                          - box
                          - envelope
                          - custom
                        description: Container type. Defaults to `box`.
                      inner_length_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior length, in inches.'
                      inner_width_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior width, in inches.'
                      inner_height_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior height, in inches.'
                      tare_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'The empty carton''s own weight, in ounces.'
                      max_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'Maximum content weight the carton can hold, in ounces.'
                      cost:
                        type: number
                        format: float
                        nullable: true
                        description: Cost of the carton itself.
                      fill_limit_pct:
                        type: integer
                        nullable: true
                        description: Maximum fill (1–100) of the carton's volume the engine will pack. Defaults to `100`.
                      allowed_packing_classes:
                        type: array
                        nullable: true
                        items:
                          type: string
                        description: List of packing-class values this carton accepts. `null` means any class is allowed.
                      requires_dry_ice:
                        type: boolean
                        description: Whether shipments packed in this carton require dry ice.
                      dry_ice_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'Weight of dry ice to add, in ounces.'
                      default_package_code:
                        type: string
                        nullable: true
                        description: Carrier package-type code used when buying a label for this carton.
                      priority:
                        type: integer
                        description: Selection priority. Higher-priority cartons are preferred by the engine. Defaults to `0`.
                      is_active:
                        type: boolean
                        description: Whether the carton is active and available for cartonization. Defaults to `true`.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Carton template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateCartonTemplate
      tags:
        - Carton Templates
      summary: Update a carton template
      description: |
        Update an existing carton template. Every field is optional — send only the fields you
        intend to change. `name`, if provided, must remain unique among non-deleted cartons.

        This endpoint also accepts `PATCH /carton-templates/{cartonTemplateId}`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: cartonTemplateId
          required: true
          schema:
            type: integer
          description: Carton template ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Create/update payload for a carton template. On create, only `name` is required; all other
                fields fall back to their column defaults. On update every field is optional — send only the
                fields you intend to change.
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Carton name (unique among non-deleted templates). Required on create.
                type:
                  type: string
                  enum:
                    - box
                    - envelope
                    - custom
                  description: Container type. Defaults to `box`.
                inner_length_in:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Usable interior length, in inches.'
                inner_width_in:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Usable interior width, in inches.'
                inner_height_in:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Usable interior height, in inches.'
                tare_weight_oz:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'The empty carton''s own weight, in ounces.'
                max_weight_oz:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Maximum content weight the carton can hold, in ounces.'
                cost:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: Cost of the carton itself.
                fill_limit_pct:
                  type: integer
                  nullable: true
                  minimum: 1
                  maximum: 100
                  description: Maximum fill (1–100) of the carton's volume the engine will pack. Defaults to `100`.
                allowed_packing_classes:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: List of packing-class values this carton accepts. `null` (or omitted) means any class.
                requires_dry_ice:
                  type: boolean
                  description: Whether shipments packed in this carton require dry ice. Defaults to `false`.
                dry_ice_weight_oz:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Weight of dry ice to add, in ounces.'
                default_package_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Carrier package-type code used when buying a label for this carton.
                priority:
                  type: integer
                  description: Selection priority. Higher-priority cartons are preferred by the engine. Defaults to `0`.
                is_active:
                  type: boolean
                  description: Whether the carton is active and available for cartonization. Defaults to `true`.
            example:
              priority: 20
              is_active: false
      responses:
        '200':
          description: Carton template updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A carton template — a shipping box, envelope, or packer-custom container in the carton
                      catalog that the cartonization engine can choose from when packing a shipment. Dimensions
                      are stored in inches and weights in ounces.
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the carton template.
                      name:
                        type: string
                        description: Carton name (unique among non-deleted templates).
                      type:
                        type: string
                        enum:
                          - box
                          - envelope
                          - custom
                        description: Container type. Defaults to `box`.
                      inner_length_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior length, in inches.'
                      inner_width_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior width, in inches.'
                      inner_height_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior height, in inches.'
                      tare_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'The empty carton''s own weight, in ounces.'
                      max_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'Maximum content weight the carton can hold, in ounces.'
                      cost:
                        type: number
                        format: float
                        nullable: true
                        description: Cost of the carton itself.
                      fill_limit_pct:
                        type: integer
                        nullable: true
                        description: Maximum fill (1–100) of the carton's volume the engine will pack. Defaults to `100`.
                      allowed_packing_classes:
                        type: array
                        nullable: true
                        items:
                          type: string
                        description: List of packing-class values this carton accepts. `null` means any class is allowed.
                      requires_dry_ice:
                        type: boolean
                        description: Whether shipments packed in this carton require dry ice.
                      dry_ice_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'Weight of dry ice to add, in ounces.'
                      default_package_code:
                        type: string
                        nullable: true
                        description: Carrier package-type code used when buying a label for this carton.
                      priority:
                        type: integer
                        description: Selection priority. Higher-priority cartons are preferred by the engine. Defaults to `0`.
                      is_active:
                        type: boolean
                        description: Whether the carton is active and available for cartonization. Defaults to `true`.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Carton template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error — e.g. duplicate `name` or an invalid `type`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    patch:
      operationId: patchCartonTemplate
      tags:
        - Carton Templates
      summary: Update a carton template (PATCH)
      description: |
        Alias for `PUT /carton-templates/{cartonTemplateId}` — a partial update. Send only the
        fields you intend to change.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: cartonTemplateId
          required: true
          schema:
            type: integer
          description: Carton template ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Create/update payload for a carton template. On create, only `name` is required; all other
                fields fall back to their column defaults. On update every field is optional — send only the
                fields you intend to change.
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Carton name (unique among non-deleted templates). Required on create.
                type:
                  type: string
                  enum:
                    - box
                    - envelope
                    - custom
                  description: Container type. Defaults to `box`.
                inner_length_in:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Usable interior length, in inches.'
                inner_width_in:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Usable interior width, in inches.'
                inner_height_in:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Usable interior height, in inches.'
                tare_weight_oz:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'The empty carton''s own weight, in ounces.'
                max_weight_oz:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Maximum content weight the carton can hold, in ounces.'
                cost:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: Cost of the carton itself.
                fill_limit_pct:
                  type: integer
                  nullable: true
                  minimum: 1
                  maximum: 100
                  description: Maximum fill (1–100) of the carton's volume the engine will pack. Defaults to `100`.
                allowed_packing_classes:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: List of packing-class values this carton accepts. `null` (or omitted) means any class.
                requires_dry_ice:
                  type: boolean
                  description: Whether shipments packed in this carton require dry ice. Defaults to `false`.
                dry_ice_weight_oz:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'Weight of dry ice to add, in ounces.'
                default_package_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Carrier package-type code used when buying a label for this carton.
                priority:
                  type: integer
                  description: Selection priority. Higher-priority cartons are preferred by the engine. Defaults to `0`.
                is_active:
                  type: boolean
                  description: Whether the carton is active and available for cartonization. Defaults to `true`.
      responses:
        '200':
          description: Carton template updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A carton template — a shipping box, envelope, or packer-custom container in the carton
                      catalog that the cartonization engine can choose from when packing a shipment. Dimensions
                      are stored in inches and weights in ounces.
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the carton template.
                      name:
                        type: string
                        description: Carton name (unique among non-deleted templates).
                      type:
                        type: string
                        enum:
                          - box
                          - envelope
                          - custom
                        description: Container type. Defaults to `box`.
                      inner_length_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior length, in inches.'
                      inner_width_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior width, in inches.'
                      inner_height_in:
                        type: number
                        format: float
                        nullable: true
                        description: 'Usable interior height, in inches.'
                      tare_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'The empty carton''s own weight, in ounces.'
                      max_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'Maximum content weight the carton can hold, in ounces.'
                      cost:
                        type: number
                        format: float
                        nullable: true
                        description: Cost of the carton itself.
                      fill_limit_pct:
                        type: integer
                        nullable: true
                        description: Maximum fill (1–100) of the carton's volume the engine will pack. Defaults to `100`.
                      allowed_packing_classes:
                        type: array
                        nullable: true
                        items:
                          type: string
                        description: List of packing-class values this carton accepts. `null` means any class is allowed.
                      requires_dry_ice:
                        type: boolean
                        description: Whether shipments packed in this carton require dry ice.
                      dry_ice_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: 'Weight of dry ice to add, in ounces.'
                      default_package_code:
                        type: string
                        nullable: true
                        description: Carrier package-type code used when buying a label for this carton.
                      priority:
                        type: integer
                        description: Selection priority. Higher-priority cartons are preferred by the engine. Defaults to `0`.
                      is_active:
                        type: boolean
                        description: Whether the carton is active and available for cartonization. Defaults to `true`.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Carton template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error — e.g. duplicate `name` or an invalid `type`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteCartonTemplate
      tags:
        - Carton Templates
      summary: Delete a carton template
      description: Soft-delete a carton template. Returns `204 No Content` on success.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: cartonTemplateId
          required: true
          schema:
            type: integer
          description: Carton template ID.
      responses:
        '204':
          description: Carton template deleted. No content.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Carton template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/approval-models/{model}/fields':
    get:
      operationId: listApprovalModelFields
      tags:
        - Approvals
      summary: List approval condition fields
      description: |
        Return the fields an approval rule's conditions can use on a model, each with the operators
        it allows — the same choices as the Settings › Approvals rule form.

        - `SUPPLIER_PURCHASE_ORDER`: `total_cost`.
        - `SALES_ORDER`: `source`, `orderTotal`, `orderStatus`, `is_posted`, `channel_id`.

        Numeric fields (`type` `float`/`int`) allow `==`, `!=`, `>`, `<`, `>=`, `<=`; other fields
        allow `==` and `!=` only. Select fields list their allowed values in `options`
        (`channel_id` takes a channel ID instead).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: model
          required: true
          schema:
            type: string
            enum:
              - SALES_ORDER
              - SUPPLIER_PURCHASE_ORDER
      responses:
        '200':
          description: The model's condition fields.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          description: The value to send as a condition's `field`.
                          example: orderTotal
                        type:
                          type: string
                          enum:
                            - float
                            - int
                            - string
                            - boolean
                        inputType:
                          type: string
                          example: number
                        label:
                          type: string
                          example: Order Total
                        customComponent:
                          type: string
                          description: Present on `channel_id` (`channel`).
                        options:
                          type: array
                          description: 'Allowed values, on select fields.'
                          items:
                            type: object
                            properties:
                              label:
                                type: string
                              value: {}
                        operators:
                          type: array
                          items:
                            type: object
                            properties:
                              label:
                                type: string
                                example: Greater Than
                              value:
                                type: string
                                example: '>'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Unknown approval model.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /approval-rules:
    get:
      operationId: listApprovalRules
      tags:
        - Approvals
      summary: List approval rules
      description: |
        Return every approval rule, ordered by `id`, each with its approver template and approvers.
        Rules are the same records as Settings › Approvals, so rules made in either place show in both.

        The response is wrapped in `data` and is not paginated.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: model
          schema:
            type: string
            enum:
              - SALES_ORDER
              - SUPPLIER_PURCHASE_ORDER
          description: Return only the rules for this document type. Any other value is a 422.
      responses:
        '200':
          description: A list of approval rules.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: An approval rule (Settings › Approvals › Approval Rules). Every new document of its `model` whose fields match its conditions is held for sign-off by the users of its approver template.
                      properties:
                        id:
                          type: integer
                          example: 8
                        name:
                          type: string
                          example: Wholesale prepay
                        model:
                          type: string
                          enum:
                            - SALES_ORDER
                            - SUPPLIER_PURCHASE_ORDER
                          description: The document type the rule applies to.
                        operator:
                          type: string
                          enum:
                            - AND
                            - OR
                          description: How the conditions combine — `AND` (all must match) or `OR` (any).
                        condition:
                          type: array
                          description: The rule's conditions.
                          items:
                            type: object
                            required:
                              - field
                              - operator
                              - value
                            properties:
                              field:
                                type: string
                                description: 'A field `name` from `GET /approval-models/{model}/fields` for the rule''s `model` (e.g. `channel_id`, `orderTotal`, `total_cost`).'
                                example: channel_id
                              operator:
                                type: string
                                enum:
                                  - '=='
                                  - '!='
                                  - '>'
                                  - <
                                  - '>='
                                  - <=
                                description: 'One of the operators that field allows (see `GET /approval-models/{model}/fields`). Numeric fields allow all six; select, string and boolean fields allow only `==` and `!=`.'
                                example: '=='
                              value:
                                description: 'A single value to compare against (string, number or boolean — not an array).'
                                oneOf:
                                  - type: string
                                  - type: number
                                  - type: boolean
                                example: 12
                              order:
                                type: integer
                                description: Position of the condition. Defaults to its index in the `condition` array.
                        order:
                          type: integer
                          nullable: true
                          description: 'The rule''s position, as sent on create/update.'
                        enable_single_approver:
                          type: boolean
                          description: 'When `true`, one approver''s sign-off releases the document.'
                        approval_user_template_id:
                          type: integer
                          example: 3
                        approval_user_template:
                          allOf:
                            - type: object
                              description: An approver template (Settings › Approvals › Approval User Templates) — a named list of users who sign off on documents held by an approval rule.
                              properties:
                                id:
                                  type: integer
                                  example: 3
                                label:
                                  type: string
                                  example: Finance approvers
                                users:
                                  type: array
                                  description: 'The approvers on this template. Only `id` and `name` are returned; use `GET /users/{userId}` for more.'
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        example: 17
                                      name:
                                        type: string
                                        nullable: true
                                        example: Jane Doe
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                          nullable: true
                          description: 'The approver template, with its approvers.'
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Invalid `model`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    post:
      operationId: createApprovalRule
      tags:
        - Approvals
      summary: Create an approval rule
      description: |
        Create a rule that holds every **new** document of its `model` matching its conditions for
        sign-off by the users of its approver template.

        Each condition's `field` and `operator` must come from
        `GET /approval-models/{model}/fields`, and its `value` must be a single value (not an array).
        Conditions without an `order` are ordered by their position in the array.
        `enable_single_approver` defaults to `false`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - model
                - operator
                - condition
                - approval_user_template_id
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Unique among the rules of the same `model`.
                  example: Wholesale prepay
                model:
                  type: string
                  enum:
                    - SALES_ORDER
                    - SUPPLIER_PURCHASE_ORDER
                operator:
                  type: string
                  enum:
                    - AND
                    - OR
                  description: How the conditions combine.
                condition:
                  type: array
                  description: 'One or more conditions. Each `field` and `operator` must come from `GET /approval-models/{model}/fields` for the rule''s `model`.'
                  items:
                    type: object
                    required:
                      - field
                      - operator
                      - value
                    properties:
                      field:
                        type: string
                        description: 'A field `name` from `GET /approval-models/{model}/fields` for the rule''s `model` (e.g. `channel_id`, `orderTotal`, `total_cost`).'
                        example: channel_id
                      operator:
                        type: string
                        enum:
                          - '=='
                          - '!='
                          - '>'
                          - <
                          - '>='
                          - <=
                        description: 'One of the operators that field allows (see `GET /approval-models/{model}/fields`). Numeric fields allow all six; select, string and boolean fields allow only `==` and `!=`.'
                        example: '=='
                      value:
                        description: 'A single value to compare against (string, number or boolean — not an array).'
                        oneOf:
                          - type: string
                          - type: number
                          - type: boolean
                        example: 12
                      order:
                        type: integer
                        description: Position of the condition. Defaults to its index in the `condition` array.
                approval_user_template_id:
                  type: integer
                  description: ID of an existing approver template (`GET /approval-user-templates`).
                  example: 3
                enable_single_approver:
                  type: boolean
                  description: 'When `true`, one approver''s sign-off releases the document. Optional on create (defaults to `false`); **required** on `PUT`.'
                order:
                  type: integer
                  description: Optional position of the rule.
            example:
              name: Wholesale prepay
              model: SALES_ORDER
              operator: AND
              condition:
                - field: channel_id
                  operator: '=='
                  value: 12
              approval_user_template_id: 3
      responses:
        '201':
          description: Approval rule created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An approval rule (Settings › Approvals › Approval Rules). Every new document of its `model` whose fields match its conditions is held for sign-off by the users of its approver template.
                    properties:
                      id:
                        type: integer
                        example: 8
                      name:
                        type: string
                        example: Wholesale prepay
                      model:
                        type: string
                        enum:
                          - SALES_ORDER
                          - SUPPLIER_PURCHASE_ORDER
                        description: The document type the rule applies to.
                      operator:
                        type: string
                        enum:
                          - AND
                          - OR
                        description: How the conditions combine — `AND` (all must match) or `OR` (any).
                      condition:
                        type: array
                        description: The rule's conditions.
                        items:
                          type: object
                          required:
                            - field
                            - operator
                            - value
                          properties:
                            field:
                              type: string
                              description: 'A field `name` from `GET /approval-models/{model}/fields` for the rule''s `model` (e.g. `channel_id`, `orderTotal`, `total_cost`).'
                              example: channel_id
                            operator:
                              type: string
                              enum:
                                - '=='
                                - '!='
                                - '>'
                                - <
                                - '>='
                                - <=
                              description: 'One of the operators that field allows (see `GET /approval-models/{model}/fields`). Numeric fields allow all six; select, string and boolean fields allow only `==` and `!=`.'
                              example: '=='
                            value:
                              description: 'A single value to compare against (string, number or boolean — not an array).'
                              oneOf:
                                - type: string
                                - type: number
                                - type: boolean
                              example: 12
                            order:
                              type: integer
                              description: Position of the condition. Defaults to its index in the `condition` array.
                      order:
                        type: integer
                        nullable: true
                        description: 'The rule''s position, as sent on create/update.'
                      enable_single_approver:
                        type: boolean
                        description: 'When `true`, one approver''s sign-off releases the document.'
                      approval_user_template_id:
                        type: integer
                        example: 3
                      approval_user_template:
                        allOf:
                          - type: object
                            description: An approver template (Settings › Approvals › Approval User Templates) — a named list of users who sign off on documents held by an approval rule.
                            properties:
                              id:
                                type: integer
                                example: 3
                              label:
                                type: string
                                example: Finance approvers
                              users:
                                type: array
                                description: 'The approvers on this template. Only `id` and `name` are returned; use `GET /users/{userId}` for more.'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      example: 17
                                    name:
                                      type: string
                                      nullable: true
                                      example: Jane Doe
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                        description: 'The approver template, with its approvers.'
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error, with every error listed — e.g. a duplicate `name` for the model, an unknown
            condition `field`, an `operator` the field does not allow, an array `value`, or an
            `approval_user_template_id` that does not exist.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/approval-rules/{id}':
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: integer
        description: The approval rule ID.
    get:
      operationId: getApprovalRule
      tags:
        - Approvals
      summary: Get an approval rule
      description: Return one approval rule with its approver template and approvers.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: The approval rule.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An approval rule (Settings › Approvals › Approval Rules). Every new document of its `model` whose fields match its conditions is held for sign-off by the users of its approver template.
                    properties:
                      id:
                        type: integer
                        example: 8
                      name:
                        type: string
                        example: Wholesale prepay
                      model:
                        type: string
                        enum:
                          - SALES_ORDER
                          - SUPPLIER_PURCHASE_ORDER
                        description: The document type the rule applies to.
                      operator:
                        type: string
                        enum:
                          - AND
                          - OR
                        description: How the conditions combine — `AND` (all must match) or `OR` (any).
                      condition:
                        type: array
                        description: The rule's conditions.
                        items:
                          type: object
                          required:
                            - field
                            - operator
                            - value
                          properties:
                            field:
                              type: string
                              description: 'A field `name` from `GET /approval-models/{model}/fields` for the rule''s `model` (e.g. `channel_id`, `orderTotal`, `total_cost`).'
                              example: channel_id
                            operator:
                              type: string
                              enum:
                                - '=='
                                - '!='
                                - '>'
                                - <
                                - '>='
                                - <=
                              description: 'One of the operators that field allows (see `GET /approval-models/{model}/fields`). Numeric fields allow all six; select, string and boolean fields allow only `==` and `!=`.'
                              example: '=='
                            value:
                              description: 'A single value to compare against (string, number or boolean — not an array).'
                              oneOf:
                                - type: string
                                - type: number
                                - type: boolean
                              example: 12
                            order:
                              type: integer
                              description: Position of the condition. Defaults to its index in the `condition` array.
                      order:
                        type: integer
                        nullable: true
                        description: 'The rule''s position, as sent on create/update.'
                      enable_single_approver:
                        type: boolean
                        description: 'When `true`, one approver''s sign-off releases the document.'
                      approval_user_template_id:
                        type: integer
                        example: 3
                      approval_user_template:
                        allOf:
                          - type: object
                            description: An approver template (Settings › Approvals › Approval User Templates) — a named list of users who sign off on documents held by an approval rule.
                            properties:
                              id:
                                type: integer
                                example: 3
                              label:
                                type: string
                                example: Finance approvers
                              users:
                                type: array
                                description: 'The approvers on this template. Only `id` and `name` are returned; use `GET /users/{userId}` for more.'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      example: 17
                                    name:
                                      type: string
                                      nullable: true
                                      example: Jane Doe
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                        description: 'The approver template, with its approvers.'
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Approval rule not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateApprovalRule
      tags:
        - Approvals
      summary: Replace an approval rule
      description: |
        Replace a rule, as the Settings form saves it. Send the full body: every field of create is
        required again, and `enable_single_approver` is **required** too (so omitting it cannot reset it).
        The `condition` array replaces the existing conditions.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  required:
                    - name
                    - model
                    - operator
                    - condition
                    - approval_user_template_id
                  properties:
                    name:
                      type: string
                      maxLength: 255
                      description: Unique among the rules of the same `model`.
                      example: Wholesale prepay
                    model:
                      type: string
                      enum:
                        - SALES_ORDER
                        - SUPPLIER_PURCHASE_ORDER
                    operator:
                      type: string
                      enum:
                        - AND
                        - OR
                      description: How the conditions combine.
                    condition:
                      type: array
                      description: 'One or more conditions. Each `field` and `operator` must come from `GET /approval-models/{model}/fields` for the rule''s `model`.'
                      items:
                        type: object
                        required:
                          - field
                          - operator
                          - value
                        properties:
                          field:
                            type: string
                            description: 'A field `name` from `GET /approval-models/{model}/fields` for the rule''s `model` (e.g. `channel_id`, `orderTotal`, `total_cost`).'
                            example: channel_id
                          operator:
                            type: string
                            enum:
                              - '=='
                              - '!='
                              - '>'
                              - <
                              - '>='
                              - <=
                            description: 'One of the operators that field allows (see `GET /approval-models/{model}/fields`). Numeric fields allow all six; select, string and boolean fields allow only `==` and `!=`.'
                            example: '=='
                          value:
                            description: 'A single value to compare against (string, number or boolean — not an array).'
                            oneOf:
                              - type: string
                              - type: number
                              - type: boolean
                            example: 12
                          order:
                            type: integer
                            description: Position of the condition. Defaults to its index in the `condition` array.
                    approval_user_template_id:
                      type: integer
                      description: ID of an existing approver template (`GET /approval-user-templates`).
                      example: 3
                    enable_single_approver:
                      type: boolean
                      description: 'When `true`, one approver''s sign-off releases the document. Optional on create (defaults to `false`); **required** on `PUT`.'
                    order:
                      type: integer
                      description: Optional position of the rule.
                - required:
                    - enable_single_approver
            example:
              name: Wholesale prepay
              model: SALES_ORDER
              operator: OR
              condition:
                - field: channel_id
                  operator: '=='
                  value: 14
              approval_user_template_id: 3
              enable_single_approver: true
      responses:
        '200':
          description: The updated approval rule.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An approval rule (Settings › Approvals › Approval Rules). Every new document of its `model` whose fields match its conditions is held for sign-off by the users of its approver template.
                    properties:
                      id:
                        type: integer
                        example: 8
                      name:
                        type: string
                        example: Wholesale prepay
                      model:
                        type: string
                        enum:
                          - SALES_ORDER
                          - SUPPLIER_PURCHASE_ORDER
                        description: The document type the rule applies to.
                      operator:
                        type: string
                        enum:
                          - AND
                          - OR
                        description: How the conditions combine — `AND` (all must match) or `OR` (any).
                      condition:
                        type: array
                        description: The rule's conditions.
                        items:
                          type: object
                          required:
                            - field
                            - operator
                            - value
                          properties:
                            field:
                              type: string
                              description: 'A field `name` from `GET /approval-models/{model}/fields` for the rule''s `model` (e.g. `channel_id`, `orderTotal`, `total_cost`).'
                              example: channel_id
                            operator:
                              type: string
                              enum:
                                - '=='
                                - '!='
                                - '>'
                                - <
                                - '>='
                                - <=
                              description: 'One of the operators that field allows (see `GET /approval-models/{model}/fields`). Numeric fields allow all six; select, string and boolean fields allow only `==` and `!=`.'
                              example: '=='
                            value:
                              description: 'A single value to compare against (string, number or boolean — not an array).'
                              oneOf:
                                - type: string
                                - type: number
                                - type: boolean
                              example: 12
                            order:
                              type: integer
                              description: Position of the condition. Defaults to its index in the `condition` array.
                      order:
                        type: integer
                        nullable: true
                        description: 'The rule''s position, as sent on create/update.'
                      enable_single_approver:
                        type: boolean
                        description: 'When `true`, one approver''s sign-off releases the document.'
                      approval_user_template_id:
                        type: integer
                        example: 3
                      approval_user_template:
                        allOf:
                          - type: object
                            description: An approver template (Settings › Approvals › Approval User Templates) — a named list of users who sign off on documents held by an approval rule.
                            properties:
                              id:
                                type: integer
                                example: 3
                              label:
                                type: string
                                example: Finance approvers
                              users:
                                type: array
                                description: 'The approvers on this template. Only `id` and `name` are returned; use `GET /users/{userId}` for more.'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      example: 17
                                    name:
                                      type: string
                                      nullable: true
                                      example: Jane Doe
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                        description: 'The approver template, with its approvers.'
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Approval rule not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (same checks as create, plus a missing `enable_single_approver`).'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteApprovalRule
      tags:
        - Approvals
      summary: Delete an approval rule
      description: Delete an approval rule. New documents are no longer held by it.
      security:
        - BearerAuth: []
      responses:
        '204':
          description: Approval rule deleted.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Approval rule not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /approval-user-templates:
    get:
      operationId: listApprovalUserTemplates
      tags:
        - Approvals
      summary: List approver templates
      description: |
        Return the approver templates (named lists of approving users) that approval rules point at,
        each with its users. Paginated.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: label
          schema:
            type: string
          description: Filter to templates whose `label` contains this value.
        - in: query
          name: page
          schema:
            type: integer
            default: 1
        - in: query
          name: per_page
          schema:
            type: integer
          description: Results per page.
      responses:
        '200':
          description: A page of approver templates.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: An approver template (Settings › Approvals › Approval User Templates) — a named list of users who sign off on documents held by an approval rule.
                      properties:
                        id:
                          type: integer
                          example: 3
                        label:
                          type: string
                          example: Finance approvers
                        users:
                          type: array
                          description: 'The approvers on this template. Only `id` and `name` are returned; use `GET /users/{userId}` for more.'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                example: 17
                              name:
                                type: string
                                nullable: true
                                example: Jane Doe
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                  links:
                    type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createApprovalUserTemplate
      tags:
        - Approvals
      summary: Create an approver template
      description: Create a named list of approving users to point approval rules at. `label` must be unique.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - label
                - user_ids
              properties:
                label:
                  type: string
                  maxLength: 255
                  description: Unique template name.
                  example: Finance approvers
                user_ids:
                  type: array
                  minItems: 1
                  description: IDs of the approving users (from `GET /users`). At least one is required.
                  items:
                    type: integer
                  example:
                    - 17
                    - 21
      responses:
        '201':
          description: Approver template created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An approver template (Settings › Approvals › Approval User Templates) — a named list of users who sign off on documents held by an approval rule.
                    properties:
                      id:
                        type: integer
                        example: 3
                      label:
                        type: string
                        example: Finance approvers
                      users:
                        type: array
                        description: 'The approvers on this template. Only `id` and `name` are returned; use `GET /users/{userId}` for more.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 17
                            name:
                              type: string
                              nullable: true
                              example: Jane Doe
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error — e.g. missing or duplicate `label`, empty `user_ids`, or an unknown user ID.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/approval-user-templates/{id}':
    parameters:
      - in: path
        name: id
        required: true
        schema:
          type: integer
        description: The approver template ID.
    get:
      operationId: getApprovalUserTemplate
      tags:
        - Approvals
      summary: Get an approver template
      description: Return one approver template with its users.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: The approver template.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An approver template (Settings › Approvals › Approval User Templates) — a named list of users who sign off on documents held by an approval rule.
                    properties:
                      id:
                        type: integer
                        example: 3
                      label:
                        type: string
                        example: Finance approvers
                      users:
                        type: array
                        description: 'The approvers on this template. Only `id` and `name` are returned; use `GET /users/{userId}` for more.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 17
                            name:
                              type: string
                              nullable: true
                              example: Jane Doe
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Approver template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateApprovalUserTemplate
      tags:
        - Approvals
      summary: Replace an approver template
      description: Replace a template's `label` and its whole approver list (`user_ids` replaces the existing users).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - label
                - user_ids
              properties:
                label:
                  type: string
                  maxLength: 255
                  description: Unique template name.
                  example: Finance approvers
                user_ids:
                  type: array
                  minItems: 1
                  description: IDs of the approving users (from `GET /users`). At least one is required.
                  items:
                    type: integer
                  example:
                    - 17
                    - 21
      responses:
        '200':
          description: The updated approver template.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An approver template (Settings › Approvals › Approval User Templates) — a named list of users who sign off on documents held by an approval rule.
                    properties:
                      id:
                        type: integer
                        example: 3
                      label:
                        type: string
                        example: Finance approvers
                      users:
                        type: array
                        description: 'The approvers on this template. Only `id` and `name` are returned; use `GET /users/{userId}` for more.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 17
                            name:
                              type: string
                              nullable: true
                              example: Jane Doe
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Approver template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (same checks as create).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteApprovalUserTemplate
      tags:
        - Approvals
      summary: Delete an approver template
      description: Delete an approver template.
      security:
        - BearerAuth: []
      responses:
        '204':
          description: Approver template deleted.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Approver template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /shipping-rules:
    get:
      operationId: listShippingRules
      tags:
        - Shipping Rules
      summary: Get shipping rules
      description: |
        Return the tenant's saved shipping rules — one ordered list that decides which carriers and
        services an order may ship with, and on which days. The same list is edited in the app under
        **Operations → Operations Admin → Shipping Rules**.

        At label time, every rule whose conditions all hold applies, from top to bottom:

        - It narrows the quoted rates to its `services`, and to `maxTransitDays` if set.
        - A `lock` rule refuses a label on any service outside its list.
        - `shipDays` refuses a label on any other day, in the tenant operating timezone.
        - A rule that would leave no rate at all is skipped, so an order is never left unshippable.

        On Parcel Perform accounts the carrier is chosen by Parcel Perform's own rules, so only
        `shipDays` takes effect there.

        `warnings` lists configurations that are legal but probably unintended — a rule with no
        conditions, two locked rules that can apply to the same order with disjoint services (between
        them they refuse every label), or a state code that is not a US state or territory.

        Available to every account. When per-user permissions are enabled, the token's owner needs the `fulfillmentSettings.read` permission (the same as the Operations Admin pages); otherwise `403`. When per-user
        permissions are enabled, the token's owner needs `fulfillmentSettings.read`.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: 'The saved shipping rules, in apply order.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      required:
                        - name
                      properties:
                        name:
                          type: string
                          description: Unique rule name. Shown in label refusals and on rates.
                          example: Perishables West → FedEx 2Day
                        when:
                          type: object
                          description: |
                            Conditions. All conditions that are set must hold for the rule to apply. Empty lists and
                            `null` mean "no condition"; a rule with no conditions matches every order.
                          properties:
                            packingClasses:
                              type: array
                              items:
                                type: string
                                enum:
                                  - ambient
                                  - perishable_dry_ice
                                  - flour
                                  - fragile
                                  - bulk
                                  - liquid
                              description: Any line on the order has one of these packing classes.
                            states:
                              type: array
                              items:
                                type: string
                              description: 'Ship-to state or province code (e.g. `CA`, `AK`, `AA`).'
                            countries:
                              type: array
                              items:
                                type: string
                              description: 'Ship-to country, two-letter ISO code.'
                            poBox:
                              type: boolean
                              nullable: true
                              description: '`true`: the ship-to address is a PO box; `false`: it is not; `null`/absent: either.'
                            tagsAny:
                              type: array
                              items:
                                type: string
                              description: The fulfillment order or its sales order carries one of these tags (by name).
                            tiktokOrder:
                              type: boolean
                              nullable: true
                              description: '`true`: a TikTok Shop order; `false`: not; `null`/absent: either.'
                            channelIds:
                              type: array
                              items:
                                type: integer
                              description: The order came from one of these sales channels.
                        then:
                          type: object
                          description: Effects applied when the rule matches.
                          properties:
                            services:
                              type: array
                              items:
                                type: string
                              description: Allowed services. A rate is kept when its service code equals an entry or its service name contains one.
                            maxTransitDays:
                              type: integer
                              minimum: 1
                              maximum: 30
                              nullable: true
                              description: Keep only rates quoting this many transit days or fewer.
                            shipDays:
                              type: array
                              items:
                                type: string
                                enum:
                                  - Mon
                                  - Tue
                                  - Wed
                                  - Thu
                                  - Fri
                                  - Sat
                                  - Sun
                              description: Labels may only be bought on these days (tenant operating timezone).
                            lock:
                              type: boolean
                              description: Refuse a label on any service outside `services`. Requires `services`.
                      example:
                        name: Perishables West → FedEx 2Day
                        when:
                          packingClasses:
                            - perishable_dry_ice
                          states:
                            - WA
                            - OR
                            - CA
                        then:
                          services:
                            - FEDEX_2_DAY
                            - FedEx 2Day
                          shipDays:
                            - Tue
                            - Wed
                          lock: true
                  warnings:
                    type: array
                    items:
                      type: object
                      properties:
                        rule:
                          type: integer
                          nullable: true
                          description: Zero-based index of the rule the warning is about.
                          example: 2
                        message:
                          type: string
                          example: '"Islands" has no conditions, so it applies to every order.'
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: The token's owner lacks the `fulfillmentSettings.read` permission (enforced when per-user permissions are enabled).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: User does not have the right permissions.
    put:
      operationId: replaceShippingRules
      tags:
        - Shipping Rules
      summary: Replace shipping rules
      description: |
        Replace the whole ordered list of shipping rules. The list is in apply order and replaces
        everything saved; `{ "rules": [] }` clears it.

        Writes are validated strictly — nothing is saved if any rule has an error. Errors are reported
        for unknown fields, conditions or effects; invalid state, country, packing-class or day values;
        channel ids that don't exist; `maxTransitDays` outside 1–30; `lock` without `services`; a rule
        that does nothing; a missing or duplicate `name`; and more than 100 rules.

        On success the cleaned rules are returned: values are trimmed and de-duplicated, codes are
        upper-cased, days are written as Mon…Sun in week order, and empty conditions are dropped.

        Available to every account. When per-user permissions are enabled, the token's owner needs the `fulfillmentSettings.read` permission (the same as the Operations Admin pages); otherwise `403`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - rules
              properties:
                rules:
                  type: array
                  maxItems: 100
                  items:
                    type: object
                    required:
                      - name
                    properties:
                      name:
                        type: string
                        description: Unique rule name. Shown in label refusals and on rates.
                        example: Perishables West → FedEx 2Day
                      when:
                        type: object
                        description: |
                          Conditions. All conditions that are set must hold for the rule to apply. Empty lists and
                          `null` mean "no condition"; a rule with no conditions matches every order.
                        properties:
                          packingClasses:
                            type: array
                            items:
                              type: string
                              enum:
                                - ambient
                                - perishable_dry_ice
                                - flour
                                - fragile
                                - bulk
                                - liquid
                            description: Any line on the order has one of these packing classes.
                          states:
                            type: array
                            items:
                              type: string
                            description: 'Ship-to state or province code (e.g. `CA`, `AK`, `AA`).'
                          countries:
                            type: array
                            items:
                              type: string
                            description: 'Ship-to country, two-letter ISO code.'
                          poBox:
                            type: boolean
                            nullable: true
                            description: '`true`: the ship-to address is a PO box; `false`: it is not; `null`/absent: either.'
                          tagsAny:
                            type: array
                            items:
                              type: string
                            description: The fulfillment order or its sales order carries one of these tags (by name).
                          tiktokOrder:
                            type: boolean
                            nullable: true
                            description: '`true`: a TikTok Shop order; `false`: not; `null`/absent: either.'
                          channelIds:
                            type: array
                            items:
                              type: integer
                            description: The order came from one of these sales channels.
                      then:
                        type: object
                        description: Effects applied when the rule matches.
                        properties:
                          services:
                            type: array
                            items:
                              type: string
                            description: Allowed services. A rate is kept when its service code equals an entry or its service name contains one.
                          maxTransitDays:
                            type: integer
                            minimum: 1
                            maximum: 30
                            nullable: true
                            description: Keep only rates quoting this many transit days or fewer.
                          shipDays:
                            type: array
                            items:
                              type: string
                              enum:
                                - Mon
                                - Tue
                                - Wed
                                - Thu
                                - Fri
                                - Sat
                                - Sun
                            description: Labels may only be bought on these days (tenant operating timezone).
                          lock:
                            type: boolean
                            description: Refuse a label on any service outside `services`. Requires `services`.
                    example:
                      name: Perishables West → FedEx 2Day
                      when:
                        packingClasses:
                          - perishable_dry_ice
                        states:
                          - WA
                          - OR
                          - CA
                      then:
                        services:
                          - FEDEX_2_DAY
                          - FedEx 2Day
                        shipDays:
                          - Tue
                          - Wed
                        lock: true
            example:
              rules:
                - name: Perishables West → FedEx 2Day
                  when:
                    packingClasses:
                      - perishable_dry_ice
                    states:
                      - WA
                      - OR
                      - CA
                  then:
                    services:
                      - FEDEX_2_DAY
                      - FedEx 2Day
                    shipDays:
                      - Tue
                      - Wed
                    lock: true
      responses:
        '200':
          description: Rules saved. Returns the cleaned list plus any warnings.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      required:
                        - name
                      properties:
                        name:
                          type: string
                          description: Unique rule name. Shown in label refusals and on rates.
                          example: Perishables West → FedEx 2Day
                        when:
                          type: object
                          description: |
                            Conditions. All conditions that are set must hold for the rule to apply. Empty lists and
                            `null` mean "no condition"; a rule with no conditions matches every order.
                          properties:
                            packingClasses:
                              type: array
                              items:
                                type: string
                                enum:
                                  - ambient
                                  - perishable_dry_ice
                                  - flour
                                  - fragile
                                  - bulk
                                  - liquid
                              description: Any line on the order has one of these packing classes.
                            states:
                              type: array
                              items:
                                type: string
                              description: 'Ship-to state or province code (e.g. `CA`, `AK`, `AA`).'
                            countries:
                              type: array
                              items:
                                type: string
                              description: 'Ship-to country, two-letter ISO code.'
                            poBox:
                              type: boolean
                              nullable: true
                              description: '`true`: the ship-to address is a PO box; `false`: it is not; `null`/absent: either.'
                            tagsAny:
                              type: array
                              items:
                                type: string
                              description: The fulfillment order or its sales order carries one of these tags (by name).
                            tiktokOrder:
                              type: boolean
                              nullable: true
                              description: '`true`: a TikTok Shop order; `false`: not; `null`/absent: either.'
                            channelIds:
                              type: array
                              items:
                                type: integer
                              description: The order came from one of these sales channels.
                        then:
                          type: object
                          description: Effects applied when the rule matches.
                          properties:
                            services:
                              type: array
                              items:
                                type: string
                              description: Allowed services. A rate is kept when its service code equals an entry or its service name contains one.
                            maxTransitDays:
                              type: integer
                              minimum: 1
                              maximum: 30
                              nullable: true
                              description: Keep only rates quoting this many transit days or fewer.
                            shipDays:
                              type: array
                              items:
                                type: string
                                enum:
                                  - Mon
                                  - Tue
                                  - Wed
                                  - Thu
                                  - Fri
                                  - Sat
                                  - Sun
                              description: Labels may only be bought on these days (tenant operating timezone).
                            lock:
                              type: boolean
                              description: Refuse a label on any service outside `services`. Requires `services`.
                      example:
                        name: Perishables West → FedEx 2Day
                        when:
                          packingClasses:
                            - perishable_dry_ice
                          states:
                            - WA
                            - OR
                            - CA
                        then:
                          services:
                            - FEDEX_2_DAY
                            - FedEx 2Day
                          shipDays:
                            - Tue
                            - Wed
                          lock: true
                  warnings:
                    type: array
                    items:
                      type: object
                      properties:
                        rule:
                          type: integer
                          nullable: true
                          description: Zero-based index of the rule the warning is about.
                          example: 2
                        message:
                          type: string
                          example: '"Islands" has no conditions, so it applies to every order.'
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: The token's owner lacks the `fulfillmentSettings.read` permission (enforced when per-user permissions are enabled).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: User does not have the right permissions.
        '422':
          description: One or more rules have errors. Nothing was saved.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: The shipping rules have errors.
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                    example:
                      rules.1.when.states:
                        - '"California" is not a state or province code.'
  /shipping-rules/schema:
    get:
      operationId: getShippingRulesSchema
      tags:
        - Shipping Rules
      summary: Get the shipping-rule schema
      description: |
        Describe the shipping-rule format — every condition (`when`) and effect (`then`), with its type,
        allowed options and meaning — plus the maximum number of rules. Useful for building an editor
        or for an AI agent authoring rules.

        Available to every account. When per-user permissions are enabled, the token's owner needs the `fulfillmentSettings.read` permission (the same as the Operations Admin pages); otherwise `403`.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: The rule format.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      description:
                        type: string
                        description: How the ordered list is applied.
                      maxRules:
                        type: integer
                        example: 100
                      rule:
                        type: object
                        description: |
                          Field descriptors keyed by field name: `name`, and the `when` / `then` maps. Each
                          descriptor has `type` (e.g. `string[]`, `boolean|null`, `integer|null`),
                          `description`, and where applicable `options` (allowed values) or `required`.
                        additionalProperties: true
                example:
                  data:
                    description: 'An ordered list of shipping rules. Every rule whose conditions all hold applies, top to bottom …'
                    maxRules: 100
                    rule:
                      name:
                        type: string
                        required: true
                        description: 'Unique, shown in label refusals and rate badges.'
                      when:
                        packingClasses:
                          type: 'string[]'
                          options:
                            - ambient
                            - perishable_dry_ice
                            - flour
                            - fragile
                            - bulk
                            - liquid
                          description: Any line on the order has one of these packing classes.
                      then:
                        shipDays:
                          type: 'string[]'
                          options:
                            - Mon
                            - Tue
                            - Wed
                            - Thu
                            - Fri
                            - Sat
                            - Sun
                          description: Labels may only be bought on these days (tenant operating timezone).
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: The token's owner lacks the `fulfillmentSettings.read` permission (enforced when per-user permissions are enabled).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: User does not have the right permissions.
  /shipping-rules/test:
    post:
      operationId: testShippingRules
      tags:
        - Shipping Rules
      summary: Test shipping rules against an order
      description: |
        Evaluate shipping rules against one fulfillment order and explain the result: the order's
        facts, each rule's per-condition result and whether it matched, and the label refusal (if any)
        for a given service at a given time.

        Identify the order with `fulfillment_order_id` or `order_number` (an order number or scan,
        resolved like the label panel's lookup). Pass `rules` to test a draft list — it is validated
        first (`422` as for `PUT /shipping-rules`) and never saved. When `rules` is omitted, the saved
        rules are used.

        Available to every account. When per-user permissions are enabled, the token's owner needs the `fulfillmentSettings.read` permission (the same as the Operations Admin pages); otherwise `403`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                fulfillment_order_id:
                  type: integer
                  nullable: true
                  description: Required unless `order_number` is given.
                order_number:
                  type: string
                  maxLength: 100
                  nullable: true
                  description: Required unless `fulfillment_order_id` is given.
                rules:
                  type: array
                  nullable: true
                  description: A draft rule list to test instead of the saved rules. Never saved.
                  items:
                    type: object
                    required:
                      - name
                    properties:
                      name:
                        type: string
                        description: Unique rule name. Shown in label refusals and on rates.
                        example: Perishables West → FedEx 2Day
                      when:
                        type: object
                        description: |
                          Conditions. All conditions that are set must hold for the rule to apply. Empty lists and
                          `null` mean "no condition"; a rule with no conditions matches every order.
                        properties:
                          packingClasses:
                            type: array
                            items:
                              type: string
                              enum:
                                - ambient
                                - perishable_dry_ice
                                - flour
                                - fragile
                                - bulk
                                - liquid
                            description: Any line on the order has one of these packing classes.
                          states:
                            type: array
                            items:
                              type: string
                            description: 'Ship-to state or province code (e.g. `CA`, `AK`, `AA`).'
                          countries:
                            type: array
                            items:
                              type: string
                            description: 'Ship-to country, two-letter ISO code.'
                          poBox:
                            type: boolean
                            nullable: true
                            description: '`true`: the ship-to address is a PO box; `false`: it is not; `null`/absent: either.'
                          tagsAny:
                            type: array
                            items:
                              type: string
                            description: The fulfillment order or its sales order carries one of these tags (by name).
                          tiktokOrder:
                            type: boolean
                            nullable: true
                            description: '`true`: a TikTok Shop order; `false`: not; `null`/absent: either.'
                          channelIds:
                            type: array
                            items:
                              type: integer
                            description: The order came from one of these sales channels.
                      then:
                        type: object
                        description: Effects applied when the rule matches.
                        properties:
                          services:
                            type: array
                            items:
                              type: string
                            description: Allowed services. A rate is kept when its service code equals an entry or its service name contains one.
                          maxTransitDays:
                            type: integer
                            minimum: 1
                            maximum: 30
                            nullable: true
                            description: Keep only rates quoting this many transit days or fewer.
                          shipDays:
                            type: array
                            items:
                              type: string
                              enum:
                                - Mon
                                - Tue
                                - Wed
                                - Thu
                                - Fri
                                - Sat
                                - Sun
                            description: Labels may only be bought on these days (tenant operating timezone).
                          lock:
                            type: boolean
                            description: Refuse a label on any service outside `services`. Requires `services`.
                    example:
                      name: Perishables West → FedEx 2Day
                      when:
                        packingClasses:
                          - perishable_dry_ice
                        states:
                          - WA
                          - OR
                          - CA
                      then:
                        services:
                          - FEDEX_2_DAY
                          - FedEx 2Day
                        shipDays:
                          - Tue
                          - Wed
                        lock: true
                service_code:
                  type: string
                  maxLength: 120
                  nullable: true
                  description: The service to check a label refusal for.
                at:
                  type: string
                  format: date-time
                  nullable: true
                  description: When the label would be bought. Defaults to now.
            example:
              order_number: BF-104233
              service_code: FEDEX_GROUND
      responses:
        '200':
          description: Evaluation result.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      fulfillment_order_id:
                        type: integer
                      order_number:
                        type: string
                      facts:
                        type: object
                        description: The order values the conditions are evaluated against.
                        properties:
                          state:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                          poBox:
                            type: boolean
                          tiktok:
                            type: boolean
                          packingClasses:
                            type: array
                            items:
                              type: string
                          tags:
                            type: array
                            items:
                              type: string
                          channelId:
                            type: integer
                            nullable: true
                      rules:
                        type: array
                        items:
                          type: object
                          properties:
                            index:
                              type: integer
                              description: Zero-based position in the list.
                            name:
                              type: string
                            matched:
                              type: boolean
                              description: '`true` when every condition the rule sets passes.'
                            conditions:
                              type: array
                              description: 'Each condition the rule sets, with the order''s value and whether it holds.'
                              items:
                                type: object
                                properties:
                                  key:
                                    type: string
                                    example: states
                                  expected:
                                    description: The rule's value for this condition.
                                  actual:
                                    description: The order's value for this condition.
                                  pass:
                                    type: boolean
                      label_refusal:
                        type: string
                        nullable: true
                        description: 'Why a label on `service_code` at `at` would be refused, or `null` if it would be allowed.'
                example:
                  data:
                    fulfillment_order_id: 4821
                    order_number: BF-104233
                    facts:
                      state: CA
                      country: US
                      poBox: false
                      tiktok: false
                      packingClasses:
                        - perishable_dry_ice
                      tags: []
                      channelId: 3
                    rules:
                      - index: 0
                        name: Perishables West → FedEx 2Day
                        matched: true
                        conditions:
                          - key: states
                            expected:
                              - WA
                              - OR
                              - CA
                            actual: CA
                            pass: true
                          - key: packingClasses
                            expected:
                              - perishable_dry_ice
                            actual:
                              - perishable_dry_ice
                            pass: true
                    label_refusal: 'Perishables West → FedEx 2Day: ship with FEDEX_2_DAY or FedEx 2Day.'
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: The token's owner lacks the `fulfillmentSettings.read` permission (enforced when per-user permissions are enabled).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: User does not have the right permissions.
        '404':
          description: The fulfillment order was not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Fulfillment order not found.
        '422':
          description: 'Missing order identifier, invalid parameters, or the draft `rules` have errors.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /automations/schema:
    get:
      operationId: getAutomationsSchema
      tags:
        - Automations
      summary: Get the automation catalog
      description: |
        The catalog that rule writes are validated against: rule statuses, tester models, every trigger
        (with the model it runs on and whether the live tester can fire it), condition types, action
        types, value-pipeline initial values and functions, and the leaf field paths for each model.

        `manually_triggerable` is false for events the tester cannot fire (`daily`, `hourly`,
        `receiving`, `shipment_created`, `deal_created`, `deal_stage_changed`) and for
        `sku_mapping_completed` / `sku_mapping_failed`, which need extra context. Pipeline function names
        are snake_case; the camelCase form (`addDays`) is also accepted.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: The automation catalog.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      statuses:
                        type: array
                        items:
                          type: string
                        example:
                          - active
                          - paused
                          - error
                      default_status:
                        type: string
                        example: paused
                      models:
                        type: array
                        description: Model aliases accepted by `POST /automations/runs` `model_type`.
                        items:
                          type: string
                        example:
                          - order
                          - invoice
                          - fulfillment_order
                          - supplier_purchase_order
                          - supplier_purchase_order_shipment
                          - transfer_order
                          - order_item
                          - oms_product
                          - rfq
                          - assembly_order
                          - approval
                          - work_order
                          - production_batch
                          - supplier_receiving_report
                      triggers:
                        type: array
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                              example: order_updated
                            model:
                              type: string
                              nullable: true
                              description: Model alias the event fires on; null when not tied to a loadable record.
                              example: order
                            manually_triggerable:
                              type: boolean
                      conditions:
                        type: array
                        items:
                          type: object
                          properties:
                            type:
                              type: string
                              example: field
                      actions:
                        type: array
                        items:
                          type: object
                          properties:
                            type:
                              type: string
                              example: update_column
                      pipeline:
                        type: object
                        properties:
                          initial_values:
                            type: array
                            items:
                              type: string
                            example:
                              - now
                              - today
                              - yesterday
                              - tomorrow
                              - value
                          functions:
                            type: array
                            items:
                              type: string
                            example:
                              - add_days
                              - date_modify
                              - upper
                      model_field_paths:
                        type: object
                        description: Leaf field paths keyed by model alias.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                        example:
                          work_order:
                            - status
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /automations/runs:
    get:
      operationId: getAutomationRuns
      tags:
        - Automations
      summary: List automation runs
      description: |
        Paginated list of automation runs, newest first.

        Ordinary production events write run rows only when the tenant log level is `debug`; the live
        tester always writes them.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number
        - in: query
          name: per_page
          schema:
            type: integer
            default: 25
          description: Runs per page
        - in: query
          name: status
          schema:
            type: string
          description: Exact run status (e.g. `completed`)
        - in: query
          name: event_name
          schema:
            type: string
          description: Exact trigger name (e.g. `order_updated`)
        - in: query
          name: model_type
          schema:
            type: string
          description: Model alias from the schema (e.g. `order`) or full class name
        - in: query
          name: model_id
          schema:
            type: integer
          description: Record id
        - in: query
          name: date_from
          schema:
            type: string
            format: date-time
          description: Runs created at or after this time
        - in: query
          name: date_to
          schema:
            type: string
            format: date-time
          description: Runs created at or before this time
        - in: query
          name: is_test
          schema:
            type: boolean
          description: Only tester runs (`true`) or only non-tester runs (`false`)
      responses:
        '200':
          description: A page of runs.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: One execution of the automation engine for an event on a record.
                      properties:
                        id:
                          type: string
                          format: uuid
                        event_name:
                          type: string
                          example: order_updated
                        model_type:
                          type: string
                          description: Fully qualified model class of the record the event fired on.
                          example: App\Models\MTShipstationOrder
                        model_id:
                          type: integer
                          example: 1001
                        status:
                          type: string
                          example: completed
                        rules_evaluated:
                          type: integer
                        rules_executed:
                          type: integer
                        rules_skipped:
                          type: integer
                        rules_errored:
                          type: integer
                        started_at:
                          type: string
                          format: date-time
                          nullable: true
                        completed_at:
                          type: string
                          format: date-time
                          nullable: true
                        triggered_by:
                          nullable: true
                          description: Who or what started the run.
                        is_test:
                          type: boolean
                          description: True when the run wrote debug logs (always true for the live tester). It does not mean changes were rolled back.
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        duration_ms:
                          type: integer
                          nullable: true
                  links:
                    type: object
                    additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '500':
          description: Failed to list automation runs
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: runAutomationEvent
      tags:
        - Automations
      summary: Live-test an automation event
      description: |
        Load a saved record, fire the event against it, and return the run summary plus its full
        execution log.

        **This is not a dry run — every action commits.** Emails, HTTP calls, holds, and bills go out.
        Only rules whose status is `active` or `error` run; paused rules are skipped. The log is step
        text and a small `context` object, not a before/after diff — read the record again to see what
        changed.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model_type
                - model_id
                - event_name
              properties:
                model_type:
                  type: string
                  description: A value from `models` in the schema.
                  example: order
                model_id:
                  type: integer
                  description: The saved record's id.
                  example: 1001
                event_name:
                  type: string
                  description: 'A trigger with `manually_triggerable: true` in the schema.'
                  example: order_updated
      responses:
        '200':
          description: The run and its log.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    allOf:
                      - type: object
                        description: One execution of the automation engine for an event on a record.
                        properties:
                          id:
                            type: string
                            format: uuid
                          event_name:
                            type: string
                            example: order_updated
                          model_type:
                            type: string
                            description: Fully qualified model class of the record the event fired on.
                            example: App\Models\MTShipstationOrder
                          model_id:
                            type: integer
                            example: 1001
                          status:
                            type: string
                            example: completed
                          rules_evaluated:
                            type: integer
                          rules_executed:
                            type: integer
                          rules_skipped:
                            type: integer
                          rules_errored:
                            type: integer
                          started_at:
                            type: string
                            format: date-time
                            nullable: true
                          completed_at:
                            type: string
                            format: date-time
                            nullable: true
                          triggered_by:
                            nullable: true
                            description: Who or what started the run.
                          is_test:
                            type: boolean
                            description: True when the run wrote debug logs (always true for the live tester). It does not mean changes were rolled back.
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                          duration_ms:
                            type: integer
                            nullable: true
                      - type: object
                        properties:
                          logs:
                            type: array
                            items:
                              type: object
                              description: One step of an automation run's execution log.
                              properties:
                                id:
                                  type: integer
                                  example: 1
                                timestamp:
                                  type: string
                                  format: date-time
                                level:
                                  type: string
                                  example: SUCCESS
                                description:
                                  type: string
                                  example: Action executed
                                context:
                                  type: object
                                  additionalProperties: true
                                  nullable: true
                                  description: Small step context. Not a before/after field diff — re-read the record to see what changed.
                                step_type:
                                  type: string
                                  nullable: true
                                  example: action_executed
                                depth:
                                  type: integer
                                  nullable: true
                                rule_id:
                                  type: integer
                                  nullable: true
        '400':
          description: '`sku_mapping_completed` / `sku_mapping_failed` need extra context and cannot be fired here'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Record not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: Trigger skipped (e.g. automations disabled or pre-conditions not met)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: '`model_type` or `event_name` is not supported by the tester'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/automations/runs/{runId}':
    get:
      operationId: getAutomationRun
      tags:
        - Automations
      summary: Get an automation run
      description: |
        One run summary. Use `GET /automations/runs/{runId}/logs` for its log lines.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: runId
          required: true
          schema:
            type: string
            format: uuid
          description: Automation run ID
      responses:
        '200':
          description: The run.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: One execution of the automation engine for an event on a record.
                    properties:
                      id:
                        type: string
                        format: uuid
                      event_name:
                        type: string
                        example: order_updated
                      model_type:
                        type: string
                        description: Fully qualified model class of the record the event fired on.
                        example: App\Models\MTShipstationOrder
                      model_id:
                        type: integer
                        example: 1001
                      status:
                        type: string
                        example: completed
                      rules_evaluated:
                        type: integer
                      rules_executed:
                        type: integer
                      rules_skipped:
                        type: integer
                      rules_errored:
                        type: integer
                      started_at:
                        type: string
                        format: date-time
                        nullable: true
                      completed_at:
                        type: string
                        format: date-time
                        nullable: true
                      triggered_by:
                        nullable: true
                        description: Who or what started the run.
                      is_test:
                        type: boolean
                        description: True when the run wrote debug logs (always true for the live tester). It does not mean changes were rolled back.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      duration_ms:
                        type: integer
                        nullable: true
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Automation run not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/automations/runs/{runId}/logs':
    get:
      operationId: getAutomationRunLogs
      tags:
        - Automations
      summary: Get an automation run's log
      description: |
        Log lines for a run, oldest first. Use `after_id` to page forward (or tail a run).

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: runId
          required: true
          schema:
            type: string
            format: uuid
          description: Automation run ID
        - in: query
          name: after_id
          schema:
            type: integer
          description: Only lines with an id greater than this
        - in: query
          name: limit
          schema:
            type: integer
          description: Maximum lines to return (all when omitted)
      responses:
        '200':
          description: Log lines.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: One step of an automation run's execution log.
                      properties:
                        id:
                          type: integer
                          example: 1
                        timestamp:
                          type: string
                          format: date-time
                        level:
                          type: string
                          example: SUCCESS
                        description:
                          type: string
                          example: Action executed
                        context:
                          type: object
                          additionalProperties: true
                          nullable: true
                          description: Small step context. Not a before/after field diff — re-read the record to see what changed.
                        step_type:
                          type: string
                          nullable: true
                          example: action_executed
                        depth:
                          type: integer
                          nullable: true
                        rule_id:
                          type: integer
                          nullable: true
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Automation run not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '500':
          description: Failed to fetch automation logs
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /automations:
    get:
      operationId: getAutomations
      tags:
        - Automations
      summary: List automation rules
      description: |
        Paginated list of automation rules, newest first, each with its conditions and actions.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number
        - in: query
          name: per_page
          schema:
            type: integer
            default: 25
          description: Rules per page
      responses:
        '200':
          description: A page of rules.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: An automation rule — the same rules edited under **Automations** in the app.
                      properties:
                        id:
                          type: integer
                          example: 12
                        name:
                          type: string
                          description: 'Unique rule name, shown in the automations list.'
                          example: Note large orders
                        trigger:
                          type: string
                          description: The event that runs the rule. A `name` from `triggers` in `GET /automations/schema`.
                          example: order_updated
                        status:
                          type: string
                          enum:
                            - active
                            - paused
                            - error
                          description: Only `active` and `error` rules run. `paused` rules are skipped.
                          example: paused
                        summary:
                          type: string
                          nullable: true
                          description: Human-readable summary. Generated in the background when not supplied.
                        execution_count:
                          type: integer
                          description: 'Legacy run counter. Rule runs no longer update it, so it holds whatever value was last recorded (usually `0`).'
                          example: 0
                        last_run:
                          type: string
                          format: date-time
                          nullable: true
                          description: Legacy last-run timestamp. Rule runs no longer update it.
                        last_run_success:
                          type: boolean
                          nullable: true
                          description: Legacy last-run result. Rule runs no longer update it; a failing rule is still reported through `status` = `error`.
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                        conditions:
                          type: array
                          description: All conditions must hold for the actions to run. An empty list matches every record.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              type:
                                type: string
                                description: A `type` from `conditions` in the schema.
                                example: field
                              value:
                                description: 'Condition settings, decoded from JSON. Shape depends on `type`.'
                                nullable: true
                        actions:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              type:
                                type: string
                                description: A `type` from `actions` in the schema.
                                example: update_column
                              value:
                                description: 'Action settings, decoded from JSON. Shape depends on `type`.'
                                nullable: true
                              action_id:
                                type: integer
                                nullable: true
                  links:
                    type: object
                    additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createAutomation
      tags:
        - Automations
      summary: Create an automation rule
      description: |
        Create a rule. The trigger, condition types, and action types must be in the catalog
        (`GET /automations/schema`); values are otherwise loosely typed, apart from the engine's checks for
        `hold_order` (valid hold type) and `add_line_item` (SKU or product id, quantity > 0).

        **A new rule is `paused` when `status` is omitted** and does not run. Test it with
        `POST /automations/runs` before setting it `active` — an active rule also runs on every real
        event of its trigger.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - trigger
                - conditions
                - actions
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Unique across rules.
                  example: Note large orders
                trigger:
                  type: string
                  description: A `name` from `triggers` in `GET /automations/schema`.
                  example: order_updated
                status:
                  type: string
                  enum:
                    - active
                    - paused
                    - error
                  nullable: true
                  description: |
                    Omitted on create means `paused` (the rule does not run until activated). Omitted on update
                    leaves the current status. Set `active` only after a live test with `POST /automations/runs`.
                summary:
                  type: string
                  maxLength: 1000
                  nullable: true
                  description: 'Optional. When omitted, a summary is generated in the background.'
                conditions:
                  type: array
                  description: Required (may be empty — an empty list matches every record). Replaces the existing list on update.
                  items:
                    type: object
                    required:
                      - type
                    properties:
                      type:
                        type: string
                        description: A `type` from `conditions` in the schema.
                      value:
                        description: Condition settings. Shape depends on `type`.
                        nullable: true
                actions:
                  type: array
                  description: Required (may be empty). Replaces the existing list on update; any `id` sent is ignored.
                  items:
                    type: object
                    required:
                      - type
                    properties:
                      type:
                        type: string
                        description: A `type` from `actions` in the schema.
                      value:
                        description: Action settings. Shape depends on `type`. Whitespace in string values is preserved.
                        nullable: true
              example:
                name: Note large orders
                trigger: order_updated
                status: paused
                conditions: []
                actions:
                  - type: update_column
                    value:
                      field: customerNotes
                      value: reviewed
      responses:
        '201':
          description: Rule created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An automation rule — the same rules edited under **Automations** in the app.
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        description: 'Unique rule name, shown in the automations list.'
                        example: Note large orders
                      trigger:
                        type: string
                        description: The event that runs the rule. A `name` from `triggers` in `GET /automations/schema`.
                        example: order_updated
                      status:
                        type: string
                        enum:
                          - active
                          - paused
                          - error
                        description: Only `active` and `error` rules run. `paused` rules are skipped.
                        example: paused
                      summary:
                        type: string
                        nullable: true
                        description: Human-readable summary. Generated in the background when not supplied.
                      execution_count:
                        type: integer
                        description: 'Legacy run counter. Rule runs no longer update it, so it holds whatever value was last recorded (usually `0`).'
                        example: 0
                      last_run:
                        type: string
                        format: date-time
                        nullable: true
                        description: Legacy last-run timestamp. Rule runs no longer update it.
                      last_run_success:
                        type: boolean
                        nullable: true
                        description: Legacy last-run result. Rule runs no longer update it; a failing rule is still reported through `status` = `error`.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      conditions:
                        type: array
                        description: All conditions must hold for the actions to run. An empty list matches every record.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            type:
                              type: string
                              description: A `type` from `conditions` in the schema.
                              example: field
                            value:
                              description: 'Condition settings, decoded from JSON. Shape depends on `type`.'
                              nullable: true
                      actions:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            type:
                              type: string
                              description: A `type` from `actions` in the schema.
                              example: update_column
                            value:
                              description: 'Action settings, decoded from JSON. Shape depends on `type`.'
                              nullable: true
                            action_id:
                              type: integer
                              nullable: true
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation failed (unknown trigger/condition/action type, missing or duplicate name, invalid `hold_order` or `add_line_item` values). Nothing is saved.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/automations/{automationId}':
    parameters:
      - in: path
        name: automationId
        required: true
        schema:
          type: integer
        description: Automation rule ID
    get:
      operationId: getAutomation
      tags:
        - Automations
      summary: Get an automation rule
      description: |
        One rule with its conditions and actions. Condition and action `value` are decoded objects.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: The rule.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An automation rule — the same rules edited under **Automations** in the app.
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        description: 'Unique rule name, shown in the automations list.'
                        example: Note large orders
                      trigger:
                        type: string
                        description: The event that runs the rule. A `name` from `triggers` in `GET /automations/schema`.
                        example: order_updated
                      status:
                        type: string
                        enum:
                          - active
                          - paused
                          - error
                        description: Only `active` and `error` rules run. `paused` rules are skipped.
                        example: paused
                      summary:
                        type: string
                        nullable: true
                        description: Human-readable summary. Generated in the background when not supplied.
                      execution_count:
                        type: integer
                        description: 'Legacy run counter. Rule runs no longer update it, so it holds whatever value was last recorded (usually `0`).'
                        example: 0
                      last_run:
                        type: string
                        format: date-time
                        nullable: true
                        description: Legacy last-run timestamp. Rule runs no longer update it.
                      last_run_success:
                        type: boolean
                        nullable: true
                        description: Legacy last-run result. Rule runs no longer update it; a failing rule is still reported through `status` = `error`.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      conditions:
                        type: array
                        description: All conditions must hold for the actions to run. An empty list matches every record.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            type:
                              type: string
                              description: A `type` from `conditions` in the schema.
                              example: field
                            value:
                              description: 'Condition settings, decoded from JSON. Shape depends on `type`.'
                              nullable: true
                      actions:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            type:
                              type: string
                              description: A `type` from `actions` in the schema.
                              example: update_column
                            value:
                              description: 'Action settings, decoded from JSON. Shape depends on `type`.'
                              nullable: true
                            action_id:
                              type: integer
                              nullable: true
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Rule not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: updateAutomation
      tags:
        - Automations
      summary: Replace an automation rule
      description: |
        Replace the rule's name, trigger, summary, conditions, and actions (and status, when sent).
        **Conditions and actions are replaced wholesale** — ids in the body are ignored, so send the full
        lists you want kept. Omitting `status` leaves the current status.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - trigger
                - conditions
                - actions
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Unique across rules.
                  example: Note large orders
                trigger:
                  type: string
                  description: A `name` from `triggers` in `GET /automations/schema`.
                  example: order_updated
                status:
                  type: string
                  enum:
                    - active
                    - paused
                    - error
                  nullable: true
                  description: |
                    Omitted on create means `paused` (the rule does not run until activated). Omitted on update
                    leaves the current status. Set `active` only after a live test with `POST /automations/runs`.
                summary:
                  type: string
                  maxLength: 1000
                  nullable: true
                  description: 'Optional. When omitted, a summary is generated in the background.'
                conditions:
                  type: array
                  description: Required (may be empty — an empty list matches every record). Replaces the existing list on update.
                  items:
                    type: object
                    required:
                      - type
                    properties:
                      type:
                        type: string
                        description: A `type` from `conditions` in the schema.
                      value:
                        description: Condition settings. Shape depends on `type`.
                        nullable: true
                actions:
                  type: array
                  description: Required (may be empty). Replaces the existing list on update; any `id` sent is ignored.
                  items:
                    type: object
                    required:
                      - type
                    properties:
                      type:
                        type: string
                        description: A `type` from `actions` in the schema.
                      value:
                        description: Action settings. Shape depends on `type`. Whitespace in string values is preserved.
                        nullable: true
              example:
                name: Note large orders
                trigger: order_updated
                status: paused
                conditions: []
                actions:
                  - type: update_column
                    value:
                      field: customerNotes
                      value: reviewed
      responses:
        '200':
          description: Rule updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An automation rule — the same rules edited under **Automations** in the app.
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        description: 'Unique rule name, shown in the automations list.'
                        example: Note large orders
                      trigger:
                        type: string
                        description: The event that runs the rule. A `name` from `triggers` in `GET /automations/schema`.
                        example: order_updated
                      status:
                        type: string
                        enum:
                          - active
                          - paused
                          - error
                        description: Only `active` and `error` rules run. `paused` rules are skipped.
                        example: paused
                      summary:
                        type: string
                        nullable: true
                        description: Human-readable summary. Generated in the background when not supplied.
                      execution_count:
                        type: integer
                        description: 'Legacy run counter. Rule runs no longer update it, so it holds whatever value was last recorded (usually `0`).'
                        example: 0
                      last_run:
                        type: string
                        format: date-time
                        nullable: true
                        description: Legacy last-run timestamp. Rule runs no longer update it.
                      last_run_success:
                        type: boolean
                        nullable: true
                        description: Legacy last-run result. Rule runs no longer update it; a failing rule is still reported through `status` = `error`.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      conditions:
                        type: array
                        description: All conditions must hold for the actions to run. An empty list matches every record.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            type:
                              type: string
                              description: A `type` from `conditions` in the schema.
                              example: field
                            value:
                              description: 'Condition settings, decoded from JSON. Shape depends on `type`.'
                              nullable: true
                      actions:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            type:
                              type: string
                              description: A `type` from `actions` in the schema.
                              example: update_column
                            value:
                              description: 'Action settings, decoded from JSON. Shape depends on `type`.'
                              nullable: true
                            action_id:
                              type: integer
                              nullable: true
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Rule not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation failed. Nothing is saved.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteAutomation
      tags:
        - Automations
      summary: Delete an automation rule
      description: |
        Delete the rule and its conditions and actions.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Rule deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: Rule successfully deleted.
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Rule not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/automations/{automationId}/status':
    post:
      operationId: updateAutomationStatus
      tags:
        - Automations
      summary: Set an automation rule's status
      description: |
        Activate, pause, or mark a rule as errored. Only `active` and `error` rules run.

        When per-user permissions are enabled, the token's owner needs `automationRules.read` (the same permission as the Automations page); otherwise `403`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: automationId
          required: true
          schema:
            type: integer
          description: Automation rule ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - status
              properties:
                status:
                  type: string
                  enum:
                    - active
                    - paused
                    - error
              example:
                status: active
      responses:
        '200':
          description: The updated rule.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An automation rule — the same rules edited under **Automations** in the app.
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        description: 'Unique rule name, shown in the automations list.'
                        example: Note large orders
                      trigger:
                        type: string
                        description: The event that runs the rule. A `name` from `triggers` in `GET /automations/schema`.
                        example: order_updated
                      status:
                        type: string
                        enum:
                          - active
                          - paused
                          - error
                        description: Only `active` and `error` rules run. `paused` rules are skipped.
                        example: paused
                      summary:
                        type: string
                        nullable: true
                        description: Human-readable summary. Generated in the background when not supplied.
                      execution_count:
                        type: integer
                        description: 'Legacy run counter. Rule runs no longer update it, so it holds whatever value was last recorded (usually `0`).'
                        example: 0
                      last_run:
                        type: string
                        format: date-time
                        nullable: true
                        description: Legacy last-run timestamp. Rule runs no longer update it.
                      last_run_success:
                        type: boolean
                        nullable: true
                        description: Legacy last-run result. Rule runs no longer update it; a failing rule is still reported through `status` = `error`.
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      conditions:
                        type: array
                        description: All conditions must hold for the actions to run. An empty list matches every record.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            type:
                              type: string
                              description: A `type` from `conditions` in the schema.
                              example: field
                            value:
                              description: 'Condition settings, decoded from JSON. Shape depends on `type`.'
                              nullable: true
                      actions:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            type:
                              type: string
                              description: A `type` from `actions` in the schema.
                              example: update_column
                            value:
                              description: 'Action settings, decoded from JSON. Shape depends on `type`.'
                              nullable: true
                            action_id:
                              type: integer
                              nullable: true
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Rule not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Invalid status
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /export-templates/types:
    get:
      operationId: listExportTemplateTypes
      tags:
        - Export Templates
      summary: List export template types
      description: |
        Return the catalogue of supported template types with, for each, the render modes it
        supports, its HTML body shape, whether it can be previewed, and which document its
        `document_id` refers to during preview. Use this first when authoring a new template.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: The type catalogue.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          example: packing_slip
                        modes:
                          type: array
                          description: Render modes this type supports.
                          items:
                            type: string
                            enum:
                              - options
                              - html
                          example:
                            - options
                            - html
                        html_shape:
                          type: string
                          description: 'HTML body shape when in `html` mode: `single_body` (one `html` body plus optional `css`) for every type that supports HTML mode, `none` otherwise.'
                          enum:
                            - none
                            - single_body
                          example: single_body
                        supports_preview:
                          type: boolean
                          example: true
                        is_data_template:
                          type: boolean
                          description: Whether this is a CSV/Excel data template (not previewable).
                          example: false
                        is_label:
                          type: boolean
                          description: Whether this is a barcode label template.
                          example: false
                        document_id:
                          type: string
                          nullable: true
                          description: What the preview `document_id` refers to for this type (e.g. "Sales order id").
                          example: Sales order id
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /export-templates/authoring-guide:
    get:
      operationId: getExportTemplateAuthoringGuide
      tags:
        - Export Templates
      summary: Get the export template authoring guide
      description: |
        Return a structured JSON playbook for authoring templates: Mustache syntax notes, the
        per-type body shapes, formatter sub-keys, and what `document_id` means per type. Aimed
        at AI authors and integrators building templates end to end.

        The payload is descriptive and may grow over time — treat unknown keys as additive.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: The authoring guide.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    description: 'Structured authoring guide (syntax, shapes, formatters, `document_id_by_type`).'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /export-templates/placeholders:
    get:
      operationId: getExportTemplatePlaceholders
      tags:
        - Export Templates
      summary: List placeholders for a template type
      description: |
        Return the placeholder catalogue for an HTML-capable template `type`, grouped for
        authoring. Includes tenant custom fields. Copy exact placeholder names from here so
        they resolve at render time.

        For `packing_slip` and `sales_order`, an **Order Tags** group (`id: order_tags`) is
        included: `tags` prints the order's tag names comma-separated, `tags._info` prints the
        tag keys on that order (for debugging), and one `tags.<key>` entry is listed per tag in
        your account — use it as a section (`{{#tags.giftWrap}}…{{/tags.giftWrap}}`) to print
        text only when the order carries that tag. `<key>` is the tag name in camelCase with
        punctuation removed (e.g. "Gift Wrap" → `giftWrap`). Accounts with more than 500 tags
        get a note explaining the key format instead of the per-tag list.

        For `supplier_purchase_order`, a **Supplier Custom Fields** group is included alongside
        the order's own custom fields: one `supplier.customFields.<key>` entry per supplier
        custom field in your account, printing the value set on the PO's supplier.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: type
          required: true
          schema:
            type: string
          description: Template type to fetch placeholders for (e.g. `packing_slip`).
      responses:
        '200':
          description: Placeholder groups for the type.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    description: Placeholder groups (structure varies by type; includes tenant custom fields).
        '400':
          description: The `type` query parameter is required.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /export-templates/options-schema:
    get:
      operationId: getExportTemplateOptionsSchema
      tags:
        - Export Templates
      summary: Get the options-mode form schema
      description: |
        Return the options-mode form schema — the toggles and sections available when a
        template is authored in `options` render mode (rather than raw HTML). Pass an optional
        `type` to scope the schema to one template type.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: type
          required: false
          schema:
            type: string
          description: Optional template type to scope the schema to.
      responses:
        '200':
          description: The options-mode schema.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    description: Options-mode form schema (structure varies by type).
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /export-templates/validate:
    post:
      operationId: validateExportTemplate
      tags:
        - Export Templates
      summary: Validate an export template draft
      description: |
        Dry-run a template draft without saving. Runs the same shape rules as create/update,
        compiles the Mustache markup, and flags unknown placeholders. Returns a unified
        `{ valid, errors, warnings }` result.

        HTTP status is `200` when `valid` is `true` and `422` when `false` — the body uses the
        same shape either way. `errors` block a save; `warnings` (e.g. an unrecognized
        placeholder) do not.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - type
                - fields
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Optional template name (used only for messaging).
                type:
                  type: string
                  description: Template type to validate against.
                  example: packing_slip
                fields:
                  type: object
                  additionalProperties: true
                  description: Raw template body to validate.
            example:
              type: packing_slip
              fields:
                render_mode: html
                page:
                  size: A4
                  orientation: Portrait
                html: '<h1>Packing Slip #{{orderNumber}}</h1><table>{{#orderLines}}<tr><td>{{sku}}</td></tr>{{/orderLines}}</table><div>{{fakeField}}</div>'
      responses:
        '200':
          description: Draft is valid.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      valid:
                        type: boolean
                        description: Whether the draft passed all blocking rules and compiled cleanly.
                      errors:
                        type: array
                        description: 'Blocking problems (shape rule failures, Mustache compile errors). A save would fail while non-empty.'
                        items:
                          type: string
                      warnings:
                        type: array
                        description: 'Non-blocking advisories, such as placeholders not found in the type''s catalogue.'
                        items:
                          type: string
              example:
                data:
                  valid: true
                  errors: []
                  warnings: []
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Draft is invalid — see `errors`. Body uses the same `{ valid, errors, warnings }` shape.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      valid:
                        type: boolean
                        description: Whether the draft passed all blocking rules and compiled cleanly.
                      errors:
                        type: array
                        description: 'Blocking problems (shape rule failures, Mustache compile errors). A save would fail while non-empty.'
                        items:
                          type: string
                      warnings:
                        type: array
                        description: 'Non-blocking advisories, such as placeholders not found in the type''s catalogue.'
                        items:
                          type: string
              example:
                data:
                  valid: false
                  errors:
                    - The fields.page.size field is required when fields.render_mode is html.
                  warnings:
                    - 'Unknown placeholder {{fakeField}} in html (not in catalogue for packing_slip)'
  /export-templates/preview:
    post:
      operationId: previewDraftExportTemplate
      tags:
        - Export Templates
      summary: Preview an unsaved export template draft
      description: |
        Render an **unsaved** template draft against a live document — supply `type` and
        `fields` inline along with `document_id`. Ideal for iterating on markup before saving.

        Preview requires HTML render mode (`fields.render_mode = "html"`). CSV/`*_data` and
        label types are not previewable and return `422`.

        See `POST /export-templates/{exportTemplateId}/preview` for how `document_id` maps to a
        document by type and how `format` controls the response (JSON vs. raw PDF).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  description: |
                    Preview request. `document_id` is always required. For the draft-preview endpoint
                    (`POST /export-templates/preview`), `type` and `fields` are also required. For the
                    saved-preview endpoint (`POST /export-templates/{id}/preview`), `type`/`fields` are
                    ignored — they come from the saved template.
                  required:
                    - document_id
                  properties:
                    document_id:
                      type: integer
                      minimum: 1
                      description: ID of the live document to render against. Interpreted by template type — see the endpoint description.
                      example: 12345
                    format:
                      type: string
                      enum:
                        - html
                        - pdf
                      default: html
                      description: 'Output format. `html` returns JSON with rendered markup; `pdf` returns a PDF (binary, or base64 in JSON when `Accept: application/json`).'
                    type:
                      type: string
                      description: Template type. **Required for draft preview** (`POST /export-templates/preview`); ignored for saved preview.
                      enum:
                        - packing_slip
                        - supplier_purchase_order
                        - assembly_order
                        - invoice_pdf
                        - work_order
                        - production_run
                        - sales_order
                    fields:
                      type: object
                      additionalProperties: true
                      description: Raw template body (must be HTML render mode). **Required for draft preview**; ignored for saved preview.
                    document_kind:
                      type: string
                      enum:
                        - sales_order
                        - fulfillment_order
                        - shipment
                      default: sales_order
                      description: |
                        Which packing slip to render, and so what `document_id` names. Applies to `packing_slip`
                        only: `sales_order` (default) → sales order ID, `fulfillment_order` → fulfillment order ID,
                        `shipment` → shipment ID (a shipment of a sales order split into shipments). Any other value,
                        or a non-default kind on another template type, returns `422`.

                        A `sales_order` packing slip preview maps the whole order, cancelled lines included. The
                        exported slip omits fully cancelled lines and, for an order split into shipments, prints one
                        slip per shipment — preview those with `shipment`.
                      example: fulfillment_order
                - required:
                    - document_id
                    - type
                    - fields
            example:
              document_id: 12345
              format: html
              type: packing_slip
              fields:
                render_mode: html
                page:
                  size: A4
                  orientation: Portrait
                  highDpi: false
                html: '<h1>Packing Slip #{{orderNumber}}</h1><table><tr><th>SKU</th><th>Qty</th></tr>{{#orderLines}}<tr><td>{{sku}}</td><td>{{quantity}}</td></tr>{{/orderLines}}</table><div>{{shippingMethod}}</div>'
      responses:
        '200':
          description: 'Rendered preview. JSON for `html` (or `pdf` with `Accept: application/json`); raw PDF bytes for `pdf`.'
          content:
            application/json:
              schema:
                type: object
                description: 'JSON preview result. `html` is present for `format=html`; `pdf_base64` replaces it for `format=pdf` requested with `Accept: application/json`.'
                properties:
                  data:
                    type: object
                    properties:
                      type:
                        type: string
                        description: Resolved template type.
                        example: packing_slip
                      format:
                        type: string
                        enum:
                          - html
                          - pdf
                        example: html
                      paper_size:
                        type: string
                        nullable: true
                        description: Paper size used to render (HTML-mode paged templates).
                        example: A4
                      errors:
                        type: array
                        description: 'Render-time errors, if any (empty on a clean render).'
                        items:
                          type: string
                      html:
                        type: string
                        nullable: true
                        description: Rendered HTML. Present when `format=html`.
                      pdf_base64:
                        type: string
                        nullable: true
                        description: Base64-encoded PDF. Present when `format=pdf` and JSON is requested.
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Document not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Preview not possible or input invalid — e.g. non-HTML template, unsupported type, missing `type`/`fields`, or invalid `document_kind` (non-default kinds apply to `packing_slip` only).'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /export-templates:
    get:
      operationId: listExportTemplates
      tags:
        - Export Templates
      summary: List export templates
      description: |
        Paginated list of PDF/HTML **document export templates** for the tenant.

        This is **not** carton templates, distribution/grid templates, or Google-Sheets
        export-data field graphs — it is the `export_templates` catalog that controls how
        packing slips, invoices, work orders, and similar documents render.
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: name
          schema:
            type: string
          description: Filter to templates whose `name` contains this value (LIKE).
        - in: query
          name: type
          schema:
            type: string
          description: Filter to a single template `type` (e.g. `packing_slip`).
        - in: query
          name: types
          schema:
            type: string
          description: 'Comma-separated list of types to include (e.g. `packing_slip,invoice_pdf`).'
        - in: query
          name: id
          schema:
            type: integer
          description: Filter to a single template ID.
        - in: query
          name: is_default_template
          schema:
            type: boolean
          description: 'When `true`, return only default templates.'
      responses:
        '200':
          description: A paginated list of export templates.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A PDF/HTML **document export template** (`export_templates` table). Metadata is
                        snake_case; `fields` keys mirror the stored Manage shape so templates round-trip
                        with the admin UI (`render_mode`, `page`, `html`, `css`, etc.).
                      properties:
                        id:
                          type: integer
                          example: 4821
                        name:
                          type: string
                          example: AI Packing Slip
                        type:
                          type: string
                          description: Template type. Determines which document a template renders and its `fields` shape.
                          enum:
                            - packing_slip
                            - supplier_purchase_order
                            - supplier_purchase_order_data
                            - assembly_order
                            - rfq
                            - invoice_pdf
                            - cost_layer
                            - receiving_report
                            - receiving_report_data
                            - work_order
                            - production_run
                            - production_run_data
                            - sales_order
                            - label_product
                            - label_lot
                            - label_location
                            - label_box
                            - label_pallet
                          example: packing_slip
                        fields:
                          type: object
                          additionalProperties: true
                          description: |
                            Raw template body. Keys match Manage storage and vary by `type` and render mode:

                            - `render_mode` — `options` (form-driven) or `html` (author-supplied markup).
                            - `page` — `{ size, orientation, highDpi }` for HTML-mode paged types.
                              `size` ∈ `Letter`, `Legal`, `A4`, `A5` (plus `2x1` for `packing_slip`);
                              `orientation` ∈ `Portrait`, `Landscape`.
                            - **HTML mode** (every HTML document type: `packing_slip`, `sales_order`, `work_order`,
                              `production_run`, `assembly_order`, `supplier_purchase_order`, `invoice_pdf`):
                              a single `html` body plus optional `css`. `packing_slip` and `sales_order` also
                              accept optional `sortField` / `sortDirection` to order their lines. On the `2x1`
                              packing slip label the body prints as written.
                            - **Legacy four fragments** (`headerHtml`, `itemsHeaderHtml`, `itemRowHtml`,
                              `footerHtml`): a template saved in this shape before its type moved to the single
                              body is returned as stored and still renders, but saving in this shape is rejected.
                            - **Options mode**: `contents.sections` (an array of section descriptors).

                            Placeholders use Mustache syntax (`{{orderNumber}}`, `{{#orderLines}}…{{/orderLines}}`).
                            Call `GET /export-templates/placeholders?type=` for the exact catalogue.
                          example:
                            render_mode: html
                            page:
                              size: A4
                              orientation: Portrait
                              highDpi: false
                            html: '<h1>Packing Slip #{{orderNumber}}</h1><table><tr><th>SKU</th><th>Qty</th></tr>{{#orderLines}}<tr><td>{{sku}}</td><td>{{quantity}}</td></tr>{{/orderLines}}</table><div>{{shippingMethod}}</div>'
                            css: 'h1 { font-size: 18pt; }'
                            sortField: SKU
                            sortDirection: Ascending
                        custom_fields:
                          type: array
                          nullable: true
                          description: Tenant custom-field selections carried by the template.
                          items:
                            type: object
                            additionalProperties: true
                        invoice_fields:
                          type: array
                          nullable: true
                          description: Invoice-specific field selections (used by invoice-type templates).
                          items:
                            type: object
                            additionalProperties: true
                        is_default_template:
                          type: boolean
                          description: Whether this is the default template for its `type`.
                          example: false
                        schema_fingerprint:
                          type: string
                          nullable: true
                          description: Fingerprint of the placeholder schema the template was authored against.
                          example: a1b2c3d4
                        has_schema_drift:
                          type: boolean
                          description: '`true` when the current placeholder schema for this `type` no longer matches the template''s stored `schema_fingerprint` (the template may reference placeholders that have changed).'
                          example: false
                        created_by:
                          type: integer
                          nullable: true
                        updated_by:
                          type: integer
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createExportTemplate
      tags:
        - Export Templates
      summary: Create an export template
      description: |
        Create a PDF/HTML export template. `name`, `type`, and `fields` are required.

        The `fields` shape depends on `type` and `render_mode`. For HTML-mode paged types,
        `fields.page.size` is required and `fields.page.orientation` is required whenever a
        size is given. Discover the exact shape and valid placeholders via the meta endpoints
        and dry-run with `POST /export-templates/validate` before saving.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  description: |
                    Create/update payload for an export template. On create, `name`, `type`, and
                    `fields` are required. On update, send only the fields you intend to change.

                    `fields` keys must match the stored Manage shape for the chosen `type` — use the
                    meta endpoints (`/export-templates/types`, `/export-templates/authoring-guide`,
                    `/export-templates/placeholders`) to discover the shape and valid placeholders,
                    and `POST /export-templates/validate` to dry-run before saving.
                  properties:
                    name:
                      type: string
                      maxLength: 255
                      example: AI Packing Slip
                    type:
                      type: string
                      description: Template type (immutable in practice — determines the `fields` shape).
                      enum:
                        - packing_slip
                        - supplier_purchase_order
                        - supplier_purchase_order_data
                        - assembly_order
                        - rfq
                        - invoice_pdf
                        - cost_layer
                        - receiving_report
                        - receiving_report_data
                        - work_order
                        - production_run
                        - production_run_data
                        - sales_order
                        - label_product
                        - label_lot
                        - label_location
                        - label_box
                        - label_pallet
                      example: packing_slip
                    fields:
                      type: object
                      additionalProperties: true
                      description: |
                        Raw template body — see the `fields` description on the export template schema.

                        For HTML-mode paged types set `render_mode: "html"` and supply `page`, a single
                        `html` body (required) and an optional `css`; the legacy four fragments
                        (`headerHtml`, ...) are not accepted. For options mode set
                        `render_mode: "options"` and supply `contents.sections`.
                    custom_fields:
                      type: array
                      nullable: true
                      description: Tenant custom-field selections. Also accepted as `customFields`.
                      items:
                        type: object
                        additionalProperties: true
                    invoice_fields:
                      type: array
                      nullable: true
                      description: Invoice-specific field selections. Also accepted as `invoiceFields`.
                      items:
                        type: object
                        additionalProperties: true
                    is_default_template:
                      type: boolean
                      nullable: true
                      description: Set `true` to make this the default template for its `type`. Also accepted as `isDefaultTemplate`.
                      example: false
                - required:
                    - name
                    - type
                    - fields
            examples:
              packingSlipSingleBody:
                summary: Single-body packing slip (HTML mode)
                value:
                  name: AI Packing Slip
                  type: packing_slip
                  fields:
                    render_mode: html
                    page:
                      size: A4
                      orientation: Portrait
                      highDpi: false
                    html: '<h1>Packing Slip #{{orderNumber}}</h1><table><tr><th>SKU</th><th>Qty</th></tr>{{#orderLines}}<tr><td>{{sku}}</td><td>{{quantity}}</td></tr>{{/orderLines}}</table><div>{{shippingMethod}}</div>'
                    css: 'h1 { font-size: 18pt; }'
                    sortField: SKU
                    sortDirection: Ascending
                  is_default_template: false
              workOrderSingleBody:
                summary: Single-body work order (HTML mode)
                value:
                  name: Shop Floor WO
                  type: work_order
                  fields:
                    render_mode: html
                    page:
                      size: Letter
                      orientation: Portrait
                      highDpi: false
                    html: '<h1>{{workOrderNumber}}</h1>{{#bomComponents}}<div>{{sku}}</div>{{/bomComponents}}'
                    css: 'h1 { font-size: 18pt; }'
      responses:
        '201':
          description: Export template created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A PDF/HTML **document export template** (`export_templates` table). Metadata is
                      snake_case; `fields` keys mirror the stored Manage shape so templates round-trip
                      with the admin UI (`render_mode`, `page`, `html`, `css`, etc.).
                    properties:
                      id:
                        type: integer
                        example: 4821
                      name:
                        type: string
                        example: AI Packing Slip
                      type:
                        type: string
                        description: Template type. Determines which document a template renders and its `fields` shape.
                        enum:
                          - packing_slip
                          - supplier_purchase_order
                          - supplier_purchase_order_data
                          - assembly_order
                          - rfq
                          - invoice_pdf
                          - cost_layer
                          - receiving_report
                          - receiving_report_data
                          - work_order
                          - production_run
                          - production_run_data
                          - sales_order
                          - label_product
                          - label_lot
                          - label_location
                          - label_box
                          - label_pallet
                        example: packing_slip
                      fields:
                        type: object
                        additionalProperties: true
                        description: |
                          Raw template body. Keys match Manage storage and vary by `type` and render mode:

                          - `render_mode` — `options` (form-driven) or `html` (author-supplied markup).
                          - `page` — `{ size, orientation, highDpi }` for HTML-mode paged types.
                            `size` ∈ `Letter`, `Legal`, `A4`, `A5` (plus `2x1` for `packing_slip`);
                            `orientation` ∈ `Portrait`, `Landscape`.
                          - **HTML mode** (every HTML document type: `packing_slip`, `sales_order`, `work_order`,
                            `production_run`, `assembly_order`, `supplier_purchase_order`, `invoice_pdf`):
                            a single `html` body plus optional `css`. `packing_slip` and `sales_order` also
                            accept optional `sortField` / `sortDirection` to order their lines. On the `2x1`
                            packing slip label the body prints as written.
                          - **Legacy four fragments** (`headerHtml`, `itemsHeaderHtml`, `itemRowHtml`,
                            `footerHtml`): a template saved in this shape before its type moved to the single
                            body is returned as stored and still renders, but saving in this shape is rejected.
                          - **Options mode**: `contents.sections` (an array of section descriptors).

                          Placeholders use Mustache syntax (`{{orderNumber}}`, `{{#orderLines}}…{{/orderLines}}`).
                          Call `GET /export-templates/placeholders?type=` for the exact catalogue.
                        example:
                          render_mode: html
                          page:
                            size: A4
                            orientation: Portrait
                            highDpi: false
                          html: '<h1>Packing Slip #{{orderNumber}}</h1><table><tr><th>SKU</th><th>Qty</th></tr>{{#orderLines}}<tr><td>{{sku}}</td><td>{{quantity}}</td></tr>{{/orderLines}}</table><div>{{shippingMethod}}</div>'
                          css: 'h1 { font-size: 18pt; }'
                          sortField: SKU
                          sortDirection: Ascending
                      custom_fields:
                        type: array
                        nullable: true
                        description: Tenant custom-field selections carried by the template.
                        items:
                          type: object
                          additionalProperties: true
                      invoice_fields:
                        type: array
                        nullable: true
                        description: Invoice-specific field selections (used by invoice-type templates).
                        items:
                          type: object
                          additionalProperties: true
                      is_default_template:
                        type: boolean
                        description: Whether this is the default template for its `type`.
                        example: false
                      schema_fingerprint:
                        type: string
                        nullable: true
                        description: Fingerprint of the placeholder schema the template was authored against.
                        example: a1b2c3d4
                      has_schema_drift:
                        type: boolean
                        description: '`true` when the current placeholder schema for this `type` no longer matches the template''s stored `schema_fingerprint` (the template may reference placeholders that have changed).'
                        example: false
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error — e.g. missing `name`/`type`/`fields`, invalid `type`, or an invalid `fields` shape for the type.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/export-templates/{exportTemplateId}':
    get:
      operationId: getExportTemplateById
      tags:
        - Export Templates
      summary: Get an export template
      description: 'Get a single export template by ID, including its full raw `fields`.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: exportTemplateId
          required: true
          schema:
            type: integer
          description: Export template ID.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A PDF/HTML **document export template** (`export_templates` table). Metadata is
                      snake_case; `fields` keys mirror the stored Manage shape so templates round-trip
                      with the admin UI (`render_mode`, `page`, `html`, `css`, etc.).
                    properties:
                      id:
                        type: integer
                        example: 4821
                      name:
                        type: string
                        example: AI Packing Slip
                      type:
                        type: string
                        description: Template type. Determines which document a template renders and its `fields` shape.
                        enum:
                          - packing_slip
                          - supplier_purchase_order
                          - supplier_purchase_order_data
                          - assembly_order
                          - rfq
                          - invoice_pdf
                          - cost_layer
                          - receiving_report
                          - receiving_report_data
                          - work_order
                          - production_run
                          - production_run_data
                          - sales_order
                          - label_product
                          - label_lot
                          - label_location
                          - label_box
                          - label_pallet
                        example: packing_slip
                      fields:
                        type: object
                        additionalProperties: true
                        description: |
                          Raw template body. Keys match Manage storage and vary by `type` and render mode:

                          - `render_mode` — `options` (form-driven) or `html` (author-supplied markup).
                          - `page` — `{ size, orientation, highDpi }` for HTML-mode paged types.
                            `size` ∈ `Letter`, `Legal`, `A4`, `A5` (plus `2x1` for `packing_slip`);
                            `orientation` ∈ `Portrait`, `Landscape`.
                          - **HTML mode** (every HTML document type: `packing_slip`, `sales_order`, `work_order`,
                            `production_run`, `assembly_order`, `supplier_purchase_order`, `invoice_pdf`):
                            a single `html` body plus optional `css`. `packing_slip` and `sales_order` also
                            accept optional `sortField` / `sortDirection` to order their lines. On the `2x1`
                            packing slip label the body prints as written.
                          - **Legacy four fragments** (`headerHtml`, `itemsHeaderHtml`, `itemRowHtml`,
                            `footerHtml`): a template saved in this shape before its type moved to the single
                            body is returned as stored and still renders, but saving in this shape is rejected.
                          - **Options mode**: `contents.sections` (an array of section descriptors).

                          Placeholders use Mustache syntax (`{{orderNumber}}`, `{{#orderLines}}…{{/orderLines}}`).
                          Call `GET /export-templates/placeholders?type=` for the exact catalogue.
                        example:
                          render_mode: html
                          page:
                            size: A4
                            orientation: Portrait
                            highDpi: false
                          html: '<h1>Packing Slip #{{orderNumber}}</h1><table><tr><th>SKU</th><th>Qty</th></tr>{{#orderLines}}<tr><td>{{sku}}</td><td>{{quantity}}</td></tr>{{/orderLines}}</table><div>{{shippingMethod}}</div>'
                          css: 'h1 { font-size: 18pt; }'
                          sortField: SKU
                          sortDirection: Ascending
                      custom_fields:
                        type: array
                        nullable: true
                        description: Tenant custom-field selections carried by the template.
                        items:
                          type: object
                          additionalProperties: true
                      invoice_fields:
                        type: array
                        nullable: true
                        description: Invoice-specific field selections (used by invoice-type templates).
                        items:
                          type: object
                          additionalProperties: true
                      is_default_template:
                        type: boolean
                        description: Whether this is the default template for its `type`.
                        example: false
                      schema_fingerprint:
                        type: string
                        nullable: true
                        description: Fingerprint of the placeholder schema the template was authored against.
                        example: a1b2c3d4
                      has_schema_drift:
                        type: boolean
                        description: '`true` when the current placeholder schema for this `type` no longer matches the template''s stored `schema_fingerprint` (the template may reference placeholders that have changed).'
                        example: false
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Export template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateExportTemplate
      tags:
        - Export Templates
      summary: Update an export template
      description: |
        Update an existing export template. Send only the fields you intend to change.
        When you send `fields`, the same shape rules as create apply for the template's type.

        This endpoint also accepts `PATCH /export-templates/{exportTemplateId}`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: exportTemplateId
          required: true
          schema:
            type: integer
          description: Export template ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Create/update payload for an export template. On create, `name`, `type`, and
                `fields` are required. On update, send only the fields you intend to change.

                `fields` keys must match the stored Manage shape for the chosen `type` — use the
                meta endpoints (`/export-templates/types`, `/export-templates/authoring-guide`,
                `/export-templates/placeholders`) to discover the shape and valid placeholders,
                and `POST /export-templates/validate` to dry-run before saving.
              properties:
                name:
                  type: string
                  maxLength: 255
                  example: AI Packing Slip
                type:
                  type: string
                  description: Template type (immutable in practice — determines the `fields` shape).
                  enum:
                    - packing_slip
                    - supplier_purchase_order
                    - supplier_purchase_order_data
                    - assembly_order
                    - rfq
                    - invoice_pdf
                    - cost_layer
                    - receiving_report
                    - receiving_report_data
                    - work_order
                    - production_run
                    - production_run_data
                    - sales_order
                    - label_product
                    - label_lot
                    - label_location
                    - label_box
                    - label_pallet
                  example: packing_slip
                fields:
                  type: object
                  additionalProperties: true
                  description: |
                    Raw template body — see the `fields` description on the export template schema.

                    For HTML-mode paged types set `render_mode: "html"` and supply `page`, a single
                    `html` body (required) and an optional `css`; the legacy four fragments
                    (`headerHtml`, ...) are not accepted. For options mode set
                    `render_mode: "options"` and supply `contents.sections`.
                custom_fields:
                  type: array
                  nullable: true
                  description: Tenant custom-field selections. Also accepted as `customFields`.
                  items:
                    type: object
                    additionalProperties: true
                invoice_fields:
                  type: array
                  nullable: true
                  description: Invoice-specific field selections. Also accepted as `invoiceFields`.
                  items:
                    type: object
                    additionalProperties: true
                is_default_template:
                  type: boolean
                  nullable: true
                  description: Set `true` to make this the default template for its `type`. Also accepted as `isDefaultTemplate`.
                  example: false
            example:
              name: AI Packing Slip (v2)
              is_default_template: true
      responses:
        '200':
          description: Export template updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A PDF/HTML **document export template** (`export_templates` table). Metadata is
                      snake_case; `fields` keys mirror the stored Manage shape so templates round-trip
                      with the admin UI (`render_mode`, `page`, `html`, `css`, etc.).
                    properties:
                      id:
                        type: integer
                        example: 4821
                      name:
                        type: string
                        example: AI Packing Slip
                      type:
                        type: string
                        description: Template type. Determines which document a template renders and its `fields` shape.
                        enum:
                          - packing_slip
                          - supplier_purchase_order
                          - supplier_purchase_order_data
                          - assembly_order
                          - rfq
                          - invoice_pdf
                          - cost_layer
                          - receiving_report
                          - receiving_report_data
                          - work_order
                          - production_run
                          - production_run_data
                          - sales_order
                          - label_product
                          - label_lot
                          - label_location
                          - label_box
                          - label_pallet
                        example: packing_slip
                      fields:
                        type: object
                        additionalProperties: true
                        description: |
                          Raw template body. Keys match Manage storage and vary by `type` and render mode:

                          - `render_mode` — `options` (form-driven) or `html` (author-supplied markup).
                          - `page` — `{ size, orientation, highDpi }` for HTML-mode paged types.
                            `size` ∈ `Letter`, `Legal`, `A4`, `A5` (plus `2x1` for `packing_slip`);
                            `orientation` ∈ `Portrait`, `Landscape`.
                          - **HTML mode** (every HTML document type: `packing_slip`, `sales_order`, `work_order`,
                            `production_run`, `assembly_order`, `supplier_purchase_order`, `invoice_pdf`):
                            a single `html` body plus optional `css`. `packing_slip` and `sales_order` also
                            accept optional `sortField` / `sortDirection` to order their lines. On the `2x1`
                            packing slip label the body prints as written.
                          - **Legacy four fragments** (`headerHtml`, `itemsHeaderHtml`, `itemRowHtml`,
                            `footerHtml`): a template saved in this shape before its type moved to the single
                            body is returned as stored and still renders, but saving in this shape is rejected.
                          - **Options mode**: `contents.sections` (an array of section descriptors).

                          Placeholders use Mustache syntax (`{{orderNumber}}`, `{{#orderLines}}…{{/orderLines}}`).
                          Call `GET /export-templates/placeholders?type=` for the exact catalogue.
                        example:
                          render_mode: html
                          page:
                            size: A4
                            orientation: Portrait
                            highDpi: false
                          html: '<h1>Packing Slip #{{orderNumber}}</h1><table><tr><th>SKU</th><th>Qty</th></tr>{{#orderLines}}<tr><td>{{sku}}</td><td>{{quantity}}</td></tr>{{/orderLines}}</table><div>{{shippingMethod}}</div>'
                          css: 'h1 { font-size: 18pt; }'
                          sortField: SKU
                          sortDirection: Ascending
                      custom_fields:
                        type: array
                        nullable: true
                        description: Tenant custom-field selections carried by the template.
                        items:
                          type: object
                          additionalProperties: true
                      invoice_fields:
                        type: array
                        nullable: true
                        description: Invoice-specific field selections (used by invoice-type templates).
                        items:
                          type: object
                          additionalProperties: true
                      is_default_template:
                        type: boolean
                        description: Whether this is the default template for its `type`.
                        example: false
                      schema_fingerprint:
                        type: string
                        nullable: true
                        description: Fingerprint of the placeholder schema the template was authored against.
                        example: a1b2c3d4
                      has_schema_drift:
                        type: boolean
                        description: '`true` when the current placeholder schema for this `type` no longer matches the template''s stored `schema_fingerprint` (the template may reference placeholders that have changed).'
                        example: false
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Export template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error — e.g. an invalid `fields` shape for the type.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    patch:
      operationId: patchExportTemplate
      tags:
        - Export Templates
      summary: Update an export template (PATCH)
      description: 'Alias for `PUT /export-templates/{exportTemplateId}` — a partial update.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: exportTemplateId
          required: true
          schema:
            type: integer
          description: Export template ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Create/update payload for an export template. On create, `name`, `type`, and
                `fields` are required. On update, send only the fields you intend to change.

                `fields` keys must match the stored Manage shape for the chosen `type` — use the
                meta endpoints (`/export-templates/types`, `/export-templates/authoring-guide`,
                `/export-templates/placeholders`) to discover the shape and valid placeholders,
                and `POST /export-templates/validate` to dry-run before saving.
              properties:
                name:
                  type: string
                  maxLength: 255
                  example: AI Packing Slip
                type:
                  type: string
                  description: Template type (immutable in practice — determines the `fields` shape).
                  enum:
                    - packing_slip
                    - supplier_purchase_order
                    - supplier_purchase_order_data
                    - assembly_order
                    - rfq
                    - invoice_pdf
                    - cost_layer
                    - receiving_report
                    - receiving_report_data
                    - work_order
                    - production_run
                    - production_run_data
                    - sales_order
                    - label_product
                    - label_lot
                    - label_location
                    - label_box
                    - label_pallet
                  example: packing_slip
                fields:
                  type: object
                  additionalProperties: true
                  description: |
                    Raw template body — see the `fields` description on the export template schema.

                    For HTML-mode paged types set `render_mode: "html"` and supply `page`, a single
                    `html` body (required) and an optional `css`; the legacy four fragments
                    (`headerHtml`, ...) are not accepted. For options mode set
                    `render_mode: "options"` and supply `contents.sections`.
                custom_fields:
                  type: array
                  nullable: true
                  description: Tenant custom-field selections. Also accepted as `customFields`.
                  items:
                    type: object
                    additionalProperties: true
                invoice_fields:
                  type: array
                  nullable: true
                  description: Invoice-specific field selections. Also accepted as `invoiceFields`.
                  items:
                    type: object
                    additionalProperties: true
                is_default_template:
                  type: boolean
                  nullable: true
                  description: Set `true` to make this the default template for its `type`. Also accepted as `isDefaultTemplate`.
                  example: false
      responses:
        '200':
          description: Export template updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A PDF/HTML **document export template** (`export_templates` table). Metadata is
                      snake_case; `fields` keys mirror the stored Manage shape so templates round-trip
                      with the admin UI (`render_mode`, `page`, `html`, `css`, etc.).
                    properties:
                      id:
                        type: integer
                        example: 4821
                      name:
                        type: string
                        example: AI Packing Slip
                      type:
                        type: string
                        description: Template type. Determines which document a template renders and its `fields` shape.
                        enum:
                          - packing_slip
                          - supplier_purchase_order
                          - supplier_purchase_order_data
                          - assembly_order
                          - rfq
                          - invoice_pdf
                          - cost_layer
                          - receiving_report
                          - receiving_report_data
                          - work_order
                          - production_run
                          - production_run_data
                          - sales_order
                          - label_product
                          - label_lot
                          - label_location
                          - label_box
                          - label_pallet
                        example: packing_slip
                      fields:
                        type: object
                        additionalProperties: true
                        description: |
                          Raw template body. Keys match Manage storage and vary by `type` and render mode:

                          - `render_mode` — `options` (form-driven) or `html` (author-supplied markup).
                          - `page` — `{ size, orientation, highDpi }` for HTML-mode paged types.
                            `size` ∈ `Letter`, `Legal`, `A4`, `A5` (plus `2x1` for `packing_slip`);
                            `orientation` ∈ `Portrait`, `Landscape`.
                          - **HTML mode** (every HTML document type: `packing_slip`, `sales_order`, `work_order`,
                            `production_run`, `assembly_order`, `supplier_purchase_order`, `invoice_pdf`):
                            a single `html` body plus optional `css`. `packing_slip` and `sales_order` also
                            accept optional `sortField` / `sortDirection` to order their lines. On the `2x1`
                            packing slip label the body prints as written.
                          - **Legacy four fragments** (`headerHtml`, `itemsHeaderHtml`, `itemRowHtml`,
                            `footerHtml`): a template saved in this shape before its type moved to the single
                            body is returned as stored and still renders, but saving in this shape is rejected.
                          - **Options mode**: `contents.sections` (an array of section descriptors).

                          Placeholders use Mustache syntax (`{{orderNumber}}`, `{{#orderLines}}…{{/orderLines}}`).
                          Call `GET /export-templates/placeholders?type=` for the exact catalogue.
                        example:
                          render_mode: html
                          page:
                            size: A4
                            orientation: Portrait
                            highDpi: false
                          html: '<h1>Packing Slip #{{orderNumber}}</h1><table><tr><th>SKU</th><th>Qty</th></tr>{{#orderLines}}<tr><td>{{sku}}</td><td>{{quantity}}</td></tr>{{/orderLines}}</table><div>{{shippingMethod}}</div>'
                          css: 'h1 { font-size: 18pt; }'
                          sortField: SKU
                          sortDirection: Ascending
                      custom_fields:
                        type: array
                        nullable: true
                        description: Tenant custom-field selections carried by the template.
                        items:
                          type: object
                          additionalProperties: true
                      invoice_fields:
                        type: array
                        nullable: true
                        description: Invoice-specific field selections (used by invoice-type templates).
                        items:
                          type: object
                          additionalProperties: true
                      is_default_template:
                        type: boolean
                        description: Whether this is the default template for its `type`.
                        example: false
                      schema_fingerprint:
                        type: string
                        nullable: true
                        description: Fingerprint of the placeholder schema the template was authored against.
                        example: a1b2c3d4
                      has_schema_drift:
                        type: boolean
                        description: '`true` when the current placeholder schema for this `type` no longer matches the template''s stored `schema_fingerprint` (the template may reference placeholders that have changed).'
                        example: false
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Export template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteExportTemplate
      tags:
        - Export Templates
      summary: Delete an export template
      description: |
        Soft-delete an export template. Returns `204 No Content` on success.

        Deleting the current default template for a type is refused with `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: exportTemplateId
          required: true
          schema:
            type: integer
          description: Export template ID.
      responses:
        '204':
          description: Export template deleted. No content.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Export template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Deletion refused — e.g. the template is the default for its type.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/export-templates/{exportTemplateId}/set-default':
    post:
      operationId: setDefaultExportTemplate
      tags:
        - Export Templates
      summary: Set an export template as default
      description: |
        Make this template the default for its `type`. Any previously-default template of the
        same type is unset. Takes no request body.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: exportTemplateId
          required: true
          schema:
            type: integer
          description: Export template ID.
      responses:
        '200':
          description: Template set as default.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Successfully set as default template.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Export template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/export-templates/{exportTemplateId}/preview':
    post:
      operationId: previewSavedExportTemplate
      tags:
        - Export Templates
      summary: Preview a saved export template
      description: |
        Render a saved template against a live document and return the result. The template's
        `type` and `fields` are taken from the saved record — the body only needs `document_id`
        (and optionally `format` and, for `packing_slip`, `document_kind`).

        Each document is loaded by the same loader its export uses, so the preview shows the
        values the export prints.

        Preview requires the template to be in HTML render mode (`fields.render_mode = "html"`).
        CSV/`*_data` types and label types are not previewable and return `422`.

        **`document_id` is interpreted by template type:**

        | Type | `document_id` |
        | --- | --- |
        | `packing_slip` (`document_kind` omitted or `sales_order`), `sales_order` | Sales order ID |
        | `packing_slip` with `document_kind: fulfillment_order` | Fulfillment order ID |
        | `packing_slip` with `document_kind: shipment` | Shipment ID (a shipment of a sales order split into shipments) |
        | `invoice_pdf` | Client purchase order (invoice) ID |
        | `supplier_purchase_order` | Supplier purchase order ID |
        | `assembly_order` | Assembly order ID |
        | `work_order` | Work order ID |
        | `production_run` | Production batch ID |

        **Response format** follows `format`:
        - `html` (default) → JSON `{ data: { html, errors, paper_size, type, format } }`.
        - `pdf` → `application/pdf` binary, unless the request sends `Accept: application/json`,
          in which case JSON is returned with a base64 `pdf_base64` field instead of `html`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: exportTemplateId
          required: true
          schema:
            type: integer
          description: Export template ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Preview request. `document_id` is always required. For the draft-preview endpoint
                (`POST /export-templates/preview`), `type` and `fields` are also required. For the
                saved-preview endpoint (`POST /export-templates/{id}/preview`), `type`/`fields` are
                ignored — they come from the saved template.
              required:
                - document_id
              properties:
                document_id:
                  type: integer
                  minimum: 1
                  description: ID of the live document to render against. Interpreted by template type — see the endpoint description.
                  example: 12345
                format:
                  type: string
                  enum:
                    - html
                    - pdf
                  default: html
                  description: 'Output format. `html` returns JSON with rendered markup; `pdf` returns a PDF (binary, or base64 in JSON when `Accept: application/json`).'
                type:
                  type: string
                  description: Template type. **Required for draft preview** (`POST /export-templates/preview`); ignored for saved preview.
                  enum:
                    - packing_slip
                    - supplier_purchase_order
                    - assembly_order
                    - invoice_pdf
                    - work_order
                    - production_run
                    - sales_order
                fields:
                  type: object
                  additionalProperties: true
                  description: Raw template body (must be HTML render mode). **Required for draft preview**; ignored for saved preview.
                document_kind:
                  type: string
                  enum:
                    - sales_order
                    - fulfillment_order
                    - shipment
                  default: sales_order
                  description: |
                    Which packing slip to render, and so what `document_id` names. Applies to `packing_slip`
                    only: `sales_order` (default) → sales order ID, `fulfillment_order` → fulfillment order ID,
                    `shipment` → shipment ID (a shipment of a sales order split into shipments). Any other value,
                    or a non-default kind on another template type, returns `422`.

                    A `sales_order` packing slip preview maps the whole order, cancelled lines included. The
                    exported slip omits fully cancelled lines and, for an order split into shipments, prints one
                    slip per shipment — preview those with `shipment`.
                  example: fulfillment_order
            example:
              document_id: 12345
              format: html
      responses:
        '200':
          description: 'Rendered preview. JSON for `html` (or `pdf` with `Accept: application/json`); raw PDF bytes for `pdf`.'
          content:
            application/json:
              schema:
                type: object
                description: 'JSON preview result. `html` is present for `format=html`; `pdf_base64` replaces it for `format=pdf` requested with `Accept: application/json`.'
                properties:
                  data:
                    type: object
                    properties:
                      type:
                        type: string
                        description: Resolved template type.
                        example: packing_slip
                      format:
                        type: string
                        enum:
                          - html
                          - pdf
                        example: html
                      paper_size:
                        type: string
                        nullable: true
                        description: Paper size used to render (HTML-mode paged templates).
                        example: A4
                      errors:
                        type: array
                        description: 'Render-time errors, if any (empty on a clean render).'
                        items:
                          type: string
                      html:
                        type: string
                        nullable: true
                        description: Rendered HTML. Present when `format=html`.
                      pdf_base64:
                        type: string
                        nullable: true
                        description: Base64-encoded PDF. Present when `format=pdf` and JSON is requested.
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Document or template not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Preview not possible — e.g. non-HTML template, unsupported type, invalid `document_kind` (or a non-default `document_kind` on a non-`packing_slip` template), or invalid input.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /purchase-orders:
    get:
      operationId: getPurchaseOrders
      tags:
        - Purchase Orders
      summary: Purchase orders
      description: |
        Get a paginated list of purchase orders with optional filtering.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### String Filters
        - `order_numbers`: Purchase order numbers (alternate IDs) - searches across all order numbers
        - `public_note`: Public notes content
        - `private_note`: Private notes content
        - `tag`: Order tags

        ### Date Filters
        - `order_date`: Date the order was placed
        - `invoice_date`: Date the order was invoiced
        - `requested_ship_date`: Requested shipping date
        - `arrival_due_date`: Expected arrival date

        ### DateTime Filters
        - `created_at`: When the order was created
        - `updated_at`: When the order was last updated

        ### Numeric Filters
        - `order_quantity`: Total number of items ordered
        - `order_cost`: Base cost before tax and shipping (calculated from line items plus additional fees)
        - `total_cost`: Total cost including tax and shipping
        - `total_tax`: Tax amount
        - `total_shipping_cost`: Shipping cost
        - `total_paid`: Amount paid
        - `total_qty_ordered`: Total quantity of line items ordered (sum of `ordered_qty` from all items)
        - `total_qty_received`: Total quantity of line items received (sum of `received_qty` from all items)
        - `total_qty_remaining`: Total quantity of line items remaining to be received (ordered - received)

        ### Boolean Filters
        - `starred`: Whether the order is starred

        ### ID Filters
        - `supplier_id`: Filter by supplier
        - `warehouse_id`: Filter by warehouse
        - `location_id`: Filter by location

        ### Enum Filters
        - `order_status`: Milestone status token or numeric id (active, production_started, production_completed, in_transit, completed, draft, cancelled, deleted; `inactive` deprecated alias for completed). For example `?order_status=draft` or `?order_status=101` lists draft purchase orders.

        ### Custom Field Filters
        Purchase orders can be filtered by their custom fields, using the format
        `custom_fields.{field_label}` where `{field_label}` is the exact label of a custom field
        defined for purchase orders. Fields defined for other record types are not available here. The
        available operators depend on the custom field type:

        - **String/Dropdown fields**: `eq`, `neq`, `contains`, `notcontains`, `in`, `notin`, `set`, `notset`
        - **Number fields**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `notin`, `set`, `notset`
        - **Date fields**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `set`, `notset`

        Custom field labels may contain spaces or special characters; URL-encode them
        (e.g. spaces become `%20` or `+`).

        ## Examples
        ```
        # Find active orders with total cost over $1000
        ?order_status=active&total_cost[gt]=1000.00

        # Find starred orders from a specific supplier
        ?starred=1&supplier_id=123

        # Find orders by order number
        ?order_numbers=PO-2024-001

        # Find orders with remaining quantity greater than 0
        ?total_qty_remaining[gt]=0

        # Find recent orders with specific shipping costs
        ?total_shipping_cost=50.00&created_at[gte]=2024-10-25 00:00:00

        # Find orders by a custom field value
        ?custom_fields.Buyer[eq]=Jane
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: include_items
          schema:
            type: boolean
            default: true
          description: |
            When `false`, each purchase order omits `items` and line items are not loaded, which makes
            header-only listings much faster. Header fields (supplier, dates, payment terms, `total_cost`,
            `total_paid`, `total_due`, etc.) stay. Totals rolled up from lines (quantities, volume) are
            zero in this mode. `GET /purchase-orders/{id}` always includes items.
        - in: query
          name: order_numbers
          schema:
            type: string
          description: Filter by purchase order numbers (alternate IDs). Searches across all order numbers associated with the purchase order.
        - in: query
          name: public_note
          schema:
            type: string
          description: Filter by public note content
        - in: query
          name: private_note
          schema:
            type: string
          description: Filter by private note content
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by tags
        - in: query
          name: order_date
          schema:
            type: string
            format: date
          description: Filter by order date (YYYY-MM-DD)
        - in: query
          name: invoice_date
          schema:
            type: string
            format: date
          description: Filter by invoice date (YYYY-MM-DD)
        - in: query
          name: requested_ship_date
          schema:
            type: string
            format: date
          description: Filter by requested ship date (YYYY-MM-DD)
        - in: query
          name: arrival_due_date
          schema:
            type: string
            format: date
          description: Filter by arrival due date (YYYY-MM-DD)
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: order_quantity
          schema:
            type: number
          description: Filter by total number of items ordered
        - in: query
          name: total_qty_ordered
          schema:
            type: number
          description: Filter by total quantity of line items ordered (sum of `ordered_qty` from all items)
        - in: query
          name: total_qty_received
          schema:
            type: number
          description: Filter by total quantity of line items received
        - in: query
          name: total_qty_remaining
          schema:
            type: number
          description: Filter by total quantity of line items remaining to be received (ordered - received)
        - in: query
          name: order_cost
          schema:
            type: number
          description: Filter by order cost
        - in: query
          name: total_cost
          schema:
            type: number
          description: Filter by total cost (including tax and shipping)
        - in: query
          name: total_tax
          schema:
            type: number
          description: Filter by tax amount
        - in: query
          name: total_shipping_cost
          schema:
            type: number
          description: Filter by shipping cost
        - in: query
          name: total_paid
          schema:
            type: number
          description: Filter by amount paid
        - in: query
          name: starred
          schema:
            type: boolean
          description: Filter by starred status
        - in: query
          name: id
          schema:
            type: integer
          description: Filter by purchase order ID
        - in: query
          name: supplier_id
          schema:
            type: integer
          description: Filter by supplier ID
        - in: query
          name: warehouse_id
          schema:
            type: integer
          description: Filter by warehouse ID
        - in: query
          name: location_id
          schema:
            type: integer
          description: Filter by location ID
        - in: query
          name: order_status
          schema:
            type: string
            enum:
              - active
              - production_started
              - production_completed
              - in_transit
              - completed
              - draft
              - cancelled
              - deleted
              - inactive
          description: |
            Filter by milestone status token or numeric id (e.g. `101` for draft).
            `inactive` is a deprecated alias for `completed`.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the purchase order
                        order_numbers:
                          type: array
                          description: List of purchase order numbers
                          items:
                            type: string
                        created_by:
                          type: integer
                          nullable: true
                          description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                          example: 12
                        created_by_name:
                          type: string
                          nullable: true
                          description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                          example: Pat Buyer
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the purchase order was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the purchase order was last updated
                        order_status:
                          type: string
                          nullable: true
                          description: 'Current milestone status token (active, production_started, production_completed, in_transit, completed, draft, cancelled, deleted). A purchase order deleted in the app or via the API always reads as `deleted`.'
                        order_status_id:
                          type: integer
                          description: Current milestone status id (the deleted status id for any deleted purchase order)
                        order_status_date:
                          type: string
                          format: date-time
                          nullable: true
                          description: Date of the current milestone on the PO header
                        statuses:
                          type: array
                          description: Read-only milestone timeline from mt_purchase_order_status
                          items:
                            type: object
                            properties:
                              status:
                                type: string
                                nullable: true
                              status_id:
                                type: integer
                              date:
                                type: string
                                format: date-time
                                nullable: true
                              remarks:
                                type: string
                                nullable: true
                        order_date:
                          type: string
                          format: date
                          description: Date when the purchase order was created
                        invoice_date:
                          type: string
                          format: date
                          description: Date when the purchase order was invoiced
                        arrival_due_date:
                          type: string
                          format: date
                          nullable: true
                          description: Expected arrival date for the order
                        requested_ship_date:
                          type: string
                          format: date
                          nullable: true
                          description: Requested shipping date
                        original_arrival_due_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                        shipment_type:
                          type: string
                          nullable: true
                          enum:
                            - Air
                            - Sea
                            - Road
                            - Rail
                            - Express
                            - null
                          description: Freight mode used by the Transit Time Matrix. Null when unset.
                        override_transit_days:
                          type: integer
                          nullable: true
                          description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                        order_type:
                          type: integer
                          description: Type of the order
                        incoterm:
                          type: string
                          description: International Commercial Terms for the order
                        tracking_info:
                          type: string
                          nullable: true
                          description: Tracking information for the order
                        payment_terms:
                          type: string
                          description: Payment terms for the order
                        supplier_id:
                          type: integer
                          description: ID of the supplier
                        item_count:
                          type: integer
                          description: Number of unique items in the order
                        total_qty_ordered:
                          type: number
                          format: float
                          description: Total quantity of line items ordered
                        total_qty_received:
                          type: number
                          format: float
                          description: Total quantity of line items received
                        total_qty_remaining:
                          type: number
                          format: float
                          description: Total quantity of line items remaining to be received (ordered - received)
                        receipt_status:
                          type: string
                          nullable: true
                          enum:
                            - awaiting_shipment
                            - partially_received
                            - fully_received
                          description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                        currency_code:
                          type: string
                          nullable: true
                          description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                          example: EUR
                        exchange_rate:
                          type: number
                          format: float
                          nullable: true
                          description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                          example: 1.085
                        order_cost:
                          type: number
                          format: float
                          description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                        total_tax:
                          type: number
                          format: float
                          description: Total tax amount
                        total_shipping_cost:
                          type: number
                          format: float
                          description: Total shipping cost
                        total_cost:
                          type: number
                          format: float
                          description: Total cost including tax and shipping
                        total_paid:
                          type: number
                          format: float
                          description: Total amount paid
                        total_due:
                          type: number
                          format: float
                          description: Total amount due
                        down_payment:
                          type: number
                          format: float
                          description: Down payment amount
                        public_note:
                          type: string
                          nullable: true
                          description: Public notes
                        private_note:
                          type: string
                          nullable: true
                          description: Private notes
                        starred:
                          type: boolean
                          description: Whether the order is starred
                        items:
                          type: array
                          description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this list endpoint the per-line `allocations` array is always empty.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Line item ID
                              purchase_order_id:
                                type: integer
                                description: ID of the parent purchase order
                              created_at:
                                type: string
                                format: date-time
                                description: Creation timestamp
                              updated_at:
                                type: string
                                format: date-time
                                description: Last update timestamp
                              quantity:
                                type: number
                                format: float
                                description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                              presentment_unit_price:
                                type: number
                                format: float
                                nullable: true
                                description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                              unit_price:
                                type: number
                                format: float
                                description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                              unit:
                                type: string
                                nullable: true
                                description: Unit of measure
                              tax:
                                type: number
                                format: float
                                description: Tax amount
                              discount_amount:
                                type: number
                                format: float
                                description: Discount amount
                              line_total:
                                type: number
                                format: float
                                description: Total for this line item
                              expected_ship_date:
                                type: string
                                format: date
                                nullable: true
                                description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                              expected_arrival_date:
                                type: string
                                format: date
                                nullable: true
                                description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                              requested_ship_date:
                                type: string
                                format: date
                                nullable: true
                                description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                              arrival_due_date:
                                type: string
                                format: date
                                nullable: true
                                description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                              shipment_type:
                                type: string
                                nullable: true
                                enum:
                                  - Air
                                  - Sea
                                  - Road
                                  - Rail
                                  - Express
                                  - null
                                description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                              original_arrival_due_date:
                                type: string
                                format: date
                                nullable: true
                                description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                              override_transit_days:
                                type: integer
                                nullable: true
                                description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                              quantity_received:
                                type: number
                                format: float
                                description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                              received_quantity:
                                type: number
                                format: float
                                deprecated: true
                                description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                              quantity_ordered:
                                type: number
                                format: float
                                description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                              quantity_shipped:
                                type: number
                                format: float
                                description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                              quantity_billed:
                                type: number
                                format: float
                                description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                              quantity_allocated:
                                type: number
                                format: float
                                description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                              quantity_released:
                                type: number
                                format: float
                                description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                              under_covered_quantity:
                                type: number
                                format: float
                                description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                              remaining_to_ship:
                                type: number
                                format: float
                                description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                              remaining_to_receive:
                                type: number
                                format: float
                                description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                              open_quantity:
                                type: number
                                format: float
                                description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                                example: 40
                              closed_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                                example: null
                              close_reason:
                                type: string
                                nullable: true
                                description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                                example: null
                              available_to_allocate:
                                type: number
                                format: float
                                description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                              volume_cbm:
                                type: number
                                format: float
                                description: |
                                  Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                  (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                  container-fill summary.
                              line_volume_cbm:
                                type: number
                                format: float
                                description: |
                                  This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                              weight_kg:
                                type: number
                                format: float
                                description: |
                                  Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                  container-fill summary.
                              line_weight_kg:
                                type: number
                                format: float
                                description: |
                                  This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                              allocations:
                                type: array
                                description: |
                                  Which sales orders currently hold the allocation on this line. Only populated on the
                                  single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                  array on the list endpoint and for non-allocated lines.
                                items:
                                  type: object
                                  properties:
                                    sales_order_id:
                                      type: integer
                                      description: ID of the sales order holding the allocation
                                    sales_order_number:
                                      type: string
                                      nullable: true
                                      description: Human-readable sales order number
                                    quantity_allocated:
                                      type: number
                                      format: float
                                      description: Open quantity this sales order has pegged to the line
                                    quantity_released:
                                      type: number
                                      format: float
                                      description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                    peg_ids:
                                      type: array
                                      items:
                                        type: integer
                                      description: |
                                        IDs of the pegs backing this allocation. Pass these to
                                        `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                        allocation made through the API. Allocate, read the peg ids back from
                                        `GET /purchase-orders/{id}`, then reverse them.
                              source_sku:
                                type: string
                                nullable: true
                                description: Source SKU from the supplier
                              product:
                                type: object
                                nullable: true
                                description: Associated product information
                                properties:
                                  id:
                                    type: integer
                                    description: Product ID
                                  name:
                                    type: string
                                    description: Product name
                                  description:
                                    type: string
                                    nullable: true
                                    description: Product description
                                  retail_price:
                                    type: number
                                    format: float
                                    description: Product retail price
                                  wholesale_price:
                                    type: number
                                    format: float
                                    description: Product wholesale price
                                  unit_cost:
                                    type: number
                                    format: float
                                    description: Product unit cost
                                  product_weight:
                                    type: number
                                    format: float
                                    description: Product weight
                                  product_length:
                                    type: number
                                    format: float
                                    description: Product length (in inches)
                                  product_width:
                                    type: number
                                    format: float
                                    description: Product width (in inches)
                                  product_height:
                                    type: number
                                    format: float
                                    description: Product height (in inches)
                                  sellable:
                                    type: boolean
                                    description: Whether the product is sellable
                                  discontinued:
                                    type: boolean
                                    description: Whether the product is discontinued
                                  image_url:
                                    type: string
                                    nullable: true
                                    description: Product image URL
                                  variant_attributes:
                                    type: object
                                    nullable: true
                                    description: Product variant attributes
                                  sku:
                                    type: string
                                    description: Product internal SKU
                                  upc:
                                    type: string
                                    description: Product UPC/Barcode
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Product creation timestamp
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Product last update timestamp
                              base_unit_of_measure:
                                type: object
                                nullable: true
                                description: Base unit of measure
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  abbreviation:
                                    type: string
                              ordered_unit_of_measure:
                                type: object
                                nullable: true
                                description: Ordered unit of measure
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  abbreviation:
                                    type: string
                              lot:
                                type: object
                                nullable: true
                                description: Product lot information
                                properties:
                                  id:
                                    type: integer
                                  lot_number:
                                    type: string
                                  expiration_date:
                                    type: string
                                    format: date
                                    nullable: true
                        supplier:
                          type: object
                          properties:
                            id:
                              type: integer
                            status:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                            street_address:
                              type: string
                            city:
                              type: string
                            state:
                              type: string
                            zip:
                              type: string
                            country:
                              type: string
                            contact_name:
                              type: string
                            contact_email:
                              type: string
                            contact_phone:
                              type: string
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                        payments:
                          type: array
                          description: Array of payments for this purchase order
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the payment
                              payment_date:
                                type: string
                                format: date
                                description: Date of the payment
                              payment_type:
                                type: string
                                enum:
                                  - cash
                                  - credit_card
                                  - debit_card
                                  - check
                                  - bank_transfer
                                description: Type of payment
                              paid_amount:
                                type: number
                                format: float
                                description: Amount paid
                              remarks:
                                type: string
                                nullable: true
                                description: Payment remarks or notes
                              external_id:
                                type: string
                                nullable: true
                                description: External payment reference ID
                              created_by:
                                type: object
                                description: User who created the payment
                                properties:
                                  id:
                                    type: integer
                                    description: User ID
                                  name:
                                    type: string
                                    nullable: true
                                    description: User full name
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the payment was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the payment was last updated
                        ship_to:
                          type: object
                          nullable: true
                          description: Shipping address information
                          properties:
                            address_1:
                              type: string
                              nullable: true
                              description: Primary street address
                            address_2:
                              type: string
                              nullable: true
                              description: Secondary address line
                            city:
                              type: string
                              nullable: true
                              description: City name
                            state:
                              type: string
                              nullable: true
                              description: State or province
                            zip:
                              type: string
                              nullable: true
                              description: ZIP or postal code
                            country:
                              type: string
                              nullable: true
                              description: Country name
                            default_ship_to_address:
                              type: string
                              enum:
                                - ship_to_address
                                - warehouse
                              nullable: true
                              description: Default shipping address preference
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                        location_id:
                          type: integer
                          nullable: true
                          description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                        warehouse:
                          type: object
                          nullable: true
                          description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        location:
                          type: object
                          nullable: true
                          description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        tags:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              icon:
                                type: string
                                nullable: true
                              color:
                                type: string
                                nullable: true
                        fulfillment_orders:
                          type: array
                          description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              order_number:
                                type: string
                                nullable: true
                              order_status:
                                type: string
                                nullable: true
                        custom_fields:
                          type: object
                          description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createPurchaseOrder
      tags:
        - Purchase Orders
      summary: Create a new purchase order
      description: |
        Create a new purchase order with items, payments, and optional metadata.

        ## Key Features
        - Create orders with multiple line items
        - Support for both product ID and SKU lookup for items
        - Automatic product name and details population
        - Optional payments - can include payments when creating the order
        - Optional shipping address (`ship_to`) information
        - Optional custom fields and tags at both order and order item level
        - Automatic total calculation from line items plus tax/shipping
        - Stock count updates - incoming quantities are automatically updated

        ## Product Identification
        For each line item, you must provide either:
        - `product_id`: The internal product ID
        - `sku`: The product SKU (supports both internal SKU and alternate SKUs)

        ## Inventory-Tracked Products Only
        Every line item must reference an inventory-tracked product (type `PRODUCT` or `KIT`).
        Non-inventory items (e.g. service or fee SKUs) are rejected with a `422` on
        `items.{index}.product` — record those charges as an extra cost on the purchase order instead.

        ## Order Status Values
        Valid order statuses include: `active`, `completed`, `deleted`
        Defaults to `active` if not provided.

        ## Total Calculation
        The order cost (`order_cost`) is automatically calculated as:
        `sum of (item quantities × unit prices) + additional fees`

        Additional fees are the PO's persisted extra costs, including fees added automatically
        by matching cost rules (e.g. tariffs) when the order is saved. If a save adds or removes
        a cost-rule fee, `order_cost`, `total_cost`, and `total_due` move by that amount.

        The order total (`total_cost`) is automatically calculated as:
        `order_cost + total_tax + total_shipping_cost`

        Note: `order_cost`, `total_cost`, `total_paid`, and `total_due` are calculated automatically 
        on the backend and cannot be edited directly.

        ## Payments
        If `payments` array is provided, it replaces all existing payments for the order.
        Totals are automatically recalculated after payments are updated.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - order_date
                - supplier_id
                - items
              properties:
                order_date:
                  type: string
                  format: date
                  description: Date when the purchase order was created (YYYY-MM-DD)
                  example: '2024-01-15'
                supplier_id:
                  type: integer
                  description: ID of the supplier
                  example: 123
                warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the warehouse
                  example: 1
                location_id:
                  type: integer
                  nullable: true
                  description: ID of the location
                  example: 1
                order_status:
                  oneOf:
                    - type: string
                      enum:
                        - active
                        - production_started
                        - production_completed
                        - in_transit
                        - completed
                        - draft
                        - cancelled
                        - deleted
                    - type: integer
                      enum:
                        - 1
                        - 20
                        - 40
                        - 50
                        - 99
                        - 101
                        - 100
                        - -1
                  nullable: true
                  default: active
                  description: |
                    Milestone status (token or numeric id). Also accepts 30 (production_active) and 88 (delivered) by id.
                    Writes a milestone row and updates the PO header.

                    `draft` (101) and `cancelled` (100) are order states, not timeline milestones. They do not
                    count as incoming stock and the purchase order cannot take a new receipt while in either state.
                    Creating a purchase order with `order_status: draft` saves it as a draft from the start, so its
                    lines never post incoming. Moving it to an open milestone later posts incoming at that point.
                  example: active
                order_numbers:
                  type: array
                  nullable: true
                  description: Array of purchase order numbers used to identify the purchase order across various systems
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - PO-2024-001
                    - SUPPLIER-PO-123
                invoice_date:
                  type: string
                  format: date
                  nullable: true
                  description: Date when the purchase order was invoiced (YYYY-MM-DD)
                  example: '2024-01-16'
                incoterm:
                  type: string
                  nullable: true
                  description: 'Incoterm (delivery term) for the purchase order, given as a logistic code configured for the account (e.g. `exw`, `fob`, `ddp`). Matching is case-insensitive — both the lower-case code (`exw`) and its upper-case label (`EXW`) are accepted. Returned on the purchase order resource as `incoterm`. If omitted, the account default is applied.'
                  example: exw
                payment_terms:
                  type: string
                  nullable: true
                  description: 'Payment terms for the purchase order. Must exactly match one of the payment terms configured for the account (Manage > Suppliers); matching is case-sensitive (`Net 30` passes where `net 30` fails). Returned on the purchase order resource as `payment_terms`. If omitted, the account default is applied.'
                  example: Net 30
                currency_code:
                  type: string
                  nullable: true
                  minLength: 3
                  maxLength: 3
                  description: |
                    The purchase order's supplier currency: a three-letter code, in any case, listed by
                    `GET /currency/available`. `null` puts the purchase order in base currency. Sending your base
                    currency code explicitly also puts it in base currency, but stores the code (rate `1`) so responses
                    return it instead of `null`.
                    On create, omitting it applies the supplier's default currency (base currency when the supplier has
                    none). On update, omit to leave the currency and rate unchanged. Costs and totals stay in base currency.

                    Changing the currency restates `presentment_unit_price` at the new rate on every line the request
                    does not price (`unit_price` and costs do not change). Responds `422` on `currency_code` when the code
                    is unknown or no rate exists on or before `order_date` (send `exchange_rate` to supply one).
                  example: EUR
                exchange_rate:
                  type: number
                  nullable: true
                  minimum: 1.e-8
                  maximum: 9999999999
                  description: |
                    Base-currency units per 1 unit of `currency_code`. Requires `currency_code`. If omitted, the rate on or
                    before `order_date` is used. While the currency stays the same on update, the stored rate is kept and
                    a different value here is ignored.
                  example: 1.085
                total_shipping_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  default: 0
                  description: Total shipping cost
                  example: 50
                total_tax:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  default: 0
                  description: Total tax amount
                  example: 80
                volume_target_cbm:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Target container volume in cubic metres (the container-fill gauge's denominator). When set, the
                    purchase-order response reports `volume_remaining_cbm` and `volume_fill_percent` against it.
                  example: 67
                public_note:
                  type: string
                  nullable: true
                  description: Public notes visible to suppliers
                  example: Please ship via express delivery
                private_note:
                  type: string
                  nullable: true
                  description: Internal private notes
                  example: Rush order - expedite processing
                requested_ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: Requested shipping date (YYYY-MM-DD)
                  example: '2024-01-20'
                arrival_due_date:
                  type: string
                  format: date
                  nullable: true
                  description: Expected arrival date (YYYY-MM-DD)
                  example: '2024-01-25'
                shipment_type:
                  type: string
                  nullable: true
                  enum:
                    - Air
                    - Sea
                    - Road
                    - Rail
                    - Express
                    - null
                  description: |
                    Freight mode used by the Transit Time Matrix. Matching is case-insensitive — `sea` and `SEA` are
                    stored as `Sea` — but any other value returns `422`. On update, omit to keep the stored value or send
                    `null` to clear it.

                    When a request sends `shipment_type` or `override_transit_days` and the PO has a warehouse, the
                    Original ETA (`original_arrival_due_date`) and current ETA (`arrival_due_date`) are filled from the
                    transit matrix if empty. Arrival dates sent in the same request are always kept as sent.

                    When the PO has no `requested_ship_date`, the count starts from today, unless the account's
                    `transit_eta_requires_ship_date` setting is on (off by default). Then both dates stay empty until the
                    PO has a requested ship date, and a `PUT /purchase-orders/{id}` that sends `requested_ship_date` to a
                    PO that already has a freight mode or override fills them while they are empty, even without
                    `shipment_type` or `override_transit_days` in the request. Transfer POs are not affected.
                  example: Sea
                original_arrival_due_date:
                  type: string
                  format: date
                  nullable: true
                  description: |
                    Frozen Original ETA (YYYY-MM-DD) — the arrival date as first planned, kept separate from the current
                    `arrival_due_date`. On update, omit to keep the stored value or send `null` to clear it.
                  example: '2024-01-25'
                override_transit_days:
                  type: integer
                  minimum: 0
                  maximum: 3650
                  nullable: true
                  description: |
                    Manual override of the transit-matrix calendar days used to derive the arrival date. `0` is allowed.
                    On update, omit to keep the stored value or send `null` to clear it.
                  example: 35
                ship_to:
                  type: object
                  nullable: true
                  description: Shipping address information
                  properties:
                    address_1:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Primary street address
                      example: 123 Main Street
                    address_2:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: 'Secondary address line (apt, suite, etc.)'
                      example: Suite 100
                    city:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: City name
                      example: Anytown
                    state:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: State or province
                      example: CA
                    zip:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: ZIP or postal code
                      example: '90210'
                    country:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Country name
                      example: United States
                    default_ship_to_address:
                      type: string
                      enum:
                        - ship_to_address
                        - warehouse
                      nullable: true
                      description: Default shipping address preference
                      example: warehouse
                items:
                  type: array
                  minItems: 1
                  description: Array of line items for the purchase order
                  items:
                    type: object
                    required:
                      - quantity
                    properties:
                      id:
                        type: integer
                        nullable: true
                        description: Line item ID (only used for updates)
                        example: 456
                      product_id:
                        type: integer
                        nullable: true
                        description: ID of the product (required if sku not provided)
                        example: 123
                      sku:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: SKU of the product (required if product_id not provided)
                        example: WIDGET-001
                      quantity:
                        type: number
                        format: float
                        minimum: 0.001
                        description: Quantity of the item ordered
                        example: 10.5
                      unit_price:
                        type: number
                        format: float
                        description: |
                          Price per unit, always in **base currency**. Required unless `presentment_unit_price` is sent.
                          On a foreign-currency purchase order, `presentment_unit_price` becomes this price divided by the
                          exchange rate. Do not send a supplier-currency amount here.
                        example: 49.99
                      presentment_unit_price:
                        type: number
                        format: float
                        nullable: true
                        minimum: 0
                        maximum: 99999999999
                        description: |
                          The line price in the purchase order's supplier currency, per ordered unit. `unit_price` becomes
                          this price times the exchange rate, and wins if both are sent. Without `unit_price`, a
                          base-currency purchase order responds `422` on this field.
                        example: 46
                      ordered_qty:
                        type: number
                        format: float
                        minimum: 0.001
                        nullable: true
                        description: Ordered quantity in base unit of measure (calculated automatically if not provided)
                        example: 10.5
                      received_qty:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        default: 0
                        description: Quantity already received
                        example: 5
                      expected_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Per-line expected ship date override. When omitted or null, the line inherits the purchase order''s header `requested_ship_date`.'
                        example: '2026-08-15'
                      expected_arrival_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Per-line expected arrival date override. When omitted or null, the line inherits the purchase order''s header `arrival_due_date`.'
                        example: '2026-08-20'
                      lot_id:
                        type: integer
                        nullable: true
                        description: ID of the product lot
                        example: 789
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number for the received item (used when the product has lot tracking enabled).
                        example: LOT-12345
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
                      uom_id:
                        type: integer
                        nullable: true
                        description: 'ID of the unit of measure for the item. If omitted, a default is resolved automatically in priority order: the product''s default purchase unit, then its default selling unit, then the base unit of its unit class, then the account''s base unit. If no unit of measure is supplied and no default can be resolved, the request fails with a 422 error.'
                        example: 1
                      source_sku:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Source SKU from the supplier
                        example: SUPPLIER-SKU-123
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with this line item
                        items:
                          type: string
                          maxLength: 255
                        example:
                          - priority
                          - fragile
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for this line item
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: boolean
                        example:
                          Lot Number: LOT-12345
                          Expiry Date: '2024-12-31'
                payments:
                  type: array
                  nullable: true
                  description: |
                    Array of payments for this purchase order. If provided, replaces all existing payments.
                    Totals are automatically recalculated after payments are updated.
                  items:
                    type: object
                    required:
                      - payment_date
                      - payment_type
                      - paid_amount
                    properties:
                      payment_date:
                        type: string
                        format: date
                        description: Date of the payment (YYYY-MM-DD)
                        example: '2024-01-15'
                      payment_type:
                        type: string
                        enum:
                          - cash
                          - credit_card
                          - debit_card
                          - check
                          - bank_transfer
                        description: Type of payment
                        example: check
                      paid_amount:
                        type: number
                        format: float
                        minimum: 0.01
                        description: Amount paid
                        example: 500
                      remarks:
                        type: string
                        maxLength: 1000
                        nullable: true
                        description: Payment remarks or notes
                        example: 'Check #1234'
                      external_id:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: External payment reference ID
                        example: PAY-EXT-12345
                custom_fields:
                  type: object
                  nullable: true
                  description: Custom field values for the purchase order
                  additionalProperties:
                    oneOf:
                      - type: string
                      - type: number
                      - type: boolean
                  example:
                    Customer PO: PO-98765
                    Priority Level: High
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the purchase order
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - urgent
                    - priority
                    - rush-order
            examples:
              minimal_order:
                summary: Minimal required fields
                description: A basic purchase order with only required fields
                value:
                  order_date: '2024-01-15'
                  supplier_id: 123
                  items:
                    - product_id: 456
                      quantity: 10
                      unit_price: 49.99
              complete_order:
                summary: Complete order with all fields
                description: A comprehensive purchase order demonstrating all available fields
                value:
                  order_date: '2024-01-15'
                  supplier_id: 123
                  warehouse_id: 1
                  location_id: 1
                  order_status: active
                  order_numbers:
                    - PO-2024-001
                    - SUPPLIER-PO-123
                  invoice_date: '2024-01-16'
                  incoterm: exw
                  payment_terms: Net 30
                  total_shipping_cost: 50
                  total_tax: 80
                  public_note: Please ship via express delivery
                  private_note: Rush order - expedite processing
                  requested_ship_date: '2024-01-20'
                  arrival_due_date: '2024-01-25'
                  ship_to:
                    address_1: 123 Main Street
                    address_2: Suite 100
                    city: Anytown
                    state: CA
                    zip: '90210'
                    country: United States
                    default_ship_to_address: warehouse
                  items:
                    - product_id: 456
                      quantity: 10
                      unit_price: 49.99
                      ordered_qty: 10
                      received_qty: 0
                      uom_id: 1
                      source_sku: SUPPLIER-SKU-123
                      tags:
                        - priority
                        - fragile
                      custom_fields:
                        Lot Number: LOT-12345
                    - sku: WIDGET-001
                      quantity: 5
                      unit_price: 29.99
                      lot_id: 789
                  payments:
                    - payment_date: '2024-01-15'
                      payment_type: check
                      paid_amount: 500
                      remarks: 'Check #1234'
                      external_id: PAY-EXT-12345
                  custom_fields:
                    Customer PO: PO-98765
                    Priority Level: High
                  tags:
                    - urgent
                    - priority
                    - rush-order
      responses:
        '201':
          description: Purchase order created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '400':
          description: Bad request - validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Unprocessable entity - validation error (e.g. a line item references a non-inventory product)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /purchase-orders/bulk:
    post:
      operationId: bulkCreatePurchaseOrders
      tags:
        - Purchase Orders
      summary: Bulk create purchase orders
      description: |
        Create up to 100 purchase orders in one request. Each element of `purchase_orders` is the same object
        as `POST /purchase-orders` and is
        validated and created on its own, in the order given.

        ## Partial success
        A well-formed request returns `200` even when some or all elements fail. Each element gets one slot
        in `data`, identified by its `index` in the request array:
        - **Created:** `index`, `id` and `order_numbers`.
        - **Failed:** `index` and `error`, that element's validation messages keyed by field.

        A missing, non-array or empty `purchase_orders`, or more than 100 elements, returns `422` and creates
        nothing.

        There is no all-or-nothing transaction: purchase orders created before a failing element are kept,
        and a failure after an element's header is saved can leave that purchase order in place while its
        slot reports an error.

        ## Things to send on every element
        - **`order_status`**: elements without it are created as **active** and post incoming stock, the same
          as the single create. Send `order_status: "draft"` for purchase orders that should stay drafts.
        - **`currency_code`** when the purchase order should not be in the supplier's default currency.
          Omitted, the supplier's default currency is applied (base currency when the supplier has none).

        ## Retries and idempotency
        Accepts an optional `Idempotency-Key` header. A retry with the same key and body replays the first
        response (with an `Idempotent-Replay: true` header); the same key with a different body, or while
        the first request is still running, returns `409`. Keys are kept for 24 hours and are scoped to your
        API token. Order numbers are not unique, so a retry without a key can create duplicate purchase orders.

        Limited to 30 requests per minute.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: |
            Optional idempotency token. A retry with the same key and body replays the original stored
            response instead of creating the purchase orders again. Reusing the key with a different body
            returns `409`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - purchase_orders
              properties:
                purchase_orders:
                  type: array
                  minItems: 1
                  maxItems: 100
                  description: Purchase orders to create. Each element is validated with the same rules as `POST /purchase-orders`.
                  items:
                    type: object
                    required:
                      - order_date
                      - supplier_id
                      - items
                    properties:
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created (YYYY-MM-DD)
                        example: '2024-01-15'
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                        example: 123
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse
                        example: 1
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the location
                        example: 1
                      order_status:
                        oneOf:
                          - type: string
                            enum:
                              - active
                              - production_started
                              - production_completed
                              - in_transit
                              - completed
                              - draft
                              - cancelled
                              - deleted
                          - type: integer
                            enum:
                              - 1
                              - 20
                              - 40
                              - 50
                              - 99
                              - 101
                              - 100
                              - -1
                        nullable: true
                        default: active
                        description: |
                          Milestone status (token or numeric id). Also accepts 30 (production_active) and 88 (delivered) by id.
                          Writes a milestone row and updates the PO header.

                          `draft` (101) and `cancelled` (100) are order states, not timeline milestones. They do not
                          count as incoming stock and the purchase order cannot take a new receipt while in either state.
                          Creating a purchase order with `order_status: draft` saves it as a draft from the start, so its
                          lines never post incoming. Moving it to an open milestone later posts incoming at that point.
                        example: active
                      order_numbers:
                        type: array
                        nullable: true
                        description: Array of purchase order numbers used to identify the purchase order across various systems
                        items:
                          type: string
                          maxLength: 255
                        example:
                          - PO-2024-001
                          - SUPPLIER-PO-123
                      invoice_date:
                        type: string
                        format: date
                        nullable: true
                        description: Date when the purchase order was invoiced (YYYY-MM-DD)
                        example: '2024-01-16'
                      incoterm:
                        type: string
                        nullable: true
                        description: 'Incoterm (delivery term) for the purchase order, given as a logistic code configured for the account (e.g. `exw`, `fob`, `ddp`). Matching is case-insensitive — both the lower-case code (`exw`) and its upper-case label (`EXW`) are accepted. Returned on the purchase order resource as `incoterm`. If omitted, the account default is applied.'
                        example: exw
                      payment_terms:
                        type: string
                        nullable: true
                        description: 'Payment terms for the purchase order. Must exactly match one of the payment terms configured for the account (Manage > Suppliers); matching is case-sensitive (`Net 30` passes where `net 30` fails). Returned on the purchase order resource as `payment_terms`. If omitted, the account default is applied.'
                        example: Net 30
                      currency_code:
                        type: string
                        nullable: true
                        minLength: 3
                        maxLength: 3
                        description: |
                          The purchase order's supplier currency: a three-letter code, in any case, listed by
                          `GET /currency/available`. `null` puts the purchase order in base currency. Sending your base
                          currency code explicitly also puts it in base currency, but stores the code (rate `1`) so responses
                          return it instead of `null`.
                          On create, omitting it applies the supplier's default currency (base currency when the supplier has
                          none). On update, omit to leave the currency and rate unchanged. Costs and totals stay in base currency.

                          Changing the currency restates `presentment_unit_price` at the new rate on every line the request
                          does not price (`unit_price` and costs do not change). Responds `422` on `currency_code` when the code
                          is unknown or no rate exists on or before `order_date` (send `exchange_rate` to supply one).
                        example: EUR
                      exchange_rate:
                        type: number
                        nullable: true
                        minimum: 1.e-8
                        maximum: 9999999999
                        description: |
                          Base-currency units per 1 unit of `currency_code`. Requires `currency_code`. If omitted, the rate on or
                          before `order_date` is used. While the currency stays the same on update, the stored rate is kept and
                          a different value here is ignored.
                        example: 1.085
                      total_shipping_cost:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        default: 0
                        description: Total shipping cost
                        example: 50
                      total_tax:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        default: 0
                        description: Total tax amount
                        example: 80
                      volume_target_cbm:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the container-fill gauge's denominator). When set, the
                          purchase-order response reports `volume_remaining_cbm` and `volume_fill_percent` against it.
                        example: 67
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes visible to suppliers
                        example: Please ship via express delivery
                      private_note:
                        type: string
                        nullable: true
                        description: Internal private notes
                        example: Rush order - expedite processing
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date (YYYY-MM-DD)
                        example: '2024-01-20'
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date (YYYY-MM-DD)
                        example: '2024-01-25'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: |
                          Freight mode used by the Transit Time Matrix. Matching is case-insensitive — `sea` and `SEA` are
                          stored as `Sea` — but any other value returns `422`. On update, omit to keep the stored value or send
                          `null` to clear it.

                          When a request sends `shipment_type` or `override_transit_days` and the PO has a warehouse, the
                          Original ETA (`original_arrival_due_date`) and current ETA (`arrival_due_date`) are filled from the
                          transit matrix if empty. Arrival dates sent in the same request are always kept as sent.

                          When the PO has no `requested_ship_date`, the count starts from today, unless the account's
                          `transit_eta_requires_ship_date` setting is on (off by default). Then both dates stay empty until the
                          PO has a requested ship date, and a `PUT /purchase-orders/{id}` that sends `requested_ship_date` to a
                          PO that already has a freight mode or override fills them while they are empty, even without
                          `shipment_type` or `override_transit_days` in the request. Transfer POs are not affected.
                        example: Sea
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: |
                          Frozen Original ETA (YYYY-MM-DD) — the arrival date as first planned, kept separate from the current
                          `arrival_due_date`. On update, omit to keep the stored value or send `null` to clear it.
                        example: '2024-01-25'
                      override_transit_days:
                        type: integer
                        minimum: 0
                        maximum: 3650
                        nullable: true
                        description: |
                          Manual override of the transit-matrix calendar days used to derive the arrival date. `0` is allowed.
                          On update, omit to keep the stored value or send `null` to clear it.
                        example: 35
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: Primary street address
                            example: 123 Main Street
                          address_2:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: 'Secondary address line (apt, suite, etc.)'
                            example: Suite 100
                          city:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: City name
                            example: Anytown
                          state:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: State or province
                            example: CA
                          zip:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: ZIP or postal code
                            example: '90210'
                          country:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: Country name
                            example: United States
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                            example: warehouse
                      items:
                        type: array
                        minItems: 1
                        description: Array of line items for the purchase order
                        items:
                          type: object
                          required:
                            - quantity
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Line item ID (only used for updates)
                              example: 456
                            product_id:
                              type: integer
                              nullable: true
                              description: ID of the product (required if sku not provided)
                              example: 123
                            sku:
                              type: string
                              maxLength: 255
                              nullable: true
                              description: SKU of the product (required if product_id not provided)
                              example: WIDGET-001
                            quantity:
                              type: number
                              format: float
                              minimum: 0.001
                              description: Quantity of the item ordered
                              example: 10.5
                            unit_price:
                              type: number
                              format: float
                              description: |
                                Price per unit, always in **base currency**. Required unless `presentment_unit_price` is sent.
                                On a foreign-currency purchase order, `presentment_unit_price` becomes this price divided by the
                                exchange rate. Do not send a supplier-currency amount here.
                              example: 49.99
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              minimum: 0
                              maximum: 99999999999
                              description: |
                                The line price in the purchase order's supplier currency, per ordered unit. `unit_price` becomes
                                this price times the exchange rate, and wins if both are sent. Without `unit_price`, a
                                base-currency purchase order responds `422` on this field.
                              example: 46
                            ordered_qty:
                              type: number
                              format: float
                              minimum: 0.001
                              nullable: true
                              description: Ordered quantity in base unit of measure (calculated automatically if not provided)
                              example: 10.5
                            received_qty:
                              type: number
                              format: float
                              minimum: 0
                              nullable: true
                              default: 0
                              description: Quantity already received
                              example: 5
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When omitted or null, the line inherits the purchase order''s header `requested_ship_date`.'
                              example: '2026-08-15'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When omitted or null, the line inherits the purchase order''s header `arrival_due_date`.'
                              example: '2026-08-20'
                            lot_id:
                              type: integer
                              nullable: true
                              description: ID of the product lot
                              example: 789
                            lot_number:
                              type: string
                              nullable: true
                              description: Lot number for the received item (used when the product has lot tracking enabled).
                              example: LOT-12345
                            lot_name:
                              type: string
                              nullable: true
                              description: Alias for `lot_number`.
                            uom_id:
                              type: integer
                              nullable: true
                              description: 'ID of the unit of measure for the item. If omitted, a default is resolved automatically in priority order: the product''s default purchase unit, then its default selling unit, then the base unit of its unit class, then the account''s base unit. If no unit of measure is supplied and no default can be resolved, the request fails with a 422 error.'
                              example: 1
                            source_sku:
                              type: string
                              maxLength: 255
                              nullable: true
                              description: Source SKU from the supplier
                              example: SUPPLIER-SKU-123
                            tags:
                              type: array
                              nullable: true
                              description: Tags to associate with this line item
                              items:
                                type: string
                                maxLength: 255
                              example:
                                - priority
                                - fragile
                            custom_fields:
                              type: object
                              nullable: true
                              description: Custom field values for this line item
                              additionalProperties:
                                oneOf:
                                  - type: string
                                  - type: number
                                  - type: boolean
                              example:
                                Lot Number: LOT-12345
                                Expiry Date: '2024-12-31'
                      payments:
                        type: array
                        nullable: true
                        description: |
                          Array of payments for this purchase order. If provided, replaces all existing payments.
                          Totals are automatically recalculated after payments are updated.
                        items:
                          type: object
                          required:
                            - payment_date
                            - payment_type
                            - paid_amount
                          properties:
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment (YYYY-MM-DD)
                              example: '2024-01-15'
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                              example: check
                            paid_amount:
                              type: number
                              format: float
                              minimum: 0.01
                              description: Amount paid
                              example: 500
                            remarks:
                              type: string
                              maxLength: 1000
                              nullable: true
                              description: Payment remarks or notes
                              example: 'Check #1234'
                            external_id:
                              type: string
                              maxLength: 255
                              nullable: true
                              description: External payment reference ID
                              example: PAY-EXT-12345
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for the purchase order
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: boolean
                        example:
                          Customer PO: PO-98765
                          Priority Level: High
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with the purchase order
                        items:
                          type: string
                          maxLength: 255
                        example:
                          - urgent
                          - priority
                          - rush-order
            example:
              purchase_orders:
                - order_date: '2026-11-10'
                  supplier_id: 123
                  order_status: draft
                  order_numbers:
                    - PO-1001
                  items:
                    - sku: WIDGET-001
                      quantity: 10
                      unit_price: 4.5
                - supplier_id: 123
                  order_status: draft
                  items:
                    - sku: WIDGET-002
                      quantity: 5
                      unit_price: 9.99
      responses:
        '200':
          description: 'One result slot per element, in request order'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                          description: Position of the element in `purchase_orders`.
                        id:
                          type: integer
                          description: ID of the created purchase order. Present on success.
                        order_numbers:
                          type: array
                          items:
                            type: string
                          description: Order numbers on the created purchase order. Present on success.
                        error:
                          type: object
                          additionalProperties:
                            type: array
                            items:
                              type: string
                          description: Validation messages keyed by field. Present on failure.
              example:
                data:
                  - index: 0
                    id: 1001
                    order_numbers:
                      - PO-1001
                  - index: 1
                    error:
                      order_date:
                        - Order date is required.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: 'Idempotency conflict (key reused with a different body, or the first request is still running)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Invalid envelope (missing, empty or non-array `purchase_orders`, or more than 100 elements). Nothing is created.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '429':
          description: Too many requests (limit 30 per minute)
  /purchase-orders/email:
    post:
      operationId: emailPurchaseOrders
      tags:
        - Purchase Orders
      summary: Email purchase orders to suppliers
      description: |
        Email up to 100 purchase orders to their suppliers, the same as sending them from the app. Purchase
        orders are grouped by supplier, one email per supplier, addressed to that supplier's contacts with
        email addresses. Each email can attach the purchase order PDFs, a CSV or Excel file per purchase
        order (`attach_data`), or both. Subject, body, CC/BCC and PDF layout come from the email template: the supplier's own
        purchase order template when it has one, otherwise `template_id`, otherwise your default purchase
        order template. List templates with `GET /purchase-orders/email-templates`.

        Emails are queued: a `202` returns the batch that was queued, not delivery results.

        Suppliers without a contact email are skipped; if no purchase order can be emailed, the request
        fails with `422`. Returns `404` when document email is not enabled for your account.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - purchase_order_ids
              properties:
                purchase_order_ids:
                  type: array
                  minItems: 1
                  maxItems: 100
                  uniqueItems: true
                  items:
                    type: integer
                    minimum: 1
                  description: IDs of the purchase orders to email. Every one must exist and have a supplier.
                template_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: Purchase order email template to use for suppliers without their own template. Defaults to your default template.
                attach_pdf:
                  type: boolean
                  nullable: true
                  default: true
                  description: Attach each purchase order's PDF.
                attach_data:
                  type: boolean
                  nullable: true
                  default: false
                  description: |
                    Also attach each purchase order as a spreadsheet (`PurchaseOrder_<id>.csv` or `.xlsx`),
                    built the same way as the purchase order's CSV / Excel export. Can be sent alongside the PDF
                    or, with `attach_pdf: false`, instead of it.
                data_export_template_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    Purchase order data export template that controls the spreadsheet's columns, column order
                    and header names. Defaults to your default purchase order data template; with none, every
                    default column is included. Only used when `attach_data` is `true`.
                data_format:
                  type: string
                  nullable: true
                  enum:
                    - csv
                    - xlsx
                  default: csv
                  description: Spreadsheet format for the data attachment. Only used when `attach_data` is `true`.
            example:
              purchase_order_ids:
                - 1201
                - 1202
              attach_pdf: true
              attach_data: true
              data_format: xlsx
      responses:
        '202':
          description: Emails queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      batch_id:
                        type: string
                        description: ID of the queued email batch.
                      total_items:
                        type: integer
                        description: Number of emails in the batch (one per supplier).
                      failed_items:
                        type: integer
                        description: Emails that had already failed when the response was built.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Document email is not enabled for this account.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    nullable: true
                  message:
                    type: string
                    example: Document email is not enabled for this tenant.
        '422':
          description: |
            Validation failed: unknown purchase order IDs, purchase orders without a supplier, no supplier
            contacts with email addresses, or an unusable template (returned as `message` with `data: null`).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /purchase-orders/email-templates:
    get:
      operationId: listPurchaseOrderEmailTemplates
      tags:
        - Purchase Orders
      summary: List purchase order email templates
      description: |
        List the purchase order email templates, tenant-wide ones first, then supplier-specific ones. Pass a
        template's `id` as `template_id` to `POST /purchase-orders/email`. Returns `404` when document email
        is not enabled for your account.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Templates
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        document_type:
                          type: string
                          example: purchase_order
                        company_type:
                          type: string
                          nullable: true
                          description: Type of company the template is scoped to; `null` for tenant-wide templates.
                        company_id:
                          type: integer
                          nullable: true
                          description: Supplier the template is scoped to; `null` for tenant-wide templates.
                        name:
                          type: string
                        subject:
                          type: string
                          description: Subject (Mustache template source).
                        body_html:
                          type: string
                          description: HTML body (Mustache template source).
                        attach_pdf:
                          type: boolean
                        export_template_id:
                          type: integer
                          nullable: true
                          description: PDF layout used for the attachment; `null` for the default.
                        default_recipients:
                          type: array
                          nullable: true
                          items:
                            type: string
                        cc:
                          type: array
                          nullable: true
                          items:
                            type: string
                        bcc:
                          type: array
                          nullable: true
                          items:
                            type: string
                        is_default:
                          type: boolean
                        created_by:
                          type: integer
                          nullable: true
                        updated_by:
                          type: integer
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Document email is not enabled for this account.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /purchase-orders/arrival-date-preview:
    get:
      operationId: previewPurchaseOrderArrivalDate
      tags:
        - Purchase Orders
      summary: Preview a purchase order's arrival due date
      description: |
        Returns the Arrival Due Date that the Transit Time Matrix (or an override) gives for a warehouse,
        freight mode and requested ship date, before the purchase order exists. Read-only: nothing is created
        or changed. Use it to show the date on a new-PO form before the PO is saved.

        It runs the same calculation `POST /purchase-orders` uses when it stamps `original_arrival_due_date`
        and `arrival_due_date` on a new PO: `requested_ship_date` (or today when blank) plus the lane's
        calendar days for that warehouse and mode. If the date lands on a Saturday or Sunday it moves to the
        Monday, unless the lane has weekend snapping turned off. An override always snaps to a weekday.

        All query parameters are optional. When they are not enough to compute a date (no `warehouse_id`, no
        `shipment_type` and no override, or no lane in the matrix for that warehouse and mode) the response
        is `200` with all three fields `null`.

        To have the PO saved with the same date, send the same `warehouse_id`, `shipment_type` (or
        `override_transit_days`) and `requested_ship_date` on `POST /purchase-orders` and leave out
        `arrival_due_date`; an `arrival_due_date` sent in the request is kept as sent.

        Accounts that wait for a ship date: with the purchase-order setting `transit_eta_requires_ship_date`
        on (off by default), no Arrival Due Date or Original ETA is worked out until the PO has a
        `requested_ship_date`, with or without `override_transit_days`. The preview then returns all three
        fields `null` when `requested_ship_date` is blank, matching what `POST /purchase-orders` would save.

        This is not a preview of an edit. On an existing PO that already has an `original_arrival_due_date`,
        `PUT /purchase-orders/{id}` keeps that date and only fills `arrival_due_date` when it is empty, so
        changing the mode or ship date does not move them.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: warehouse_id
          required: false
          schema:
            type: integer
          description: 'Destination warehouse (the PO''s `warehouse_id`). An id that is not a warehouse returns `422`, as on create.'
          example: 24
        - in: query
          name: shipment_type
          required: false
          schema:
            type: string
            enum:
              - Air
              - Sea
              - Road
              - Rail
              - Express
          description: Freight mode. Matching is case-insensitive (`sea` is read as `Sea`); any other value returns `422`.
          example: Sea
        - in: query
          name: requested_ship_date
          required: false
          schema:
            type: string
            format: date
          description: 'Requested ship date (YYYY-MM-DD). When blank, the count starts from today, as it does on save, unless the account''s `transit_eta_requires_ship_date` setting is on; then no date is computed.'
          example: '2026-11-13'
        - in: query
          name: override_transit_days
          required: false
          schema:
            type: integer
            minimum: 0
            maximum: 3650
          description: 'Transit days to use instead of the matrix. When set, `source` is `override`.'
          example: 7
      responses:
        '200':
          description: Arrival date preview (all fields `null` when no date can be computed)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: The arrival due date a new PO with these inputs would be stamped with (YYYY-MM-DD).
                        example: '2026-12-18'
                      transit_days:
                        type: integer
                        nullable: true
                        description: 'Calendar days used — the lane''s days, or `override_transit_days`.'
                        example: 35
                      source:
                        type: string
                        nullable: true
                        enum:
                          - lane
                          - override
                          - null
                        description: '`lane` when the date came from the Transit Time Matrix, `override` when from `override_transit_days`.'
                        example: lane
              example:
                data:
                  arrival_due_date: '2026-12-18'
                  transit_days: 35
                  source: lane
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (unknown warehouse, invalid `shipment_type`, invalid date, or `override_transit_days` outside 0–3650)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /purchase-orders/items:
    get:
      operationId: getPurchaseOrderItems
      tags:
        - Purchase Orders
      summary: Purchase order items
      description: |
        Get a paginated list of purchase order items with optional filtering. Lines of a deleted
        purchase order are never returned, however the purchase order was deleted.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ### Available Filters

        #### Integer Filters
        - `purchase_order_id`: Filter by purchase order ID

        #### String Filters
        - `sku`: The line's own SKU (the internal SKU on the purchase order item)
        - `source_sku`: Source SKU on the purchase order item

        #### Float Filters
        - `quantity`: Ordered quantity (ordered UOM)
        - `quantity_received`: Quantity received
        - `received_quantity`: Deprecated alias of `quantity_received` (same column)
        - `quantity_shipped`: Quantity shipped, in the ordered UOM
        - `quantity_billed`: Quantity billed, in the ordered UOM
        - `remaining_to_ship`: Ordered minus shipped — **signed** (e.g. `remaining_to_ship[lt]=0` finds over-shipped lines)
        - `remaining_to_receive`: Ordered minus received, in the ordered UOM — **signed**
        - `unit_price`: Unit price of the item

        Each quantity filter resolves the same expression the response reports (including the
        UOM conversion), so a filtered result set can never contradict the figures in it. There
        is no filter on `available_to_allocate`.

        #### Boolean Filters
        - `on_shipment`: Whether the item is on a shipment (true) or not (false)

        #### DateTime Filters
        - `created_at`: When the purchase order item was created
        - `updated_at`: When the purchase order item was last updated

        ### Product Filters

        All product filters are available with the `product.` prefix. These filter based on the product associated with the purchase order item.

        #### String Filters
        - `product.name`: Product name
        - `product.description`: Product description
        - `product.sku`: Product SKU (searches both internal SKU and alternate SKUs)
        - `product.upc`: Product UPC/Barcode
        - `product.tag`: Product tags
        - `product.q`: General search matches name OR upc OR sku
        - `product.category.name`: Filter by category name
        - `product.sub_category.name`: Filter by sub-category name
        - `product.supplier.name`: Filter by supplier name

        #### Integer Filters
        - `product.id`: Product ID
        - `product.category.id`: Filter by category ID
        - `product.sub_category.id`: Filter by sub-category ID
        - `product.supplier.id`: Filter by supplier ID

        #### Float Filters
        - `product.retail_price`: Product retail price
        - `product.wholesale_price`: Product wholesale price

        #### Boolean Filters
        - `product.sellable`: If the product is sellable or not
        - `product.discontinued`: If the product is discontinued

        #### DateTime Filters
        - `product.created_at`: When the product was created
        - `product.updated_at`: When the product was last updated

        ## Examples
        ```
        # Get all items for a specific purchase order
        ?purchase_order_id[eq]=123

        # Find the lines (and so the purchase orders) carrying a SKU
        ?sku[eq]=PROD-SKU-001

        # Find items with a specific source SKU
        ?source_sku[eq]=VENDOR-SKU-001

        # Find items with quantity greater than 100
        ?quantity[gt]=100

        # Find items that have been partially received
        ?received_quantity[gt]=0&quantity[gt]=received_quantity

        # Find items that are on a shipment
        ?on_shipment[eq]=1

        # Find items where the associated product is discontinued
        ?product.discontinued[eq]=1

        # Find items by product category
        ?product.category.name[eq]=Electronics

        # Find items with products from a specific supplier
        ?product.supplier.name[contains]=Acme

        # Find items with unit price in a specific range
        ?unit_price[gte]=10.00&unit_price[lte]=50.00

        # Find recently updated items
        ?updated_at[gte]=2024-01-01 00:00:00

        # Combine multiple filters: items for a purchase order with products in a category
        ?purchase_order_id[eq]=123&product.category.name[eq]=Electronics

        # Find items for products with a specific SKU
        ?product.sku[eq]=PROD-SKU-001
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: purchase_order_id
          schema:
            type: integer
          description: Filter by purchase order ID
        - in: query
          name: sku
          schema:
            type: string
          description: Filter by the line's own SKU (internal SKU on the purchase order item)
        - in: query
          name: source_sku
          schema:
            type: string
          description: Filter by source SKU
        - in: query
          name: quantity
          schema:
            type: number
            format: float
          description: Filter by ordered quantity
        - in: query
          name: quantity_received
          schema:
            type: number
            format: float
          description: Filter by received quantity
        - in: query
          name: received_quantity
          schema:
            type: number
            format: float
          deprecated: true
          description: Deprecated alias of `quantity_received` (same column)
        - in: query
          name: quantity_shipped
          schema:
            type: number
            format: float
          description: Filter by quantity shipped (ordered UOM)
        - in: query
          name: quantity_billed
          schema:
            type: number
            format: float
          description: Filter by quantity billed (ordered UOM)
        - in: query
          name: remaining_to_ship
          schema:
            type: number
            format: float
          description: 'Filter by ordered minus shipped (signed). `remaining_to_ship[lt]=0` returns over-shipped lines.'
        - in: query
          name: remaining_to_receive
          schema:
            type: number
            format: float
          description: 'Filter by ordered minus received, in the ordered UOM (signed)'
        - in: query
          name: unit_price
          schema:
            type: number
            format: float
          description: Filter by unit price
        - in: query
          name: on_shipment
          schema:
            type: boolean
          description: Filter by whether the item is on a shipment
        - in: query
          name: closed
          schema:
            type: boolean
          description: 'Filter by whether the line has been closed short (`true` = closed, `false` = open)'
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: product.id
          schema:
            type: integer
          description: Filter by product ID
        - in: query
          name: product.name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: product.description
          schema:
            type: string
          description: Filter by product description
        - in: query
          name: product.sku
          schema:
            type: string
          description: Filter by product SKU (searches both internal and alternate SKUs)
        - in: query
          name: product.upc
          schema:
            type: string
          description: Filter by product UPC/Barcode
        - in: query
          name: product.sellable
          schema:
            type: boolean
          description: Filter by product sellable status
        - in: query
          name: product.discontinued
          schema:
            type: boolean
          description: Filter by whether the product is discontinued
        - in: query
          name: product.retail_price
          schema:
            type: number
            format: float
          description: Filter by product retail price
        - in: query
          name: product.wholesale_price
          schema:
            type: number
            format: float
          description: Filter by product wholesale price
        - in: query
          name: product.tag
          schema:
            type: string
          description: Filter by product tags
        - in: query
          name: product.category.id
          schema:
            type: integer
          description: Filter by product category ID
        - in: query
          name: product.category.name
          schema:
            type: string
          description: Filter by product category name
        - in: query
          name: product.sub_category.id
          schema:
            type: integer
          description: Filter by product sub-category ID
        - in: query
          name: product.sub_category.name
          schema:
            type: string
          description: Filter by product sub-category name
        - in: query
          name: product.supplier.id
          schema:
            type: integer
          description: Filter by product supplier ID
        - in: query
          name: product.supplier.name
          schema:
            type: string
          description: Filter by product supplier name
        - in: query
          name: product.q
          schema:
            type: string
          description: General product search (matches name OR upc OR sku)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Line item ID
                        purchase_order_id:
                          type: integer
                          description: ID of the parent purchase order
                        created_at:
                          type: string
                          format: date-time
                          description: Creation timestamp
                        updated_at:
                          type: string
                          format: date-time
                          description: Last update timestamp
                        quantity:
                          type: number
                          format: float
                          description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                        presentment_unit_price:
                          type: number
                          format: float
                          nullable: true
                          description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                        unit_price:
                          type: number
                          format: float
                          description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                        unit:
                          type: string
                          nullable: true
                          description: Unit of measure
                        tax:
                          type: number
                          format: float
                          description: Tax amount
                        discount_amount:
                          type: number
                          format: float
                          description: Discount amount
                        line_total:
                          type: number
                          format: float
                          description: Total for this line item
                        expected_ship_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                        expected_arrival_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                        requested_ship_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                        arrival_due_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                        shipment_type:
                          type: string
                          nullable: true
                          enum:
                            - Air
                            - Sea
                            - Road
                            - Rail
                            - Express
                            - null
                          description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                        original_arrival_due_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                        override_transit_days:
                          type: integer
                          nullable: true
                          description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                        quantity_received:
                          type: number
                          format: float
                          description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                        received_quantity:
                          type: number
                          format: float
                          deprecated: true
                          description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                        quantity_ordered:
                          type: number
                          format: float
                          description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                        quantity_shipped:
                          type: number
                          format: float
                          description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                        quantity_billed:
                          type: number
                          format: float
                          description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                        quantity_allocated:
                          type: number
                          format: float
                          description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                        quantity_released:
                          type: number
                          format: float
                          description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                        under_covered_quantity:
                          type: number
                          format: float
                          description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                        remaining_to_ship:
                          type: number
                          format: float
                          description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                        remaining_to_receive:
                          type: number
                          format: float
                          description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                        open_quantity:
                          type: number
                          format: float
                          description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                          example: 40
                        closed_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                          example: null
                        close_reason:
                          type: string
                          nullable: true
                          description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                          example: null
                        available_to_allocate:
                          type: number
                          format: float
                          description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                        volume_cbm:
                          type: number
                          format: float
                          description: |
                            Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                            (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                            container-fill summary.
                        line_volume_cbm:
                          type: number
                          format: float
                          description: |
                            This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                        weight_kg:
                          type: number
                          format: float
                          description: |
                            Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                            container-fill summary.
                        line_weight_kg:
                          type: number
                          format: float
                          description: |
                            This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                        allocations:
                          type: array
                          description: |
                            Which sales orders currently hold the allocation on this line. Only populated on the
                            single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                            array on the list endpoint and for non-allocated lines.
                          items:
                            type: object
                            properties:
                              sales_order_id:
                                type: integer
                                description: ID of the sales order holding the allocation
                              sales_order_number:
                                type: string
                                nullable: true
                                description: Human-readable sales order number
                              quantity_allocated:
                                type: number
                                format: float
                                description: Open quantity this sales order has pegged to the line
                              quantity_released:
                                type: number
                                format: float
                                description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                              peg_ids:
                                type: array
                                items:
                                  type: integer
                                description: |
                                  IDs of the pegs backing this allocation. Pass these to
                                  `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                  allocation made through the API. Allocate, read the peg ids back from
                                  `GET /purchase-orders/{id}`, then reverse them.
                        source_sku:
                          type: string
                          nullable: true
                          description: Source SKU from the supplier
                        product:
                          type: object
                          nullable: true
                          description: Associated product information
                          properties:
                            id:
                              type: integer
                              description: Product ID
                            name:
                              type: string
                              description: Product name
                            description:
                              type: string
                              nullable: true
                              description: Product description
                            retail_price:
                              type: number
                              format: float
                              description: Product retail price
                            wholesale_price:
                              type: number
                              format: float
                              description: Product wholesale price
                            unit_cost:
                              type: number
                              format: float
                              description: Product unit cost
                            product_weight:
                              type: number
                              format: float
                              description: Product weight
                            product_length:
                              type: number
                              format: float
                              description: Product length (in inches)
                            product_width:
                              type: number
                              format: float
                              description: Product width (in inches)
                            product_height:
                              type: number
                              format: float
                              description: Product height (in inches)
                            sellable:
                              type: boolean
                              description: Whether the product is sellable
                            discontinued:
                              type: boolean
                              description: Whether the product is discontinued
                            image_url:
                              type: string
                              nullable: true
                              description: Product image URL
                            variant_attributes:
                              type: object
                              nullable: true
                              description: Product variant attributes
                            sku:
                              type: string
                              description: Product internal SKU
                            upc:
                              type: string
                              description: Product UPC/Barcode
                            created_at:
                              type: string
                              format: date-time
                              description: Product creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Product last update timestamp
                        base_unit_of_measure:
                          type: object
                          nullable: true
                          description: Base unit of measure
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            abbreviation:
                              type: string
                        ordered_unit_of_measure:
                          type: object
                          nullable: true
                          description: Ordered unit of measure
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            abbreviation:
                              type: string
                        lot:
                          type: object
                          nullable: true
                          description: Product lot information
                          properties:
                            id:
                              type: integer
                            lot_number:
                              type: string
                            expiration_date:
                              type: string
                              format: date
                              nullable: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /purchase-orders/reverse-allocation:
    post:
      operationId: reversePurchaseOrderAllocation
      tags:
        - Purchase Orders
      summary: Reverse (unallocate) an allocation peg
      description: |
        Reverse a single allocation peg created by the Purchase-to-Order workflow (the inverse of
        `POST /purchase-orders/{purchaseOrderId}/allocate`), freeing the pegged stock so it reposts as
        available against the incoming purchase order / on-hand supply.

        The peg is identified by `peg_id` alone — on-hand and pre-order pegs are not tied to a purchase
        order, so this is a top-level path rather than a PO-scoped one. Behavior depends on how far the
        allocation has progressed:

        - **Pure reservation** (nothing released) — the peg is deleted and availability recovers
          automatically.
        - **Pre-ship fulfillment** — the generated fulfillment order (or just this line's contribution to
          a consolidated fulfillment order) is unwound, returning the stock, then the peg is deleted.
        - **Already shipped** — cannot be reversed here; the request fails with `422` and the allocation
          must instead be reversed through a **Return**. If only part of the allocation shipped, the
          unfulfilled remainder is removed and the shipped portion is retained (`partial: true`).

        > **Note:** This endpoint is gated by the `PURCHASE_TO_ORDER` feature flag. Contact Luminous to
        > have it enabled for your tenant.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - peg_id
              properties:
                peg_id:
                  type: integer
                  minimum: 1
                  description: ID of the allocation peg to reverse
                  example: 33012
            examples:
              reverse_peg:
                summary: Reverse an allocation peg
                value:
                  peg_id: 33012
      responses:
        '200':
          description: Allocation reversed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      removed:
                        type: boolean
                        description: Whether the peg was fully removed (false when only a shipped-partial remainder was trimmed)
                        example: true
                      foTornDown:
                        type: boolean
                        description: Whether a generated fulfillment order (or this line's contribution to one) was unwound to return the stock
                        example: true
                      quantityReversed:
                        type: number
                        format: float
                        description: Quantity returned to available supply by the reversal
                        example: 10
                      partial:
                        type: boolean
                        description: Present and `true` when only the unfulfilled remainder of a partly-shipped allocation was removed
                        example: true
                      shipped:
                        type: boolean
                        description: Present and `true` alongside `partial` when the retained portion had already shipped
                        example: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Unprocessable entity - `peg_id` missing, the allocation was not found, the `PURCHASE_TO_ORDER`
            feature is not enabled, or the allocation has already shipped (reverse it through a Return
            instead).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{id}':
    get:
      operationId: getPurchaseOrder
      tags:
        - Purchase Orders
      summary: Single purchase order
      description: Get details of a specific purchase order by ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the purchase order to retrieve
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updatePurchaseOrder
      tags:
        - Purchase Orders
      summary: Update a purchase order
      description: |
        Update an existing purchase order. All fields are optional - only provided fields will be updated.

        ## Key Features
        - Partial updates supported - only include fields you want to change
        - Items can be added, updated, or removed
        - If `items` array is provided, it replaces all existing items
        - If `payments` array is provided, it replaces all existing payments
        - Totals are automatically recalculated after updates
        - Stock count updates - incoming quantities are automatically updated when items change

        ## Product Identification
        For each line item, you must provide either:
        - `product_id`: The internal product ID
        - `sku`: The product SKU (supports both internal SKU and alternate SKUs)

        ## Inventory-Tracked Products Only
        Every line item must reference an inventory-tracked product (type `PRODUCT` or `KIT`).
        Non-inventory items (e.g. service or fee SKUs) are rejected with a `422` on
        `items.{index}.product` — record those charges as an extra cost on the purchase order instead.
        When `items` is provided, it is validated before anything is written, so a rejected request
        leaves the purchase order and its existing lines unchanged.

        ## Updating Items
        To update an existing item, include its `id` in the item object.
        To add a new item, omit the `id` field.
        To remove an item, omit it from the `items` array.

        ## Order Status Values
        Valid order statuses include: `active`, `completed`, `deleted`

        ## Supplier Currency
        Send `currency_code` (a code from `GET /currency/available`) to write the purchase order in a
        supplier's currency while costs stay in base currency. `unit_price` is always base currency; to price
        a line in the supplier's currency send `items[].presentment_unit_price` instead. An update that does
        not send `currency_code` leaves the currency and rate unchanged, and while the currency stays the same
        the stored `exchange_rate` is kept.

        ## Total Calculation
        The order cost (`order_cost`) is automatically recalculated as:
        `sum of (item quantities × unit prices) + additional fees`

        Additional fees are the PO's persisted extra costs, including fees added automatically
        by matching cost rules (e.g. tariffs) when the order is saved. If a save adds or removes
        a cost-rule fee, `order_cost`, `total_cost`, and `total_due` move by that amount.

        The order total (`total_cost`) is automatically recalculated as:
        `order_cost + total_tax + total_shipping_cost`

        Note: `order_cost`, `total_cost`, `total_paid`, and `total_due` are calculated automatically 
        on the backend and cannot be edited directly.

        ## Payments
        If `payments` array is provided, it replaces all existing payments for the order.
        Totals are automatically recalculated after payments are updated.

        If any existing payment on the order records an active vendor prepayment, the replace is
        refused with a `422` ("This purchase order has payment(s) recording prepayment #N...") and no
        payments are changed. Void the prepayment instead — replacing the payments would leave the
        prepayment balance in place.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the purchase order to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - order_date
                - supplier_id
                - items
              properties:
                order_date:
                  type: string
                  format: date
                  description: Date when the purchase order was created (YYYY-MM-DD)
                  example: '2024-01-15'
                supplier_id:
                  type: integer
                  description: ID of the supplier
                  example: 123
                warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the warehouse
                  example: 1
                location_id:
                  type: integer
                  nullable: true
                  description: ID of the location
                  example: 1
                order_status:
                  oneOf:
                    - type: string
                      enum:
                        - active
                        - production_started
                        - production_completed
                        - in_transit
                        - completed
                        - draft
                        - cancelled
                        - deleted
                    - type: integer
                      enum:
                        - 1
                        - 20
                        - 40
                        - 50
                        - 99
                        - 101
                        - 100
                        - -1
                  nullable: true
                  default: active
                  description: |
                    Milestone status (token or numeric id). Also accepts 30 (production_active) and 88 (delivered) by id.
                    Writes a milestone row and updates the PO header.

                    `draft` (101) and `cancelled` (100) are order states, not timeline milestones. They do not
                    count as incoming stock and the purchase order cannot take a new receipt while in either state.
                    Creating a purchase order with `order_status: draft` saves it as a draft from the start, so its
                    lines never post incoming. Moving it to an open milestone later posts incoming at that point.
                  example: active
                order_numbers:
                  type: array
                  nullable: true
                  description: Array of purchase order numbers used to identify the purchase order across various systems
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - PO-2024-001
                    - SUPPLIER-PO-123
                invoice_date:
                  type: string
                  format: date
                  nullable: true
                  description: Date when the purchase order was invoiced (YYYY-MM-DD)
                  example: '2024-01-16'
                incoterm:
                  type: string
                  nullable: true
                  description: 'Incoterm (delivery term) for the purchase order, given as a logistic code configured for the account (e.g. `exw`, `fob`, `ddp`). Matching is case-insensitive — both the lower-case code (`exw`) and its upper-case label (`EXW`) are accepted. Returned on the purchase order resource as `incoterm`. If omitted, the account default is applied.'
                  example: exw
                payment_terms:
                  type: string
                  nullable: true
                  description: 'Payment terms for the purchase order. Must exactly match one of the payment terms configured for the account (Manage > Suppliers); matching is case-sensitive (`Net 30` passes where `net 30` fails). Returned on the purchase order resource as `payment_terms`. If omitted, the account default is applied.'
                  example: Net 30
                currency_code:
                  type: string
                  nullable: true
                  minLength: 3
                  maxLength: 3
                  description: |
                    The purchase order's supplier currency: a three-letter code, in any case, listed by
                    `GET /currency/available`. `null` puts the purchase order in base currency. Sending your base
                    currency code explicitly also puts it in base currency, but stores the code (rate `1`) so responses
                    return it instead of `null`.
                    On create, omitting it applies the supplier's default currency (base currency when the supplier has
                    none). On update, omit to leave the currency and rate unchanged. Costs and totals stay in base currency.

                    Changing the currency restates `presentment_unit_price` at the new rate on every line the request
                    does not price (`unit_price` and costs do not change). Responds `422` on `currency_code` when the code
                    is unknown or no rate exists on or before `order_date` (send `exchange_rate` to supply one).
                  example: EUR
                exchange_rate:
                  type: number
                  nullable: true
                  minimum: 1.e-8
                  maximum: 9999999999
                  description: |
                    Base-currency units per 1 unit of `currency_code`. Requires `currency_code`. If omitted, the rate on or
                    before `order_date` is used. While the currency stays the same on update, the stored rate is kept and
                    a different value here is ignored.
                  example: 1.085
                total_shipping_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  default: 0
                  description: Total shipping cost
                  example: 50
                total_tax:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  default: 0
                  description: Total tax amount
                  example: 80
                volume_target_cbm:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Target container volume in cubic metres (the container-fill gauge's denominator). When set, the
                    purchase-order response reports `volume_remaining_cbm` and `volume_fill_percent` against it.
                  example: 67
                public_note:
                  type: string
                  nullable: true
                  description: Public notes visible to suppliers
                  example: Please ship via express delivery
                private_note:
                  type: string
                  nullable: true
                  description: Internal private notes
                  example: Rush order - expedite processing
                requested_ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: Requested shipping date (YYYY-MM-DD)
                  example: '2024-01-20'
                arrival_due_date:
                  type: string
                  format: date
                  nullable: true
                  description: Expected arrival date (YYYY-MM-DD)
                  example: '2024-01-25'
                shipment_type:
                  type: string
                  nullable: true
                  enum:
                    - Air
                    - Sea
                    - Road
                    - Rail
                    - Express
                    - null
                  description: |
                    Freight mode used by the Transit Time Matrix. Matching is case-insensitive — `sea` and `SEA` are
                    stored as `Sea` — but any other value returns `422`. On update, omit to keep the stored value or send
                    `null` to clear it.

                    When a request sends `shipment_type` or `override_transit_days` and the PO has a warehouse, the
                    Original ETA (`original_arrival_due_date`) and current ETA (`arrival_due_date`) are filled from the
                    transit matrix if empty. Arrival dates sent in the same request are always kept as sent.

                    When the PO has no `requested_ship_date`, the count starts from today, unless the account's
                    `transit_eta_requires_ship_date` setting is on (off by default). Then both dates stay empty until the
                    PO has a requested ship date, and a `PUT /purchase-orders/{id}` that sends `requested_ship_date` to a
                    PO that already has a freight mode or override fills them while they are empty, even without
                    `shipment_type` or `override_transit_days` in the request. Transfer POs are not affected.
                  example: Sea
                original_arrival_due_date:
                  type: string
                  format: date
                  nullable: true
                  description: |
                    Frozen Original ETA (YYYY-MM-DD) — the arrival date as first planned, kept separate from the current
                    `arrival_due_date`. On update, omit to keep the stored value or send `null` to clear it.
                  example: '2024-01-25'
                override_transit_days:
                  type: integer
                  minimum: 0
                  maximum: 3650
                  nullable: true
                  description: |
                    Manual override of the transit-matrix calendar days used to derive the arrival date. `0` is allowed.
                    On update, omit to keep the stored value or send `null` to clear it.
                  example: 35
                ship_to:
                  type: object
                  nullable: true
                  description: Shipping address information
                  properties:
                    address_1:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Primary street address
                      example: 123 Main Street
                    address_2:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: 'Secondary address line (apt, suite, etc.)'
                      example: Suite 100
                    city:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: City name
                      example: Anytown
                    state:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: State or province
                      example: CA
                    zip:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: ZIP or postal code
                      example: '90210'
                    country:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Country name
                      example: United States
                    default_ship_to_address:
                      type: string
                      enum:
                        - ship_to_address
                        - warehouse
                      nullable: true
                      description: Default shipping address preference
                      example: warehouse
                items:
                  type: array
                  minItems: 1
                  description: Array of line items for the purchase order
                  items:
                    type: object
                    required:
                      - quantity
                    properties:
                      id:
                        type: integer
                        nullable: true
                        description: Line item ID (only used for updates)
                        example: 456
                      product_id:
                        type: integer
                        nullable: true
                        description: ID of the product (required if sku not provided)
                        example: 123
                      sku:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: SKU of the product (required if product_id not provided)
                        example: WIDGET-001
                      quantity:
                        type: number
                        format: float
                        minimum: 0.001
                        description: Quantity of the item ordered
                        example: 10.5
                      unit_price:
                        type: number
                        format: float
                        description: |
                          Price per unit, always in **base currency**. Required unless `presentment_unit_price` is sent.
                          On a foreign-currency purchase order, `presentment_unit_price` becomes this price divided by the
                          exchange rate. Do not send a supplier-currency amount here.
                        example: 49.99
                      presentment_unit_price:
                        type: number
                        format: float
                        nullable: true
                        minimum: 0
                        maximum: 99999999999
                        description: |
                          The line price in the purchase order's supplier currency, per ordered unit. `unit_price` becomes
                          this price times the exchange rate, and wins if both are sent. Without `unit_price`, a
                          base-currency purchase order responds `422` on this field.
                        example: 46
                      ordered_qty:
                        type: number
                        format: float
                        minimum: 0.001
                        nullable: true
                        description: Ordered quantity in base unit of measure (calculated automatically if not provided)
                        example: 10.5
                      received_qty:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        default: 0
                        description: Quantity already received
                        example: 5
                      expected_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Per-line expected ship date override. When omitted or null, the line inherits the purchase order''s header `requested_ship_date`.'
                        example: '2026-08-15'
                      expected_arrival_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Per-line expected arrival date override. When omitted or null, the line inherits the purchase order''s header `arrival_due_date`.'
                        example: '2026-08-20'
                      lot_id:
                        type: integer
                        nullable: true
                        description: ID of the product lot
                        example: 789
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number for the received item (used when the product has lot tracking enabled).
                        example: LOT-12345
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
                      uom_id:
                        type: integer
                        nullable: true
                        description: 'ID of the unit of measure for the item. If omitted, a default is resolved automatically in priority order: the product''s default purchase unit, then its default selling unit, then the base unit of its unit class, then the account''s base unit. If no unit of measure is supplied and no default can be resolved, the request fails with a 422 error.'
                        example: 1
                      source_sku:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Source SKU from the supplier
                        example: SUPPLIER-SKU-123
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with this line item
                        items:
                          type: string
                          maxLength: 255
                        example:
                          - priority
                          - fragile
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for this line item
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: boolean
                        example:
                          Lot Number: LOT-12345
                          Expiry Date: '2024-12-31'
                payments:
                  type: array
                  nullable: true
                  description: |
                    Array of payments for this purchase order. If provided, replaces all existing payments.
                    Totals are automatically recalculated after payments are updated.
                  items:
                    type: object
                    required:
                      - payment_date
                      - payment_type
                      - paid_amount
                    properties:
                      payment_date:
                        type: string
                        format: date
                        description: Date of the payment (YYYY-MM-DD)
                        example: '2024-01-15'
                      payment_type:
                        type: string
                        enum:
                          - cash
                          - credit_card
                          - debit_card
                          - check
                          - bank_transfer
                        description: Type of payment
                        example: check
                      paid_amount:
                        type: number
                        format: float
                        minimum: 0.01
                        description: Amount paid
                        example: 500
                      remarks:
                        type: string
                        maxLength: 1000
                        nullable: true
                        description: Payment remarks or notes
                        example: 'Check #1234'
                      external_id:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: External payment reference ID
                        example: PAY-EXT-12345
                custom_fields:
                  type: object
                  nullable: true
                  description: Custom field values for the purchase order
                  additionalProperties:
                    oneOf:
                      - type: string
                      - type: number
                      - type: boolean
                  example:
                    Customer PO: PO-98765
                    Priority Level: High
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the purchase order
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - urgent
                    - priority
                    - rush-order
            examples:
              update_status:
                summary: Update order status only
                description: Update just the order status
                value:
                  order_status: completed
              update_items:
                summary: Update items
                description: Replace all items in the order
                value:
                  items:
                    - id: 789
                      quantity: 20
                      unit_price: 49.99
                    - product_id: 456
                      quantity: 5
                      unit_price: 29.99
              update_payments:
                summary: Update payments
                description: Replace all payments for the order
                value:
                  payments:
                    - payment_date: '2024-01-15'
                      payment_type: check
                      paid_amount: 1000
                      remarks: 'Check #5678'
      responses:
        '200':
          description: Purchase order updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '400':
          description: Bad request - validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Unprocessable entity - validation error (e.g. a line item references a non-inventory product, or a `payments` replace would remove a payment that records an active prepayment)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    patch:
      operationId: patchPurchaseOrder
      tags:
        - Purchase Orders
      summary: Update a purchase order (PATCH alias)
      description: |
        Same as `PUT /purchase-orders/{id}`: only the fields you send change, and `items`, when sent,
        replaces every line. See that operation for the full behavior, including supplier currency
        (`currency_code`, `exchange_rate`, `items[].presentment_unit_price`).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the purchase order to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - order_date
                - supplier_id
                - items
              properties:
                order_date:
                  type: string
                  format: date
                  description: Date when the purchase order was created (YYYY-MM-DD)
                  example: '2024-01-15'
                supplier_id:
                  type: integer
                  description: ID of the supplier
                  example: 123
                warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the warehouse
                  example: 1
                location_id:
                  type: integer
                  nullable: true
                  description: ID of the location
                  example: 1
                order_status:
                  oneOf:
                    - type: string
                      enum:
                        - active
                        - production_started
                        - production_completed
                        - in_transit
                        - completed
                        - draft
                        - cancelled
                        - deleted
                    - type: integer
                      enum:
                        - 1
                        - 20
                        - 40
                        - 50
                        - 99
                        - 101
                        - 100
                        - -1
                  nullable: true
                  default: active
                  description: |
                    Milestone status (token or numeric id). Also accepts 30 (production_active) and 88 (delivered) by id.
                    Writes a milestone row and updates the PO header.

                    `draft` (101) and `cancelled` (100) are order states, not timeline milestones. They do not
                    count as incoming stock and the purchase order cannot take a new receipt while in either state.
                    Creating a purchase order with `order_status: draft` saves it as a draft from the start, so its
                    lines never post incoming. Moving it to an open milestone later posts incoming at that point.
                  example: active
                order_numbers:
                  type: array
                  nullable: true
                  description: Array of purchase order numbers used to identify the purchase order across various systems
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - PO-2024-001
                    - SUPPLIER-PO-123
                invoice_date:
                  type: string
                  format: date
                  nullable: true
                  description: Date when the purchase order was invoiced (YYYY-MM-DD)
                  example: '2024-01-16'
                incoterm:
                  type: string
                  nullable: true
                  description: 'Incoterm (delivery term) for the purchase order, given as a logistic code configured for the account (e.g. `exw`, `fob`, `ddp`). Matching is case-insensitive — both the lower-case code (`exw`) and its upper-case label (`EXW`) are accepted. Returned on the purchase order resource as `incoterm`. If omitted, the account default is applied.'
                  example: exw
                payment_terms:
                  type: string
                  nullable: true
                  description: 'Payment terms for the purchase order. Must exactly match one of the payment terms configured for the account (Manage > Suppliers); matching is case-sensitive (`Net 30` passes where `net 30` fails). Returned on the purchase order resource as `payment_terms`. If omitted, the account default is applied.'
                  example: Net 30
                currency_code:
                  type: string
                  nullable: true
                  minLength: 3
                  maxLength: 3
                  description: |
                    The purchase order's supplier currency: a three-letter code, in any case, listed by
                    `GET /currency/available`. `null` puts the purchase order in base currency. Sending your base
                    currency code explicitly also puts it in base currency, but stores the code (rate `1`) so responses
                    return it instead of `null`.
                    On create, omitting it applies the supplier's default currency (base currency when the supplier has
                    none). On update, omit to leave the currency and rate unchanged. Costs and totals stay in base currency.

                    Changing the currency restates `presentment_unit_price` at the new rate on every line the request
                    does not price (`unit_price` and costs do not change). Responds `422` on `currency_code` when the code
                    is unknown or no rate exists on or before `order_date` (send `exchange_rate` to supply one).
                  example: EUR
                exchange_rate:
                  type: number
                  nullable: true
                  minimum: 1.e-8
                  maximum: 9999999999
                  description: |
                    Base-currency units per 1 unit of `currency_code`. Requires `currency_code`. If omitted, the rate on or
                    before `order_date` is used. While the currency stays the same on update, the stored rate is kept and
                    a different value here is ignored.
                  example: 1.085
                total_shipping_cost:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  default: 0
                  description: Total shipping cost
                  example: 50
                total_tax:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  default: 0
                  description: Total tax amount
                  example: 80
                volume_target_cbm:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Target container volume in cubic metres (the container-fill gauge's denominator). When set, the
                    purchase-order response reports `volume_remaining_cbm` and `volume_fill_percent` against it.
                  example: 67
                public_note:
                  type: string
                  nullable: true
                  description: Public notes visible to suppliers
                  example: Please ship via express delivery
                private_note:
                  type: string
                  nullable: true
                  description: Internal private notes
                  example: Rush order - expedite processing
                requested_ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: Requested shipping date (YYYY-MM-DD)
                  example: '2024-01-20'
                arrival_due_date:
                  type: string
                  format: date
                  nullable: true
                  description: Expected arrival date (YYYY-MM-DD)
                  example: '2024-01-25'
                shipment_type:
                  type: string
                  nullable: true
                  enum:
                    - Air
                    - Sea
                    - Road
                    - Rail
                    - Express
                    - null
                  description: |
                    Freight mode used by the Transit Time Matrix. Matching is case-insensitive — `sea` and `SEA` are
                    stored as `Sea` — but any other value returns `422`. On update, omit to keep the stored value or send
                    `null` to clear it.

                    When a request sends `shipment_type` or `override_transit_days` and the PO has a warehouse, the
                    Original ETA (`original_arrival_due_date`) and current ETA (`arrival_due_date`) are filled from the
                    transit matrix if empty. Arrival dates sent in the same request are always kept as sent.

                    When the PO has no `requested_ship_date`, the count starts from today, unless the account's
                    `transit_eta_requires_ship_date` setting is on (off by default). Then both dates stay empty until the
                    PO has a requested ship date, and a `PUT /purchase-orders/{id}` that sends `requested_ship_date` to a
                    PO that already has a freight mode or override fills them while they are empty, even without
                    `shipment_type` or `override_transit_days` in the request. Transfer POs are not affected.
                  example: Sea
                original_arrival_due_date:
                  type: string
                  format: date
                  nullable: true
                  description: |
                    Frozen Original ETA (YYYY-MM-DD) — the arrival date as first planned, kept separate from the current
                    `arrival_due_date`. On update, omit to keep the stored value or send `null` to clear it.
                  example: '2024-01-25'
                override_transit_days:
                  type: integer
                  minimum: 0
                  maximum: 3650
                  nullable: true
                  description: |
                    Manual override of the transit-matrix calendar days used to derive the arrival date. `0` is allowed.
                    On update, omit to keep the stored value or send `null` to clear it.
                  example: 35
                ship_to:
                  type: object
                  nullable: true
                  description: Shipping address information
                  properties:
                    address_1:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Primary street address
                      example: 123 Main Street
                    address_2:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: 'Secondary address line (apt, suite, etc.)'
                      example: Suite 100
                    city:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: City name
                      example: Anytown
                    state:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: State or province
                      example: CA
                    zip:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: ZIP or postal code
                      example: '90210'
                    country:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Country name
                      example: United States
                    default_ship_to_address:
                      type: string
                      enum:
                        - ship_to_address
                        - warehouse
                      nullable: true
                      description: Default shipping address preference
                      example: warehouse
                items:
                  type: array
                  minItems: 1
                  description: Array of line items for the purchase order
                  items:
                    type: object
                    required:
                      - quantity
                    properties:
                      id:
                        type: integer
                        nullable: true
                        description: Line item ID (only used for updates)
                        example: 456
                      product_id:
                        type: integer
                        nullable: true
                        description: ID of the product (required if sku not provided)
                        example: 123
                      sku:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: SKU of the product (required if product_id not provided)
                        example: WIDGET-001
                      quantity:
                        type: number
                        format: float
                        minimum: 0.001
                        description: Quantity of the item ordered
                        example: 10.5
                      unit_price:
                        type: number
                        format: float
                        description: |
                          Price per unit, always in **base currency**. Required unless `presentment_unit_price` is sent.
                          On a foreign-currency purchase order, `presentment_unit_price` becomes this price divided by the
                          exchange rate. Do not send a supplier-currency amount here.
                        example: 49.99
                      presentment_unit_price:
                        type: number
                        format: float
                        nullable: true
                        minimum: 0
                        maximum: 99999999999
                        description: |
                          The line price in the purchase order's supplier currency, per ordered unit. `unit_price` becomes
                          this price times the exchange rate, and wins if both are sent. Without `unit_price`, a
                          base-currency purchase order responds `422` on this field.
                        example: 46
                      ordered_qty:
                        type: number
                        format: float
                        minimum: 0.001
                        nullable: true
                        description: Ordered quantity in base unit of measure (calculated automatically if not provided)
                        example: 10.5
                      received_qty:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        default: 0
                        description: Quantity already received
                        example: 5
                      expected_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Per-line expected ship date override. When omitted or null, the line inherits the purchase order''s header `requested_ship_date`.'
                        example: '2026-08-15'
                      expected_arrival_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Per-line expected arrival date override. When omitted or null, the line inherits the purchase order''s header `arrival_due_date`.'
                        example: '2026-08-20'
                      lot_id:
                        type: integer
                        nullable: true
                        description: ID of the product lot
                        example: 789
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number for the received item (used when the product has lot tracking enabled).
                        example: LOT-12345
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
                      uom_id:
                        type: integer
                        nullable: true
                        description: 'ID of the unit of measure for the item. If omitted, a default is resolved automatically in priority order: the product''s default purchase unit, then its default selling unit, then the base unit of its unit class, then the account''s base unit. If no unit of measure is supplied and no default can be resolved, the request fails with a 422 error.'
                        example: 1
                      source_sku:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Source SKU from the supplier
                        example: SUPPLIER-SKU-123
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with this line item
                        items:
                          type: string
                          maxLength: 255
                        example:
                          - priority
                          - fragile
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for this line item
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: boolean
                        example:
                          Lot Number: LOT-12345
                          Expiry Date: '2024-12-31'
                payments:
                  type: array
                  nullable: true
                  description: |
                    Array of payments for this purchase order. If provided, replaces all existing payments.
                    Totals are automatically recalculated after payments are updated.
                  items:
                    type: object
                    required:
                      - payment_date
                      - payment_type
                      - paid_amount
                    properties:
                      payment_date:
                        type: string
                        format: date
                        description: Date of the payment (YYYY-MM-DD)
                        example: '2024-01-15'
                      payment_type:
                        type: string
                        enum:
                          - cash
                          - credit_card
                          - debit_card
                          - check
                          - bank_transfer
                        description: Type of payment
                        example: check
                      paid_amount:
                        type: number
                        format: float
                        minimum: 0.01
                        description: Amount paid
                        example: 500
                      remarks:
                        type: string
                        maxLength: 1000
                        nullable: true
                        description: Payment remarks or notes
                        example: 'Check #1234'
                      external_id:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: External payment reference ID
                        example: PAY-EXT-12345
                custom_fields:
                  type: object
                  nullable: true
                  description: Custom field values for the purchase order
                  additionalProperties:
                    oneOf:
                      - type: string
                      - type: number
                      - type: boolean
                  example:
                    Customer PO: PO-98765
                    Priority Level: High
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the purchase order
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - urgent
                    - priority
                    - rush-order
      responses:
        '200':
          description: Purchase order updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '400':
          description: Bad request - validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Unprocessable entity - validation error (same rules as `PUT /purchase-orders/{id}`)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deletePurchaseOrder
      tags:
        - Purchase Orders
      summary: Delete a purchase order
      description: |
        Delete a purchase order. All associated stock counts and incoming quantities are automatically
        adjusted when the order is deleted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the purchase order to delete
      responses:
        '200':
          description: Purchase order deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Purchase order deleted successfully
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/extra-costs':
    get:
      operationId: listPurchaseOrderExtraCosts
      tags:
        - Purchase Orders
      summary: List extra costs
      description: |
        List the extra-cost lines stored on one purchase order, including lines created by cost rules and
        lines copied from a transfer order. Read only; there is no write on this path.

        These lines are not included on `GET /purchase-orders/{id}`.

        - The purchase order's `order_cost` and `total_cost` count only lines with `add_as_additional_fee: true`.
          This list returns every line.
        - Purchase order shipment fees are stored separately and are not included.
        - A purchase order with no lines returns `200` with `{ "data": [] }`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: One extra-cost line stored on a purchase order.
                      properties:
                        id:
                          type: integer
                          example: 15
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        supplier_purchase_order_id:
                          type: integer
                          description: ID of the purchase order the line belongs to.
                          example: 1001
                        name:
                          type: string
                          description: Line description.
                          example: Ocean freight
                        reference_number:
                          type: string
                          nullable: true
                          description: Optional reference.
                          example: INV-9
                        cost_type:
                          type: string
                          nullable: true
                          description: 'Kind of cost (for example `freight`, `duty`, `service`), or `null`.'
                          example: freight
                        quantity:
                          type: number
                          example: 2.5
                        unit_price:
                          type: number
                          example: 10
                        line_total:
                          type: number
                          description: The line amount.
                          example: 25
                        cost_allocation_type:
                          type: string
                          nullable: true
                          description: 'How the amount is spread across the purchase order lines, or `null`.'
                          example: UNIT_BASED_ALLOCATION
                        source_cost_rule_id:
                          type: integer
                          nullable: true
                          description: Set when a cost rule created the line; `null` for a manual line.
                        source_transfer_order_extra_cost_id:
                          type: integer
                          nullable: true
                          description: Set when the line was copied from a transfer order.
                        add_as_additional_fee:
                          type: boolean
                          description: '`true` when the line was mirrored onto the purchase order as an additional fee. Only these lines count toward the purchase order''s `order_cost` and `total_cost`.'
                          example: true
                        filters:
                          type: array
                          description: 'Category, tag, SKU or purchase order filters that scope the line.'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                example: 3
                              dimension:
                                type: string
                                example: CATEGORY
                              value:
                                type: string
                                example: '44'
                              label:
                                type: string
                                nullable: true
                                description: 'The resolved name for `value`, when one exists.'
                                example: Inbound freight
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/pdf':
    get:
      operationId: getPurchaseOrderPdf
      tags:
        - Purchase Orders
      summary: Purchase order PDF
      description: |
        Download a purchase order as a PDF, rendered with the account's default supplier purchase order
        template (the same default the in-app PDF export uses when no template is chosen). There is no
        template parameter.

        The response is generated synchronously and the body is the PDF file, not JSON.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order.
      responses:
        '200':
          description: PDF document
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '400':
          description: 'The PDF could not be generated. The body is `{ "error": "..." }`.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/messages':
    get:
      operationId: listPurchaseOrderMessages
      tags:
        - Purchase Orders
      summary: List messages
      description: |
        List the comments on a purchase order's staff thread, newest first. Both `internal` comments and
        comments `shared` with the supplier are returned. Read only.

        With a PII-restricted token, `body` and the author's `firstName` / `lastName` are `null`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: One comment on a purchase order's staff thread.
                      properties:
                        id:
                          type: integer
                          example: 501
                        body:
                          type: string
                          nullable: true
                          description: Comment text. A PII-restricted token gets `null`.
                          example: Supplier confirmed the ship date.
                        visibility:
                          type: string
                          enum:
                            - internal
                            - shared
                          description: '`internal` comments are seen by staff only; `shared` comments are also shown to the supplier on the supplier portal.'
                          example: internal
                        createdAt:
                          type: string
                          format: date-time
                        user:
                          type: object
                          nullable: true
                          description: 'The staff user who wrote the comment, or `null` when there is none.'
                          properties:
                            id:
                              type: integer
                              example: 12
                            firstName:
                              type: string
                              nullable: true
                              description: A PII-restricted token gets `null`.
                              example: Pat
                            lastName:
                              type: string
                              nullable: true
                              description: A PII-restricted token gets `null`.
                              example: Buyer
                        attachments:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                example: 77
                              filename:
                                type: string
                                example: packing-list.pdf
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/items':
    post:
      operationId: appendPurchaseOrderItems
      tags:
        - Purchase Orders
      summary: Append line items to a purchase order
      description: |
        Append one or more line items to an existing **active** purchase order without pruning any
        existing lines. This is the additive counterpart to `PUT /purchase-orders/{id}`, which is
        replace-all (any omitted line is deleted). The appended lines go through the same builders as
        `POST /purchase-orders` — unit-of-measure conversion, incoming-stock increment, cost recompute,
        and lot / custom-field / tag handling are identical to create — and the purchase order header
        totals (`order_cost`, `order_quantity`, `item_count`, tax/shipping) are recalculated afterward.

        Every appended line must reference an inventory-tracked product (type `PRODUCT` or `KIT`).
        Non-inventory items (e.g. service or fee SKUs) are rejected with a `422` on
        `items.{index}.product` before anything is written — record those charges as an extra cost
        on the purchase order instead.

        Only active purchase orders accept new lines; a `409 Conflict` is returned for
        completed / received / deleted orders.

        > **Note:** This endpoint is part of the container / Purchase-to-Order workflow and is gated by
        > the `PURCHASE_TO_ORDER` feature flag. Contact Luminous to have it enabled for your tenant.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order to append line items to
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  minItems: 1
                  description: Line items to append to the purchase order
                  items:
                    type: object
                    required:
                      - quantity
                    properties:
                      product_id:
                        type: integer
                        nullable: true
                        description: ID of the product (required if `sku` not provided)
                        example: 123
                      sku:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: SKU of the product (required if `product_id` not provided)
                        example: WIDGET-001
                      quantity:
                        type: number
                        format: float
                        minimum: 0.001
                        description: Quantity of the item ordered
                        example: 10.5
                      unit_price:
                        type: number
                        format: float
                        description: |
                          Price per unit, always in **base currency**. Required unless `presentment_unit_price`
                          is sent.
                        example: 49.99
                      presentment_unit_price:
                        type: number
                        format: float
                        nullable: true
                        minimum: 0
                        maximum: 99999999999
                        description: |
                          The line price in the purchase order's supplier currency, per ordered unit, converted
                          at the purchase order's stored exchange rate. Wins over `unit_price` if both are sent.
                        example: 46
                      ordered_qty:
                        type: number
                        format: float
                        minimum: 0.001
                        nullable: true
                        description: Ordered quantity in base unit of measure (calculated automatically if not provided)
                        example: 10.5
                      received_qty:
                        type: number
                        format: float
                        minimum: 0
                        nullable: true
                        description: Quantity already received
                        example: 0
                      expected_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Per-line expected ship date override. When omitted or null, the line inherits the PO header `requested_ship_date`.'
                        example: '2026-08-17'
                      expected_arrival_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Per-line expected arrival date override. When omitted or null, the line inherits the PO header `arrival_due_date`.'
                        example: '2026-08-22'
                      lot_id:
                        type: integer
                        nullable: true
                        description: ID of the product lot
                        example: 789
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number for the item (used when the product has lot tracking enabled)
                        example: LOT-12345
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
                      uom_id:
                        type: integer
                        nullable: true
                        description: 'ID of the unit of measure for the item. If omitted, a default is resolved automatically in priority order: the product''s default purchase unit, then its default selling unit, then the base unit of its unit class, then the account''s base unit. If no unit of measure is supplied and no default can be resolved, the request fails with a 422 error.'
                        example: 1
                      source_sku:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Source SKU from the supplier
                        example: SUPPLIER-SKU-123
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with this line item
                        items:
                          type: string
                          maxLength: 255
                        example:
                          - priority
                          - fragile
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for this line item
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: boolean
                        example:
                          Lot Number: LOT-12345
                volume_target_cbm:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: |
                    Optionally set or update the purchase order's target container volume in cubic metres
                    (the container-fill gauge's denominator) while appending line items.
                  example: 67
            examples:
              append_single_item:
                summary: Append a single line item
                value:
                  items:
                    - sku: WIDGET-001
                      quantity: 25
                      unit_price: 12.5
      responses:
        '201':
          description: Line items appended; the updated purchase order is returned
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: Conflict - the purchase order is not active and cannot accept new line items
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Unprocessable entity - validation error (e.g. a line item references a non-inventory product)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/items/{lineItemId}/lot':
    patch:
      operationId: updatePurchaseOrderItemLot
      tags:
        - Purchase Orders
      summary: Set or clear a purchase-order line's lot
      description: |
        Assign a lot to a single purchase-order line item, or clear the one it already has, **ahead of
        receiving**. The change is lot-only and stock-neutral — nothing is received, allocated, or costed
        — so an automated process can annotate the lots on an active purchase order without going through
        the replace-all `PUT /purchase-orders/{id}`.

        Provide exactly one intent:

        - **Assign** — supply a lot identifier (`lot_id`, or `lot_number` / `lot_name`). By default the
          lot must already exist for the line's product; pass `create_lot: true` to create it from
          `lot_number` on the fly (optionally seeding `production_date`, `expiry_date` and
          `manufacturer_code`).
        - **Clear** — send `clear_lot: true` to unassign the line's current lot.

        Unassigning is **explicit**: an absent, empty, or `null` lot value is never read as a request to
        clear — you must send `clear_lot: true`. This protects unattended callers, where an unset template
        variable (`"lot_id": ""`) would otherwise silently wipe a lot the office had already set. Send a
        lot identifier **or** `clear_lot`, never both.

        The lot is resolved against the line's own product; a lot belonging to a different product, an
        unknown `lot_number` without `create_lot`, or a non-lot-tracked product all return `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order the line item belongs to
        - in: path
          name: lineItemId
          required: true
          schema:
            type: integer
          description: ID of the purchase-order line item to set the lot on
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Supply a lot identifier to assign, or `clear_lot: true` to unassign. Exactly one of the
                two intents is required.
              properties:
                lot_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    ID of an existing lot on the line's product. Mutually exclusive with `lot_number` /
                    `lot_name`. A `null` or empty value is **not** treated as a clear — use `clear_lot`.
                  example: 3312
                lot_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: |
                    Lot number to resolve on the line's product. With `create_lot: true` a matching lot
                    is created if none exists. Mutually exclusive with `lot_id`.
                  example: LOT-2026-0042
                lot_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: 'Human-readable lot name, used when resolving by number.'
                  example: Batch 42
                create_lot:
                  type: boolean
                  description: |
                    When `true`, create the lot from `lot_number` if it does not already exist on the
                    product. When omitted or `false`, an unknown `lot_number` returns `422`.
                  example: true
                production_date:
                  type: string
                  format: date
                  nullable: true
                  description: Production date to seed on a newly created lot.
                  example: '2026-08-01'
                expiry_date:
                  type: string
                  format: date
                  nullable: true
                  description: Expiry date to seed on a newly created lot.
                  example: '2027-08-01'
                manufacturer_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Manufacturer code to seed on a newly created lot.
                  example: MFR-77
                clear_lot:
                  type: boolean
                  description: |
                    Send `true` to unassign the line's current lot. Cannot be combined with a lot
                    identifier.
                  example: false
            examples:
              assign_existing_lot:
                summary: Assign an existing lot by id
                value:
                  lot_id: 3312
              assign_by_number_creating:
                summary: 'Assign by lot number, creating it if needed'
                value:
                  lot_number: LOT-2026-0042
                  create_lot: true
                  production_date: '2026-08-01'
                  expiry_date: '2027-08-01'
              clear_lot:
                summary: Clear the line's lot
                value:
                  clear_lot: true
      responses:
        '200':
          description: Lot set or cleared on the line item
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: ID of the purchase-order line item
                        example: 78001
                      purchase_order_id:
                        type: integer
                        description: ID of the purchase order the line belongs to
                        example: 9001
                      product_id:
                        type: integer
                        description: ID of the line's product
                        example: 4501
                      lot_id:
                        type: integer
                        nullable: true
                        description: 'ID of the assigned lot, or `null` if the lot was cleared'
                        example: 3312
                      lot_number:
                        type: string
                        nullable: true
                        description: 'Lot number of the assigned lot, or `null` if cleared'
                        example: LOT-2026-0042
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Purchase order line item not found on this purchase order, or it has no product'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Unprocessable entity — no lot identifier and no `clear_lot`, both supplied at once, a lot
            belonging to a different product, an unknown `lot_number` without `create_lot`, or a
            non-lot-tracked product.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed':
    patch:
      operationId: updatePurchaseOrderItemClosed
      tags:
        - Purchase Orders
      summary: Close or reopen a purchase-order line
      description: |
        Close a single purchase-order line **short** — mark the rest of it as no longer expected — or
        reopen a previously closed line. Ordered and received quantities are **not** rewritten, so the
        purchase order keeps an accurate record of what was ordered versus what actually arrived.

        - **Close** — send `closed: true` with a `reason`. The line's `open_quantity` and
          `available_to_allocate` drop to `0`, incoming stock is recounted, and any open allocation pegs
          against the undelivered remainder are shrunk. A reason is required when closing, and a line
          with nothing left to receive cannot be closed.
        - **Reopen** — send `closed: false`. The close timestamp and reason are cleared and incoming
          stock is recounted. Allocation pegs removed on close are **not** restored.

        While a line is closed, `POST /receiving-reports` refuses any receipt that references it with
        `400`; reopen the line first.

        Both operations are idempotent: closing an already-closed line or reopening an open one returns
        the line's current state unchanged.

        `remaining_to_receive` is unaffected by closing; read `open_quantity` for what is still expected.
        The full-replace `PUT /purchase-orders/{id}` does not accept a closed flag, so resubmitting a line
        there can never close or reopen it by accident.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order the line item belongs to
        - in: path
          name: lineItemId
          required: true
          schema:
            type: integer
          description: ID of the purchase-order line item to close or reopen
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - closed
              properties:
                closed:
                  type: boolean
                  description: '`true` to close the line short, `false` to reopen it.'
                  example: true
                reason:
                  type: string
                  maxLength: 2000
                  nullable: true
                  description: |
                    Why the line is being closed. **Required (non-blank) when `closed` is `true`**;
                    ignored when reopening.
                  example: Supplier discontinued the item; remaining units will not ship.
            examples:
              close_line:
                summary: Close a line short
                value:
                  closed: true
                  reason: Supplier discontinued the item; remaining units will not ship.
              reopen_line:
                summary: Reopen a closed line
                value:
                  closed: false
      responses:
        '200':
          description: Line closed or reopened (or already in the requested state)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: ID of the purchase-order line item
                        example: 78001
                      purchase_order_id:
                        type: integer
                        description: ID of the purchase order the line belongs to
                        example: 9001
                      closed:
                        type: boolean
                        description: Whether the line is now closed
                        example: true
                      closed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: 'When the line was closed (ISO-8601), or `null` if open'
                        example: '2026-10-02T14:30:00+00:00'
                      close_reason:
                        type: string
                        nullable: true
                        description: 'Reason recorded when the line was closed, or `null` if open'
                        example: Supplier discontinued the item; remaining units will not ship.
                      open_quantity:
                        type: number
                        format: float
                        description: |
                          Still-expected quantity in the **ordered** unit of measure. `0` when closed;
                          otherwise `remaining_to_receive` floored at 0.
                        example: 0
                      remaining_to_receive:
                        type: number
                        format: float
                        description: Ordered minus received (ordered unit of measure). Not changed by closing.
                        example: 40
                      quantity:
                        type: number
                        format: float
                        description: Ordered quantity (ordered unit of measure)
                        example: 100
                      quantity_received:
                        type: number
                        format: float
                        description: 'Received quantity, expressed in the **ordered** unit of measure'
                        example: 60
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Purchase order line item not found, or it does not belong to this purchase order'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Unprocessable entity — `closed` missing or not a boolean, `reason` too long, closing without a
            reason, or closing a line that has nothing left to receive.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/items/{lineItemId}':
    patch:
      operationId: updatePurchaseOrderItem
      tags:
        - Purchase Orders
      summary: Edit a purchase-order line's quantity or unit price
      description: |
        Change one purchase-order line's `quantity` and/or `unit_price` in place. Send either field or
        both. The line keeps its `id`, so its bill and receipt links stay attached, and the other lines
        on the purchase order are left alone. By contrast, the full-replace `PUT /purchase-orders/{id}`
        prunes any line it is not sent.

        The edit goes through the same single-line save as the purchase-order grid. Incoming stock, the
        line total, the purchase-order totals and any unbilled receiving reports are updated, and the
        purchase-order-updated automations run. On a purchase order already sent to the supplier, the
        change is recorded as an API revision.

        - `quantity` is in the line's ordered unit of measure. It cannot be lower than what has already
          been received on the line (compared in the SKU's base unit); that returns `422`. Editing the
          quantity of a closed line also returns `422`.
        - `unit_price` is in the base currency. On a purchase order with a `currency_code`, the line's
          supplier-currency price (`presentment_unit_price`) is restated from it at the purchase order's
          exchange rate.

        The purchase order's payment schedule is recalculated in the same step and returned as
        `data.payment_schedule`. Milestones with nothing paid against them are re-derived from the new
        purchase-order total. A milestone that is paid or partly paid keeps its amount, and the unpaid
        percentage milestones absorb the difference so the schedule still adds up to the new total. If
        the schedule cannot be recalculated, the request fails with `500` and the line is left unchanged.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order the line item belongs to
        - in: path
          name: lineItemId
          required: true
          schema:
            type: integer
          description: ID of the purchase-order line item to edit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: At least one of `quantity` or `unit_price` is required.
              properties:
                quantity:
                  type: number
                  format: float
                  exclusiveMinimum: true
                  minimum: 0
                  description: |
                    New ordered quantity in the line's ordered unit of measure. Must be greater than `0`
                    and not less than the quantity already received. Required when `unit_price` is omitted.
                  example: 120
                unit_price:
                  type: number
                  format: float
                  minimum: 0
                  description: New unit price in the base currency. Required when `quantity` is omitted.
                  example: 4.25
            examples:
              quantity_and_price:
                summary: Change quantity and price
                value:
                  quantity: 120
                  unit_price: 4.25
              price_only:
                summary: Change only the price
                value:
                  unit_price: 12.5
      responses:
        '200':
          description: |
            Line updated. `data` is the edited line; `purchase_order` is the whole purchase order after
            the edit (same shape as `GET /purchase-orders/{id}`), so its new totals can be read without
            a second request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: ID of the purchase-order line item (unchanged by the edit)
                        example: 78001
                      purchase_order_id:
                        type: integer
                        description: ID of the purchase order the line belongs to
                        example: 9001
                      product_id:
                        type: integer
                        description: ID of the product on the line
                        example: 5521
                      quantity:
                        type: number
                        format: float
                        description: Ordered quantity (ordered unit of measure)
                        example: 120
                      ordered_qty:
                        type: number
                        format: float
                        description: Ordered quantity in the SKU's base unit
                        example: 120
                      quantity_received:
                        type: number
                        format: float
                        description: Quantity received so far (base unit)
                        example: 40
                      unit_price:
                        type: number
                        format: float
                        description: Unit price in the base currency
                        example: 4.25
                      presentment_unit_price:
                        type: number
                        format: float
                        nullable: true
                        description: 'Unit price in the supplier''s currency, or `null` when the purchase order has none'
                        example: null
                      line_total:
                        type: number
                        format: float
                        description: Line total in the base currency
                        example: 510
                      payment_schedule:
                        type: array
                        description: |
                          The purchase order's payment milestones after the edit, in sequence order.
                          Empty when the purchase order has no payment schedule.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Payment obligation ID (see `GET /payment-obligations/{id}`)'
                              example: 3301
                            milestone_label:
                              type: string
                              nullable: true
                              example: Deposit
                            milestone_type:
                              type: string
                              enum:
                                - deposit
                                - before_shipment
                                - on_shipment
                                - on_receipt
                                - on_delivery
                                - net_days
                                - final
                                - manual
                              example: deposit
                            sequence:
                              type: integer
                              example: 1
                            status:
                              type: string
                              enum:
                                - pending
                                - due
                                - partially_fulfilled
                                - fulfilled
                                - cancelled
                                - waived
                              example: fulfilled
                            percentage:
                              type: number
                              format: float
                              nullable: true
                              description: 'The milestone''s share of the purchase-order total, or `null` for a fixed-amount milestone'
                              example: 30
                            amount:
                              type: number
                              format: float
                              description: Amount of the milestone
                              example: 150
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid against the milestone so far
                              example: 150
                            due_amount:
                              type: number
                              format: float
                              description: '`amount` minus `paid_amount`, never below `0`'
                              example: 0
                            expected_amount:
                              type: number
                              format: float
                              nullable: true
                              description: |
                                `percentage` of the current purchase-order total. `null` when the
                                milestone has no percentage.
                              example: 153
                            over_under:
                              type: number
                              format: float
                              nullable: true
                              description: |
                                On a paid or partly paid percentage milestone, how far its fixed
                                `amount` sits above (positive) or below (negative) `expected_amount`.
                                `null` on unpaid milestones, which follow the total.
                              example: -3
                  purchase_order:
                    description: |
                      The updated purchase order, in the same shape as `GET /purchase-orders/{id}`,
                      with its totals recomputed after the line change.
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: |
            Purchase order line item not found, or it does not belong to this purchase order
            (`Purchase order line item not found.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error: neither `quantity` nor `unit_price` sent, `quantity` not greater than `0`,
            `unit_price` negative, or `quantity` below what was received
            (`Quantity cannot be less than the {received} already received on this line.`, with the
            received quantity shown without trailing zeros, e.g. `60`), or a `quantity` change on a closed line
            (`This line is closed. Reopen it before changing quantity.`). Also returned
            with the service message when the line save fails.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '500':
          description: |
            The payment schedule could not be recalculated for the new total, so the edit was rolled
            back and the line is unchanged
            (`The payment schedule could not be recalculated, so the line edit was not saved.`).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/allocate':
    post:
      operationId: allocatePurchaseOrder
      tags:
        - Purchase Orders
      summary: Allocate a sales order onto a purchase order
      description: |
        Peg one or more sales-order lines onto an existing **active** purchase order so they auto-fulfil
        when the purchase order is received (the "add-to-existing-PO" step of the Purchase-to-Order /
        container workflow). The allocation appends the required line to the purchase order and creates a
        peg from the sales-order line to it; on receipt the peg is released and an auto-generated
        fulfillment order ships the pegged quantity.

        For each line, `fulfillment_channel_id` is optional — when omitted the service resolves the
        channel from the line's routing suggestion and **strict-fails with `422`** if routing is
        ambiguous, rather than risk mis-pinning the fulfillment order. In that case, retry with an
        explicit `fulfillment_channel_id`.

        Only active purchase orders accept new allocations; a `409 Conflict` is returned otherwise.

        > **Note:** This endpoint is gated by the `PURCHASE_TO_ORDER` feature flag. Contact Luminous to
        > have it enabled for your tenant.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order to allocate onto
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sales_order_id
                - lines
              properties:
                sales_order_id:
                  type: integer
                  description: ID of the sales order whose lines are being allocated
                  example: 5001
                ship_complete:
                  type: boolean
                  description: |
                    When `true`, attempt to release the whole sales order as a single ship-complete
                    fulfillment once every held line is coverable. Omit to leave the order's existing
                    ship-complete behavior unchanged.
                  example: false
                lines:
                  type: array
                  minItems: 1
                  description: Sales-order lines to peg onto this purchase order
                  items:
                    type: object
                    required:
                      - sales_order_item_id
                      - quantity
                    properties:
                      sales_order_item_id:
                        type: integer
                        description: ID of the sales-order line item (must belong to `sales_order_id`)
                        example: 78001
                      quantity:
                        type: number
                        format: float
                        minimum: 0.001
                        description: Quantity to allocate from this line onto the purchase order
                        example: 10
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                        description: |
                          Fulfillment channel to pin the auto-generated fulfillment order to. Optional —
                          resolved from the line's routing suggestion when omitted (strict-fails with
                          `422` if routing is ambiguous).
                        example: 42
                      sales_item_id:
                        type: integer
                        nullable: true
                        description: |
                          Component ("sales item") the allocation targets. A kit sales-order line explodes
                          into one row per component and a purchase-order line covers a single SKU, so a kit
                          allocation must name the specific component being pegged. Omit for simple
                          (non-kit) lines, where the sales-order line item alone identifies the SKU.
                        example: 91001
                      split_mode:
                        type: string
                        enum:
                          - atomic
                          - component
                        default: atomic
                        description: |
                          How a kit's components are sourced across warehouses. `atomic` (default) ships a
                          kit's components assembled from a single warehouse; `component` allows a
                          per-component cross-warehouse split. Component-level splitting is a future phase
                          and is currently rejected for kits by the service.
                        example: atomic
            examples:
              allocate_line:
                summary: Allocate a single sales-order line
                value:
                  sales_order_id: 5001
                  lines:
                    - sales_order_item_id: 78001
                      quantity: 10
      responses:
        '200':
          description: Sales order lines allocated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      pegsCreated:
                        type: integer
                        description: Number of allocation pegs created
                        example: 1
                      purchaseOrderIds:
                        type: array
                        description: IDs of the purchase orders touched by the allocation
                        items:
                          type: integer
                        example:
                          - 9001
                      fulfillmentOrderIds:
                        type: array
                        description: IDs of any fulfillment orders generated by the allocation
                        items:
                          type: integer
                        example: []
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order or sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: Conflict - the purchase order is not active and cannot take new allocations
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Unprocessable entity - validation error, a line item that does not belong to the sales
            order, or an unresolvable fulfillment channel.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/payments':
    post:
      operationId: createPurchaseOrderPayment
      tags:
        - Purchase Orders
      summary: Create a payment for a purchase order
      description: |
        Create a new payment for a purchase order. The purchase order totals (`total_paid` and `total_due`) 
        are automatically recalculated after the payment is created.

        ## Payment Types
        Valid payment types: `cash`, `credit_card`, `debit_card`, `check`, `bank_transfer`

        ## Total Recalculation
        After creating a payment, the system automatically:
        - Updates `total_paid` by adding the new payment amount
        - Recalculates `total_due` as `total_cost - total_paid`
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - payment_date
                - payment_type
                - paid_amount
              properties:
                payment_date:
                  type: string
                  format: date
                  description: Date of the payment (YYYY-MM-DD)
                  example: '2024-01-15'
                payment_type:
                  type: string
                  enum:
                    - cash
                    - credit_card
                    - debit_card
                    - check
                    - bank_transfer
                  description: Type of payment
                  example: check
                paid_amount:
                  type: number
                  format: float
                  minimum: 0.01
                  description: Amount paid
                  example: 500
                remarks:
                  type: string
                  maxLength: 1000
                  nullable: true
                  description: Payment remarks or notes
                  example: 'Check #1234'
                external_id:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: External payment reference ID
                  example: PAY-EXT-12345
            examples:
              check_payment:
                summary: Check payment
                value:
                  payment_date: '2024-01-15'
                  payment_type: check
                  paid_amount: 500
                  remarks: 'Check #1234'
              bank_transfer:
                summary: Bank transfer payment
                value:
                  payment_date: '2024-01-15'
                  payment_type: bank_transfer
                  paid_amount: 1000
                  external_id: PAY-EXT-12345
      responses:
        '201':
          description: Payment created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '400':
          description: Bad request - validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/payments/{paymentId}':
    put:
      operationId: updatePurchaseOrderPayment
      tags:
        - Purchase Orders
      summary: Update a purchase order payment
      description: |
        Update an existing payment for a purchase order. All fields are optional - only provided fields will be updated.
        The purchase order totals (`total_paid` and `total_due`) are automatically recalculated after the payment is updated.

        ## Payment Types
        Valid payment types: `cash`, `credit_card`, `debit_card`, `check`, `bank_transfer`

        ## Total Recalculation
        After updating a payment, the system automatically:
        - Recalculates `total_paid` by summing all payment amounts
        - Recalculates `total_due` as `total_cost - total_paid`

        ## Prepayment-backed payments
        A payment that records an active vendor prepayment cannot be deleted on its own — the
        request is refused with a `422` and the payment is kept. Void the prepayment instead;
        deleting just the payment would leave the prepayment balance in place.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order
        - in: path
          name: paymentId
          required: true
          schema:
            type: integer
          description: ID of the payment to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                payment_date:
                  type: string
                  format: date
                  description: Date of the payment (YYYY-MM-DD)
                  example: '2024-01-16'
                payment_type:
                  type: string
                  enum:
                    - cash
                    - credit_card
                    - debit_card
                    - check
                    - bank_transfer
                  description: Type of payment
                  example: check
                paid_amount:
                  type: number
                  format: float
                  minimum: 0.01
                  description: Amount paid
                  example: 600
                remarks:
                  type: string
                  maxLength: 1000
                  nullable: true
                  description: Payment remarks or notes
                  example: 'Updated check #1234'
                external_id:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: External payment reference ID
                  example: PAY-EXT-12345
            examples:
              update_amount:
                summary: Update payment amount
                value:
                  paid_amount: 600
              update_all_fields:
                summary: Update all payment fields
                value:
                  payment_date: '2024-01-16'
                  payment_type: bank_transfer
                  paid_amount: 600
                  remarks: Updated payment
                  external_id: PAY-EXT-12345
      responses:
        '200':
          description: Payment updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '400':
          description: Bad request - validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order or payment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deletePurchaseOrderPayment
      tags:
        - Purchase Orders
      summary: Delete a purchase order payment
      description: |
        Delete a payment from a purchase order. The purchase order totals (`total_paid` and `total_due`) 
        are automatically recalculated after the payment is deleted.

        ## Total Recalculation
        After deleting a payment, the system automatically:
        - Recalculates `total_paid` by summing all remaining payment amounts
        - Recalculates `total_due` as `total_cost - total_paid`
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order
        - in: path
          name: paymentId
          required: true
          schema:
            type: integer
          description: ID of the payment to delete
      responses:
        '200':
          description: Payment deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Payment deleted successfully
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order or payment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The payment records an active vendor prepayment. Void the prepayment instead.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: 'This payment records prepayment #42. Void the prepayment instead — deleting the payment on its own would leave the prepayment balance in place.'
  '/purchase-orders/{purchaseOrderId}/payments/{paymentId}/move':
    post:
      operationId: movePurchaseOrderPayment
      tags:
        - Purchase Orders
      summary: Move a purchase order payment
      description: |
        Move all or part of a payment from one purchase order to another purchase order of the
        same vendor.

        - **Whole move** (no `amount`, or `amount` equal to the payment): the payment row itself
          is moved to the target purchase order.
        - **Partial move**: the source payment is reduced by `amount` and a new payment for
          `amount` is added on the target, with the same payment date, type and remarks.

        Both purchase orders have `total_paid` / `total_due` recalculated, and both get an
        activity-log entry recording who moved the payment and the before/after totals. Every
        check runs before anything is written, so a refused move changes nothing.

        ## Refusals (`422`)
        - The target is the same purchase order (`The payment is already on this purchase order.`)
        - The target belongs to a different vendor
        - The target is in a different currency from the payment (a PO payment is in its PO's currency)
        - The payment records a vendor prepayment — move the prepayment instead with
          `POST /prepayments/{id}/transfer`
        - The payment is synced (or syncing) to QuickBooks — delete it and record it on the right
          purchase order instead
        - `amount` is not greater than zero, or exceeds the payment amount
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the purchase order the payment is currently on
        - in: path
          name: paymentId
          required: true
          schema:
            type: integer
          description: ID of the payment to move
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - target_purchase_order_id
              properties:
                target_purchase_order_id:
                  type: integer
                  minimum: 1
                  description: Purchase order to move the payment to. Must belong to the same vendor and use the same currency.
                  example: 1045
                amount:
                  type: number
                  format: float
                  minimum: 0.01
                  nullable: true
                  description: Amount to move. Defaults to the whole payment. Cannot exceed the payment amount.
                  example: 250
      responses:
        '200':
          description: Payment moved. Returns both purchase orders with recalculated totals.
          content:
            application/json:
              schema:
                type: object
                properties:
                  source_purchase_order:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                  target_purchase_order:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the purchase order
                      order_numbers:
                        type: array
                        description: List of purchase order numbers
                        items:
                          type: string
                      created_by:
                        type: integer
                        nullable: true
                        description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                        example: 12
                      created_by_name:
                        type: string
                        nullable: true
                        description: 'First and last name of the `created_by` user, or `null` when there is no such user or no name. A PII-restricted token always gets `null` (the `created_by` ID is still returned). Returned by `GET /purchase-orders`, `GET /purchase-orders/{id}` and the purchase order payment endpoints; the create, update and append-items responses, and purchase orders embedded in other responses (receiving reports, inbound shipments), have no `created_by_name` key.'
                        example: Pat Buyer
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the purchase order was last updated
                      order_status:
                        type: string
                        enum:
                          - active
                          - inactive
                          - deleted
                        description: Status of the purchase order
                      order_date:
                        type: string
                        format: date
                        description: Date when the purchase order was created
                      invoice_date:
                        type: string
                        format: date
                        description: Date when the purchase order was invoiced
                      arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expected arrival date for the order
                      requested_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Requested shipping date
                      original_arrival_due_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Frozen Original ETA — the arrival date as first planned, distinct from the current `arrival_due_date`. Null when unset.'
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                          - null
                        description: Freight mode used by the Transit Time Matrix. Null when unset.
                      override_transit_days:
                        type: integer
                        nullable: true
                        description: Manual override of the transit-matrix calendar days used to derive the arrival date. Null when unset.
                      order_type:
                        type: integer
                        description: Type of the order
                      incoterm:
                        type: string
                        description: International Commercial Terms for the order
                      tracking_info:
                        type: string
                        nullable: true
                        description: Tracking information for the order
                      payment_terms:
                        type: string
                        description: Payment terms for the order
                      supplier_id:
                        type: integer
                        description: ID of the supplier
                      item_count:
                        type: integer
                        description: Number of unique items in the order
                      total_qty_ordered:
                        type: number
                        format: float
                        description: Total quantity of line items ordered
                      total_qty_received:
                        type: number
                        format: float
                        description: Total quantity of line items received
                      total_qty_remaining:
                        type: number
                        format: float
                        description: Total quantity of line items remaining to be received (ordered - received)
                      receipt_status:
                        type: string
                        nullable: true
                        enum:
                          - awaiting_shipment
                          - partially_received
                          - fully_received
                        description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                      currency_code:
                        type: string
                        nullable: true
                        description: 'The purchase order''s supplier currency. `null` for a purchase order in the account''s base currency, unless the base currency code was sent explicitly through the API, in which case it is returned. Costs and totals are always in base currency.'
                        example: EUR
                      exchange_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Base-currency units per 1 unit of `currency_code`. `null` for a base-currency purchase order.
                        example: 1.085
                      order_cost:
                        type: number
                        format: float
                        description: Cost of the order before tax and shipping — line items plus additional fees (including automatic cost-rule fees)
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping_cost:
                        type: number
                        format: float
                        description: Total shipping cost
                      total_cost:
                        type: number
                        format: float
                        description: Total cost including tax and shipping
                      total_paid:
                        type: number
                        format: float
                        description: Total amount paid
                      total_due:
                        type: number
                        format: float
                        description: Total amount due
                      total_volume_cbm:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping volume in cubic metres, rolled up from each line item's
                          box/carton dimensions × ordered quantity. `0` when no line item's SKU has usable dimensions.
                      total_weight_kg:
                        type: number
                        format: float
                        description: |
                          Container-fill summary: total shipping weight in kilograms, rolled up from each line item's
                          per-unit weight × ordered quantity. `0` when no line item's SKU has a weight set.
                      lines_missing_dimensions:
                        type: integer
                        description: |
                          Number of line items whose SKU lacks usable box/carton dimensions and therefore contribute
                          nothing to `total_volume_cbm`. Useful for flagging an incomplete container-fill estimate.
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Target container volume in cubic metres (the fill gauge's denominator), or `null` when no
                          target has been set for this purchase order.
                      volume_remaining_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Remaining container volume in cubic metres, computed as `max(0, volume_target_cbm - total_volume_cbm)`.
                          `null` when `volume_target_cbm` is not set.
                      volume_fill_percent:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          How full the container is, as a percentage (`total_volume_cbm / volume_target_cbm × 100`).
                          `null` when `volume_target_cbm` is not set or zero.
                      down_payment:
                        type: number
                        format: float
                        description: Down payment amount
                      public_note:
                        type: string
                        nullable: true
                        description: Public notes
                      private_note:
                        type: string
                        nullable: true
                        description: Private notes
                      starred:
                        type: boolean
                        description: Whether the order is starred
                      items:
                        type: array
                        description: Line items in the purchase order. Each is the same `PurchaseOrderItem` object served by `GET /purchase-orders/items`; on this detail endpoint the per-line `allocations` array is populated.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Line item ID
                            purchase_order_id:
                              type: integer
                              description: ID of the parent purchase order
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            quantity:
                              type: number
                              format: float
                              description: 'How much was ordered, counted in the line''s **ordered** unit of measure (the unit `ordered_unit_of_measure` names). A line ordered as 10 cases of 12 reads `10` here and `120` in `quantity_ordered`.'
                            presentment_unit_price:
                              type: number
                              format: float
                              nullable: true
                              description: 'The line price in the purchase order''s supplier currency, per ordered unit. `null` on a base-currency purchase order.'
                            unit_price:
                              type: number
                              format: float
                              description: 'Price per unit, always in base currency. For a line written through this API whose ordered unit converts, this is per base unit; a line saved on the PO screen keeps it per ordered unit.'
                            unit:
                              type: string
                              nullable: true
                              description: Unit of measure
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            discount_amount:
                              type: number
                              format: float
                              description: Discount amount
                            line_total:
                              type: number
                              format: float
                              description: Total for this line item
                            expected_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected ship date override. When null, this line inherits the purchase order''s header `requested_ship_date`.'
                            expected_arrival_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Per-line expected arrival date override. When null, this line inherits the purchase order''s header `arrival_due_date`.'
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header requested ship date, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_ship_date` override.'
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header current ETA, copied onto every line. It is the same for every line of a PO and differs from the per-line `expected_arrival_date` override.'
                            shipment_type:
                              type: string
                              nullable: true
                              enum:
                                - Air
                                - Sea
                                - Road
                                - Rail
                                - Express
                                - null
                              description: 'Purchase order header freight mode, copied onto every line. It is the same for every line of a PO and is not a per-line value.'
                            original_arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: 'Purchase order header frozen Original ETA (the arrival date as first planned), copied onto every line.'
                            override_transit_days:
                              type: integer
                              nullable: true
                              description: 'Purchase order header manual override of the transit-matrix calendar days, copied onto every line.'
                            quantity_received:
                              type: number
                              format: float
                              description: 'How much has been received against this line, summed across receipts, in the **base** unit of measure. Each receipt line records the unit it was received in and stores its quantity already converted to base, so this total is reliably in one unit (DV-4147). It previously read a roll-up column that some receiving paths populated without converting, so this figure is no longer approximate on a line whose ordered and base units differ.'
                            received_quantity:
                              type: number
                              format: float
                              deprecated: true
                              description: '**Deprecated (2026-08-13).** Identical value to `quantity_received`; use that field instead. Both keys are emitted from one computed value and can never diverge. No sunset date — the alias is retained indefinitely for backward compatibility.'
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'The same order as `quantity`, converted to the line''s **base** unit of measure — not a second order. A line ordered as 10 cases of 12 reads `120` here and `10` in `quantity`.'
                            quantity_shipped:
                              type: number
                              format: float
                              description: 'How much has shipped against this line, in the **ordered** unit of measure. Summed across every shipment line, each converted from the unit it was recorded in. Gross: no shipment-status filter.'
                            quantity_billed:
                              type: number
                              format: float
                              description: 'How much has been billed against this line, in the **ordered** unit of measure. Summed across every linked bill line, each converted from its own unit. Gross and status-agnostic — drafts count, credits and returns are not netted off — and excluding lines whose bill was deleted.'
                            quantity_allocated:
                              type: number
                              format: float
                              description: 'How much of this incoming line is already committed to a sales order, in the **base** unit of measure. The open purchase-to-order reservation; `0` on an unpegged line.'
                            quantity_released:
                              type: number
                              format: float
                              description: 'Gross quantity released from pegs on this line — the received/fulfilled portion of the purchase-to-order reservation, in the **base** unit of measure. Additive to `quantity_allocated` (which stays open-only, so releasing a peg does not shrink it); `0` on an unpegged line.'
                            under_covered_quantity:
                              type: number
                              format: float
                              description: 'How much of the open reservation on this line can no longer be covered by the effective remaining quantity — for example when the parent PO is **Completed** short, leaving effective remaining at `0`. Additive; `0` on an unpegged line or one whose open reservation is still fully coverable.'
                            remaining_to_ship:
                              type: number
                              format: float
                              description: '`quantity − quantity_shipped`, in the **ordered** unit of measure. **Signed** — over-shipping off a PO is a supported flow reconciled on the bill, so an over-shipped line reports the overage as a negative rather than `0`.'
                            remaining_to_receive:
                              type: number
                              format: float
                              description: '`quantity − quantity_received`. **Signed**, for the same reason as `remaining_to_ship`. The one figure here that spans two bases — `quantity` is the ordered unit and the received quantity is nominally the base unit (DV-4119) — so treat it as approximate on a line whose two units differ. Closing a line short does **not** change this figure — read `open_quantity` for what is still expected.'
                            open_quantity:
                              type: number
                              format: float
                              description: 'Still-expected quantity in the **ordered** unit of measure. `0` when the line is closed short; otherwise `remaining_to_receive` floored at 0. Integrators that treat "remaining" as "still coming" should read this field. See `PATCH /purchase-orders/{purchaseOrderId}/items/{lineItemId}/closed`.'
                              example: 40
                            closed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: 'When the line was closed short (ISO-8601), or `null` if the line is open.'
                              example: null
                            close_reason:
                              type: string
                              nullable: true
                              description: 'Reason recorded when the line was closed short, or `null` if the line is open.'
                              example: null
                            available_to_allocate:
                              type: number
                              format: float
                              description: 'How much of this incoming line is still free to commit to a sales order, in the **base** unit of measure: `max(0, open quantity − quantity_allocated)`, where the open quantity is ordered minus received. **Floored at 0** (unlike the two signed figures above) because you cannot commit a negative quantity. A closed line reports `0`. Answers what is left to promise, not how far off the PO the delivery landed. Renamed from `quantity_remaining` (DV-4144).'
                            volume_cbm:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping volume in cubic metres, derived from the SKU's box dimensions
                                (falling back to carton dimensions). `0` when the SKU has no usable dimensions. Part of the
                                container-fill summary.
                            line_volume_cbm:
                              type: number
                              format: float
                              description: |
                                This line's total shipping volume in cubic metres (`volume_cbm` × `quantity_ordered`).
                            weight_kg:
                              type: number
                              format: float
                              description: |
                                Per-unit shipping weight in kilograms. `0` when the SKU has no weight set. Part of the
                                container-fill summary.
                            line_weight_kg:
                              type: number
                              format: float
                              description: |
                                This line's total shipping weight in kilograms (`weight_kg` × `quantity_ordered`).
                            allocations:
                              type: array
                              description: |
                                Which sales orders currently hold the allocation on this line. Only populated on the
                                single purchase-order detail endpoint (`GET /purchase-orders/{id}`); always an empty
                                array on the list endpoint and for non-allocated lines.
                              items:
                                type: object
                                properties:
                                  sales_order_id:
                                    type: integer
                                    description: ID of the sales order holding the allocation
                                  sales_order_number:
                                    type: string
                                    nullable: true
                                    description: Human-readable sales order number
                                  quantity_allocated:
                                    type: number
                                    format: float
                                    description: Open quantity this sales order has pegged to the line
                                  quantity_released:
                                    type: number
                                    format: float
                                    description: 'Quantity already released from this sales order''s pegs on the line (the received/fulfilled portion). Rows are retained while either `quantity_allocated` or `quantity_released` is greater than `0`, so a fully-received allocation still appears with its release history.'
                                  peg_ids:
                                    type: array
                                    items:
                                      type: integer
                                    description: |
                                      IDs of the pegs backing this allocation. Pass these to
                                      `POST /purchase-orders/reverse-allocation` (which is peg-scoped) to reverse an
                                      allocation made through the API. Allocate, read the peg ids back from
                                      `GET /purchase-orders/{id}`, then reverse them.
                            source_sku:
                              type: string
                              nullable: true
                              description: Source SKU from the supplier
                            product:
                              type: object
                              nullable: true
                              description: Associated product information
                              properties:
                                id:
                                  type: integer
                                  description: Product ID
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Product retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Product wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Product unit cost
                                product_weight:
                                  type: number
                                  format: float
                                  description: Product weight
                                product_length:
                                  type: number
                                  format: float
                                  description: Product length (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Product width (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Product height (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product is sellable
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                image_url:
                                  type: string
                                  nullable: true
                                  description: Product image URL
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Product variant attributes
                                sku:
                                  type: string
                                  description: Product internal SKU
                                upc:
                                  type: string
                                  description: Product UPC/Barcode
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Product creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Product last update timestamp
                            base_unit_of_measure:
                              type: object
                              nullable: true
                              description: Base unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            ordered_unit_of_measure:
                              type: object
                              nullable: true
                              description: Ordered unit of measure
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                abbreviation:
                                  type: string
                            lot:
                              type: object
                              nullable: true
                              description: Product lot information
                              properties:
                                id:
                                  type: integer
                                lot_number:
                                  type: string
                                expiration_date:
                                  type: string
                                  format: date
                                  nullable: true
                      supplier:
                        type: object
                        properties:
                          id:
                            type: integer
                          status:
                            type: integer
                          name:
                            type: string
                          description:
                            type: string
                          street_address:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          zip:
                            type: string
                          country:
                            type: string
                          contact_name:
                            type: string
                          contact_email:
                            type: string
                          contact_phone:
                            type: string
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          custom_fields:
                            type: object
                            description: Read-only map of the supplier's custom field values as label => value pairs. Always a JSON object; empty when no custom fields are set.
                            example:
                              Region: Southwest
                              Preferred Carrier: UPS
                      payments:
                        type: array
                        description: Array of payments for this purchase order
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            payment_date:
                              type: string
                              format: date
                              description: Date of the payment
                            payment_type:
                              type: string
                              enum:
                                - cash
                                - credit_card
                                - debit_card
                                - check
                                - bank_transfer
                              description: Type of payment
                            paid_amount:
                              type: number
                              format: float
                              description: Amount paid
                            remarks:
                              type: string
                              nullable: true
                              description: Payment remarks or notes
                            external_id:
                              type: string
                              nullable: true
                              description: External payment reference ID
                            created_by:
                              type: object
                              description: User who created the payment
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: User full name
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the payment was last updated
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address information
                        properties:
                          address_1:
                            type: string
                            nullable: true
                            description: Primary street address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address line
                          city:
                            type: string
                            nullable: true
                            description: City name
                          state:
                            type: string
                            nullable: true
                            description: State or province
                          zip:
                            type: string
                            nullable: true
                            description: ZIP or postal code
                          country:
                            type: string
                            nullable: true
                            description: Country name
                          default_ship_to_address:
                            type: string
                            enum:
                              - ship_to_address
                              - warehouse
                            nullable: true
                            description: Default shipping address preference
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the destination warehouse. Always present (null when the PO has no warehouse set).
                      location_id:
                        type: integer
                        nullable: true
                        description: ID of the destination location within the warehouse. Always present (null when the PO has no location set).
                      warehouse:
                        type: object
                        nullable: true
                        description: Expanded warehouse object. Present when the warehouse relation is loaded (list and detail responses); omitted when the PO has no warehouse.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        nullable: true
                        description: Expanded location object. Present when the location relation is loaded (list and detail responses); omitted when the PO has no location.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
                      fulfillment_orders:
                        type: array
                        description: Linked fulfillment orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_number:
                              type: string
                              nullable: true
                            order_status:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        description: 'Custom field values on the purchase order as label => value pairs. Field definitions are available via `GET /custom-fields?object_type=purchase-orders`; values can also be read and written via `/purchase-orders/{id}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Purchase order, target purchase order, or payment not found'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error or the move was refused (see description)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/push-inbound-shipment':
    post:
      operationId: pushPurchaseOrderInboundShipment
      tags:
        - Purchase Orders
      summary: Push purchase order as inbound shipment to WMS
      description: |
        Push the supplier purchase order to its externally managed warehouse (TrackStar inbound shipment create).
        Requires warehouse group with external management and OMS SKU mappings.

        When the warehouse group is externally managed by an **EDI** account, the push sends an EDI 943 to the 3PL
        instead of creating a WMS inbound shipment. No OMS SKU mappings are needed (the 943 carries Luminous SKUs), and an
        inbound shipment (`source` `edi`) is recorded already reconciled to the purchase order. The 3PL's EDI 944 receipts
        are later posted as receiving reports against the purchase order. Returns `422` when the EDI account has no 943
        transaction key, the purchase order has no product lines, the 943 was already sent and has receipts against it,
        or the 943 could not be sent.

        Returns `409` when `sync_status` is already `synced` unless `force` is true.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                force:
                  type: boolean
                  default: false
                  description: 'When true, push even if already synced (may duplicate WMS inbounds).'
      responses:
        '200':
          description: Push succeeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      purchase_order_id:
                        type: integer
                      sync_status:
                        type: string
                      last_synced_at:
                        type: string
                        format: date-time
                        nullable: true
                      external_shipment_id:
                        type: string
                        nullable: true
                      external_system_url:
                        type: string
                        nullable: true
                      inbound_shipment:
                        type: object
                        nullable: true
        '400':
          description: Warehouse not externally managed or missing
        '404':
          description: Purchase order not found
        '409':
          description: Already synced (use force=true to push again)
        '422':
          description: Validation error or unmapped OMS SKUs
  '/purchase-orders/{purchaseOrderId}/shipments':
    get:
      operationId: getPurchaseOrderShipmentsByPurchaseOrder
      tags:
        - Purchase Order Shipments
      summary: List shipments for a purchase order
      description: |
        Get a paginated list of shipments scoped to a specific purchase order. Returns the same
        shape as `GET /purchase-order-shipments`, filtered to shipments that have at least one
        line item tied to `{purchaseOrderId}`.

        Supports the same filter parameters as `GET /purchase-order-shipments`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: reference_number
          schema:
            type: string
          description: Filter by reference number
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                        reference_number:
                          type: string
                          description: Supplier reference number for this shipment
                        total_shipping_cost:
                          type: number
                          format: float
                        shipping_date:
                          type: string
                          format: date-time
                          nullable: true
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: Destination warehouse ID
                        shipment_status_id:
                          type: integer
                          nullable: true
                        notes:
                          type: string
                          nullable: true
                          description: Free-text notes on the shipment
                        tracking_number:
                          type: string
                          nullable: true
                          description: Carrier tracking number
                        shipped_by:
                          type: string
                          nullable: true
                          enum:
                            - Freight
                            - Supplier
                          description: Who is responsible for shipping
                        shipment_type:
                          type: string
                          nullable: true
                          enum:
                            - Air
                            - Sea
                            - Road
                            - Rail
                            - Express
                          description: Mode of transport for the shipment
                        estimated_arrival:
                          type: string
                          format: date
                          nullable: true
                          description: Estimated arrival date
                        is_closed:
                          type: boolean
                          description: 'Whether the shipment is marked as closed. Closing has no enforced behavior (it does not gate edits, pushes, or receiving) and is provided for filtering and reporting. It can be set manually, and is also set to `true` automatically when a receiving report brings every shipment line to fully received (the shipment status is moved to its "received"/Arrived mapping at the same time). Automatic closing never reopens a shipment — if received quantity later drops (e.g. a voided receipt), `is_closed` stays `true`.'
                        volume_target_cbm:
                          type: number
                          format: float
                          nullable: true
                          description: Container volume target in cubic meters. Null when unset.
                        sync_status:
                          type: string
                          nullable: true
                          description: 'Integration sync status (e.g. "synced", "unsynced")'
                        last_synced_at:
                          type: string
                          format: date-time
                          nullable: true
                        last_synced_status:
                          description: Raw sync status payload from the integration (shape varies)
                          nullable: true
                        shipment_status:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        warehouse:
                          allOf:
                            - type: object
                              properties:
                                id:
                                  type: integer
                                status:
                                  type: string
                                name:
                                  type: string
                                parent_id:
                                  type: integer
                                  nullable: true
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                          nullable: true
                        shipment_items:
                          type: array
                          description: Line items (present when the relation is loaded)
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                              updated_at:
                                type: string
                                format: date-time
                                nullable: true
                              supplier_purchase_order_shipment_id:
                                type: integer
                              supplier_purchase_order_id:
                                type: integer
                              supplier_purchase_order_item_id:
                                type: integer
                              quantity:
                                type: number
                                format: float
                              unit_of_measure_id:
                                type: integer
                              cbm:
                                type: number
                                format: float
                                nullable: true
                                description: Cubic meters (volume) for this line
                              carton_quantity:
                                type: integer
                                nullable: true
                                description: Number of cartons for this line
                              carton_dimensions:
                                type: string
                                nullable: true
                                description: Carton dimensions for this line
                        shipment_extra_costs:
                          type: array
                          description: Extra costs applied to the shipment (present when the relation is loaded)
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                              updated_at:
                                type: string
                                format: date-time
                                nullable: true
                              supplier_purchase_order_shipment_id:
                                type: integer
                              name:
                                type: string
                              quantity:
                                type: number
                                format: float
                              unit_price:
                                type: number
                                format: float
                              line_total:
                                type: number
                                format: float
                              cost_allocation_type:
                                type: string
                                nullable: true
                        custom_fields:
                          type: object
                          nullable: true
                          description: 'Custom field values for this shipment as a label => value map, e.g. `{ "Cargo Ready Date": "2026-10-20" }`. Only fields with a stored value appear, so a field defined for shipments but never filled in is absent and the object can be `{}`. Date values are `YYYY-MM-DD`. To list the fields defined for shipments (including unset ones), call `GET /custom-fields?object_type=SHIPMENT`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/shipments/{shipmentId}':
    get:
      operationId: getPurchaseOrderShipmentByPurchaseOrder
      tags:
        - Purchase Order Shipments
      summary: Get shipment by purchase order
      description: |
        Get a single shipment scoped to a specific purchase order. Returns 404 if the shipment
        exists but has no line item tied to `{purchaseOrderId}`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
        - in: path
          name: shipmentId
          required: true
          schema:
            type: integer
          description: Purchase order shipment ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      reference_number:
                        type: string
                        description: Supplier reference number for this shipment
                      total_shipping_cost:
                        type: number
                        format: float
                      shipping_date:
                        type: string
                        format: date-time
                        nullable: true
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Destination warehouse ID
                      shipment_status_id:
                        type: integer
                        nullable: true
                      notes:
                        type: string
                        nullable: true
                        description: Free-text notes on the shipment
                      tracking_number:
                        type: string
                        nullable: true
                        description: Carrier tracking number
                      shipped_by:
                        type: string
                        nullable: true
                        enum:
                          - Freight
                          - Supplier
                        description: Who is responsible for shipping
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                        description: Mode of transport for the shipment
                      estimated_arrival:
                        type: string
                        format: date
                        nullable: true
                        description: Estimated arrival date
                      is_closed:
                        type: boolean
                        description: 'Whether the shipment is marked as closed. Closing has no enforced behavior (it does not gate edits, pushes, or receiving) and is provided for filtering and reporting. It can be set manually, and is also set to `true` automatically when a receiving report brings every shipment line to fully received (the shipment status is moved to its "received"/Arrived mapping at the same time). Automatic closing never reopens a shipment — if received quantity later drops (e.g. a voided receipt), `is_closed` stays `true`.'
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: Container volume target in cubic meters. Null when unset.
                      sync_status:
                        type: string
                        nullable: true
                        description: 'Integration sync status (e.g. "synced", "unsynced")'
                      last_synced_at:
                        type: string
                        format: date-time
                        nullable: true
                      last_synced_status:
                        description: Raw sync status payload from the integration (shape varies)
                        nullable: true
                      shipment_status:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      warehouse:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                              status:
                                type: string
                              name:
                                type: string
                              parent_id:
                                type: integer
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                      shipment_items:
                        type: array
                        description: Line items (present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            supplier_purchase_order_shipment_id:
                              type: integer
                            supplier_purchase_order_id:
                              type: integer
                            supplier_purchase_order_item_id:
                              type: integer
                            quantity:
                              type: number
                              format: float
                            unit_of_measure_id:
                              type: integer
                            cbm:
                              type: number
                              format: float
                              nullable: true
                              description: Cubic meters (volume) for this line
                            carton_quantity:
                              type: integer
                              nullable: true
                              description: Number of cartons for this line
                            carton_dimensions:
                              type: string
                              nullable: true
                              description: Carton dimensions for this line
                      shipment_extra_costs:
                        type: array
                        description: Extra costs applied to the shipment (present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            supplier_purchase_order_shipment_id:
                              type: integer
                            name:
                              type: string
                            quantity:
                              type: number
                              format: float
                            unit_price:
                              type: number
                              format: float
                            line_total:
                              type: number
                              format: float
                            cost_allocation_type:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field values for this shipment as a label => value map, e.g. `{ "Cargo Ready Date": "2026-10-20" }`. Only fields with a stored value appear, so a field defined for shipments but never filled in is absent and the object can be `{}`. Date values are `YYYY-MM-DD`. To list the fields defined for shipments (including unset ones), call `GET /custom-fields?object_type=SHIPMENT`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or shipment does not belong to this purchase order
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/supplier-acceptances':
    get:
      operationId: getSupplierAcceptances
      tags:
        - Supplier Portal
      summary: List supplier acceptance responses
      description: |
        Get a paginated list of a supplier's responses to a purchase order, made
        through the supplier portal. Newest first.

        The underlying table is append-only — a supplier who changes their mind adds
        a new row — so **the first row is the current state**. A purchase order with
        no acceptance rows is **pending**; that value is never stored.

        > **A proposal never changes the purchase order.** The `proposed_qty`,
        > `proposed_unit_price` and `proposed_ship_date` fields on each line record
        > what the supplier asked for. The PO keeps its original values until someone
        > on the buying side applies the change deliberately. Do not read a proposal
        > as an agreed term.

        There is deliberately no endpoint for creating an acceptance: an acceptance
        is the supplier's own statement, made through the portal, and recording one
        on their behalf would turn the audit trail into a record of what the buyer
        wished they had said. This API reads what the supplier said.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: 'Paginated acceptance responses, newest first'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A supplier's response to a purchase order, made through the supplier portal. The underlying table is append-only — a supplier who changes their mind adds a new row — so within the newest-first list the first row is the current state. A purchase order with no acceptance rows is **pending**; that value is never stored.
                      properties:
                        id:
                          type: integer
                          example: 1
                        purchase_order_id:
                          type: integer
                          example: 7
                        status:
                          type: string
                          enum:
                            - accepted
                            - accepted_with_changes
                            - rejected
                          description: |
                            The header-level outcome. `pending` is never stored — a purchase order with no acceptance row is pending.
                          example: accepted_with_changes
                        responded_at:
                          type: string
                          format: date-time
                          example: '2026-08-28T15:13:13.000000Z'
                        note:
                          type: string
                          nullable: true
                          example: Can ship 180 by the requested date.
                        contact_details_id:
                          type: integer
                          nullable: true
                          description: 'The supplier contact who responded, when known.'
                          example: 1
                        created_at:
                          type: string
                          format: date-time
                          example: '2026-08-28T15:13:13.000000Z'
                        updated_at:
                          type: string
                          format: date-time
                          example: '2026-08-28T15:13:13.000000Z'
                        lines:
                          type: array
                          items:
                            type: object
                            description: |
                              A supplier's response to one purchase order line. The `proposed_*` values are a request, not an agreed term — the purchase order keeps its original values until someone on the buying side applies the change deliberately.
                            properties:
                              id:
                                type: integer
                                example: 1
                              purchase_order_item_id:
                                type: integer
                                example: 15
                              status:
                                type: string
                                enum:
                                  - accepted
                                  - changes_proposed
                                  - rejected
                                example: changes_proposed
                              proposed_qty:
                                type: string
                                nullable: true
                                description: |
                                  Quantity the supplier proposed for this line. `null` means no change was proposed on this dimension, which is NOT the same as proposing zero (a supplier proposing zero sends `"0"`). Branch on `null`, not on falsiness.
                                example: '180.000000'
                              proposed_unit_price:
                                type: string
                                nullable: true
                                description: Proposed unit price. `null` means no change proposed. See `proposed_qty`.
                                example: null
                              proposed_ship_date:
                                type: string
                                format: date
                                nullable: true
                                description: Proposed ship date (YYYY-MM-DD). `null` means no change proposed. See `proposed_qty`.
                                example: '2026-09-15'
                              note:
                                type: string
                                nullable: true
                                example: Short on materials
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/supplier-extra-cost-requests':
    get:
      operationId: getSupplierExtraCostRequests
      tags:
        - Supplier Portal
      summary: List supplier extra-cost requests
      description: |
        Get a paginated list of costs a supplier asked to add to a purchase order,
        and what was decided about each.

        > **A pending request is not money.** It has not touched the order total,
        > proration, the additional-fee mirror, a cost layer or a bill. Requests live
        > in their own table for exactly that reason — approving one is what creates a
        > real extra cost through the ordinary service.

        `line_total` is always computed from `quantity × unit_price` at submission,
        so a supplier cannot send a total that disagrees with its own parts.
        `created_extra_cost_id` is `null` until approval and then holds the extra
        cost the approval produced — the only link between a request and the money it
        became.

        Approving and rejecting are decisions rather than integrations, so they are
        not exposed here; they live on the admin API.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: Paginated cost requests
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A cost a supplier asked to add to a purchase order, and what was decided about it. A **pending** request is not money: it has not touched the order total, proration, the additional-fee mirror, a cost layer or a bill. Requests live in their own table for exactly that reason — approving one is what creates a real extra cost through the ordinary service.
                      properties:
                        id:
                          type: integer
                          example: 1
                        purchase_order_id:
                          type: integer
                          example: 7
                        supplier_purchase_order_shipment_id:
                          type: integer
                          nullable: true
                          description: Set when the supplier attached the cost to one shipment.
                          example: null
                        name:
                          type: string
                          example: Air freight surcharge
                        quantity:
                          type: string
                          example: '1.000000'
                        unit_price:
                          type: string
                          example: '450.000000'
                        line_total:
                          type: string
                          description: |
                            Always computed from `quantity × unit_price` at submission — a supplier cannot send a total that disagrees with its own parts.
                          example: '450.000000'
                        reference_number:
                          type: string
                          nullable: true
                          example: INV-8891
                        note:
                          type: string
                          nullable: true
                          example: Fuel surcharge for the air shipment
                        status:
                          type: string
                          enum:
                            - pending
                            - approved
                            - rejected
                          example: approved
                        requested_at:
                          type: string
                          format: date-time
                          example: '2026-08-28T16:44:25.000000Z'
                        reviewed_at:
                          type: string
                          format: date-time
                          nullable: true
                          example: '2026-08-28T16:44:37.000000Z'
                        review_note:
                          type: string
                          nullable: true
                          example: 'Agreed, air was our call.'
                        created_extra_cost_id:
                          type: integer
                          nullable: true
                          description: |
                            `null` until approval, and then the id of the extra cost the approval produced — the only link between a request and the money it became. A pending request has created nothing.
                          example: 1
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/quality-inspections':
    get:
      operationId: getQualityInspections
      tags:
        - Supplier Portal
      summary: List quality inspections for a purchase order
      description: |
        Get a paginated list of quality inspections filed against a purchase order,
        by anyone.

        > **Inspections are recorded, never enforced.** A `fail` does not block a
        > receipt, change a quantity, or move the order's status. Deciding what a
        > failure means is the buyer's — wiring an automatic consequence to a third
        > party's assertion would be a way for a supplier to halt their own order.

        > **`self_reported: true` means the supplier graded their own goods.** That is
        > worth having — it is how a brand hears about a problem before the container
        > lands — but it is evidence, not an independent audit. `supplier_id` names
        > who filed it; both are `null` on an internal inspection.

        `result` may be `conditional` ("usable, with a concession"), which is a real
        outcome — collapsing it into `pass` loses the fact that someone had to decide.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: Paginated inspections
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A quality inspection filed against a purchase order, by anyone. Inspections are **recorded, never enforced** — a `fail` does not block a receipt, change a quantity, or move the order's status. Deciding what a failure means is the buyer's.
                      properties:
                        id:
                          type: integer
                          example: 1
                        inspection_type:
                          type: string
                          enum:
                            - incoming
                            - in_process
                            - pre_shipment
                            - final
                          example: pre_shipment
                        result:
                          type: string
                          enum:
                            - pass
                            - fail
                            - conditional
                          description: |
                            `conditional` is a real outcome — "usable, with a concession" — not a rounding of pass or fail.
                          example: fail
                        quantity_inspected:
                          type: string
                          nullable: true
                          example: '200.000000'
                        quantity_rejected:
                          type: string
                          nullable: true
                          example: '14.000000'
                        inspected_at:
                          type: string
                          format: date-time
                          example: '2026-08-28T16:50:30.000000Z'
                        inspector_name:
                          type: string
                          nullable: true
                          example: Wei Zhang
                        notes:
                          type: string
                          nullable: true
                          example: Stitching defects on one carton
                        self_reported:
                          type: boolean
                          description: |
                            `true` when the supplier graded their own goods. Worth having — it is how a brand hears about a problem before the container lands — but it is evidence, not an independent audit.
                          example: true
                        supplier_id:
                          type: integer
                          nullable: true
                          description: Who filed the inspection; `null` on an internal inspection.
                          example: 66
                        lines:
                          type: array
                          items:
                            type: object
                            description: One line's inspection result within a quality inspection.
                            properties:
                              id:
                                type: integer
                                example: 1
                              purchase_order_item_id:
                                type: integer
                                nullable: true
                                example: 15
                              result:
                                type: string
                                enum:
                                  - pass
                                  - fail
                                  - conditional
                                example: fail
                              quantity_inspected:
                                type: string
                                nullable: true
                                example: '200.000000'
                              quantity_rejected:
                                type: string
                                nullable: true
                                example: '14.000000'
                              defect_code:
                                type: string
                                nullable: true
                                example: STITCH-02
                              notes:
                                type: string
                                nullable: true
                                example: null
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/supplier-portal-link':
    post:
      operationId: sendSupplierPortalLink
      tags:
        - Supplier Portal
      summary: Mint and email a supplier portal link
      description: |
        Mint a one-click portal link per contact and email each one. The link lets a
        supplier open the purchase order without an account or password and respond
        to it — accepting, rejecting, or proposing different quantities, prices or
        ship dates.

        One single-use token and one email per contact — never one email to several
        addresses, because the first click would lock the other recipients out and
        the audit trail could not say who responded. A contact whose email fails at
        send time appears in `failed` without stopping the others; if nothing could
        be sent, the response is a `400`.

        Rate limited to **20 requests per minute**.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                contact_details_ids:
                  type: array
                  nullable: true
                  description: |
                    Limit delivery to these contacts. Omit to send to every contact on the supplier. A contact that does not belong to this purchase order's supplier is rejected — one contact row can belong to several suppliers, so the pair is validated rather than the id trusted.
                  items:
                    type: integer
                    minimum: 1
      responses:
        '200':
          description: At least one link was sent.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                    example: Portal link sent.
                  data:
                    type: object
                    properties:
                      sent:
                        type: array
                        items:
                          type: string
                          format: email
                        example:
                          - ops@supplier.example
                      failed:
                        type: array
                        items:
                          type: string
                          format: email
                        example: []
        '400':
          description: 'No links could be sent, or the supplier has no emailable contact'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '429':
          description: Rate limited (20 requests per minute)
  '/purchase-orders/{purchaseOrderId}/supplier-portal-access':
    delete:
      operationId: revokeSupplierPortalAccess
      tags:
        - Supplier Portal
      summary: Revoke a supplier's portal access
      description: |
        Revoke a supplier's portal access to this purchase order. Revokes live
        sessions **and** burns any link token not yet exchanged — otherwise revoking
        would leave a working link sitting in an unopened inbox.

        The response reports how many of each were revoked.

        Rate limited to **20 requests per minute**.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
      responses:
        '200':
          description: Access revoked
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                    example: Supplier portal access revoked.
                  data:
                    type: object
                    properties:
                      sessions_revoked:
                        type: integer
                        example: 2
                      links_revoked:
                        type: integer
                        example: 1
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '429':
          description: Rate limited (20 requests per minute)
  /purchase-order-shipments:
    get:
      operationId: getPurchaseOrderShipments
      tags:
        - Purchase Order Shipments
      summary: Purchase order shipments
      description: |
        Get a paginated list of supplier purchase order shipments with optional filtering.
        Results are ordered by `updated_at` descending — use `updated_at[gt]` for incremental polling.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### DateTime Filters
        - `created_at`: When the shipment was created
        - `updated_at`: When the shipment was last updated
        - `shipping_date`: Shipping date
        - `last_synced_at`: When the shipment was last synced with an integration

        ### Integer Filters
        - `id`: Shipment ID
        - `shipment_status_id`: Shipment status ID
        - `warehouse_id`: Destination warehouse ID
        - `purchase_order_id`: Filter by linked purchase order (matches via shipment line items)

        ### String Filters
        - `reference_number`: Supplier reference number
        - `sync_status`: Integration sync status (`synced` or `unsynced`)
        - `tracking_number`: Carrier tracking number
        - `shipped_by`: Who is responsible for shipping (`Freight` or `Supplier`)
        - `shipment_type`: Mode of transport (`Air`, `Sea`, `Road`, `Rail`, `Express`)
        - `notes`: Free-text notes on the shipment

        ### DateTime Filters (logistics)
        - `estimated_arrival`: Estimated arrival date

        ### Boolean Filters
        - `is_closed`: Whether the shipment is marked as closed (no enforced behavior; set manually or automatically once every shipment line is fully received)

        ### Custom Field Filters
        Purchase order shipments can be filtered by their custom fields, using the format
        `custom_fields.{field_label}` where `{field_label}` is the exact label of a custom field
        defined for purchase order shipments. Fields defined for other record types are not available here. The
        available operators depend on the custom field type:

        - **String/Dropdown fields**: `eq`, `neq`, `contains`, `notcontains`, `in`, `notin`, `set`, `notset`
        - **Number fields**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `notin`, `set`, `notset`
        - **Date fields**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `set`, `notset`

        Custom field labels may contain spaces or special characters; URL-encode them
        (e.g. spaces become `%20` or `+`).

        ## Examples
        ```
        # Poll for recently updated shipments
        ?updated_at[gt]=2025-01-01 00:00:00

        # Filter by purchase order
        ?purchase_order_id[eq]=123

        # Filter by sync status
        ?sync_status[eq]=unsynced

        # Filter by reference number
        ?reference_number[contains]=REF-

        # Filter by tracking number
        ?tracking_number[contains]=1Z999

        # Filter by shipment mode and estimated arrival
        ?shipment_type[eq]=Sea&estimated_arrival[gte]=2025-01-01 00:00:00

        # Only closed shipments
        ?is_closed[eq]=true

        # Filter by a custom field value
        ?custom_fields.Forwarder[eq]=Flexport
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: shipping_date
          schema:
            type: string
            format: date-time
          description: Filter by shipping date
        - in: query
          name: last_synced_at
          schema:
            type: string
            format: date-time
          description: 'Filter by when the shipment was last synced with an integration (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: id
          schema:
            type: integer
          description: Filter by shipment ID
        - in: query
          name: purchase_order_id
          schema:
            type: integer
          description: Filter by linked purchase order ID
        - in: query
          name: reference_number
          schema:
            type: string
          description: Filter by reference number
        - in: query
          name: warehouse_id
          schema:
            type: integer
          description: Filter by destination warehouse ID
        - in: query
          name: shipment_status_id
          schema:
            type: integer
          description: Filter by shipment status ID
        - in: query
          name: sync_status
          schema:
            type: string
            enum:
              - synced
              - unsynced
          description: Filter by integration sync status
        - in: query
          name: tracking_number
          schema:
            type: string
          description: Filter by carrier tracking number
        - in: query
          name: shipped_by
          schema:
            type: string
            enum:
              - Freight
              - Supplier
          description: Filter by who is responsible for shipping
        - in: query
          name: shipment_type
          schema:
            type: string
            enum:
              - Air
              - Sea
              - Road
              - Rail
              - Express
          description: Filter by mode of transport
        - in: query
          name: notes
          schema:
            type: string
          description: Filter by free-text notes on the shipment
        - in: query
          name: estimated_arrival
          schema:
            type: string
            format: date-time
          description: 'Filter by estimated arrival date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: is_closed
          schema:
            type: boolean
          description: Filter by whether the shipment is marked as closed (no enforced behavior; set manually or automatically once every shipment line is fully received)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                        reference_number:
                          type: string
                          description: Supplier reference number for this shipment
                        total_shipping_cost:
                          type: number
                          format: float
                        shipping_date:
                          type: string
                          format: date-time
                          nullable: true
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: Destination warehouse ID
                        shipment_status_id:
                          type: integer
                          nullable: true
                        notes:
                          type: string
                          nullable: true
                          description: Free-text notes on the shipment
                        tracking_number:
                          type: string
                          nullable: true
                          description: Carrier tracking number
                        shipped_by:
                          type: string
                          nullable: true
                          enum:
                            - Freight
                            - Supplier
                          description: Who is responsible for shipping
                        shipment_type:
                          type: string
                          nullable: true
                          enum:
                            - Air
                            - Sea
                            - Road
                            - Rail
                            - Express
                          description: Mode of transport for the shipment
                        estimated_arrival:
                          type: string
                          format: date
                          nullable: true
                          description: Estimated arrival date
                        is_closed:
                          type: boolean
                          description: 'Whether the shipment is marked as closed. Closing has no enforced behavior (it does not gate edits, pushes, or receiving) and is provided for filtering and reporting. It can be set manually, and is also set to `true` automatically when a receiving report brings every shipment line to fully received (the shipment status is moved to its "received"/Arrived mapping at the same time). Automatic closing never reopens a shipment — if received quantity later drops (e.g. a voided receipt), `is_closed` stays `true`.'
                        volume_target_cbm:
                          type: number
                          format: float
                          nullable: true
                          description: Container volume target in cubic meters. Null when unset.
                        sync_status:
                          type: string
                          nullable: true
                          description: 'Integration sync status (e.g. "synced", "unsynced")'
                        last_synced_at:
                          type: string
                          format: date-time
                          nullable: true
                        last_synced_status:
                          description: Raw sync status payload from the integration (shape varies)
                          nullable: true
                        shipment_status:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        warehouse:
                          allOf:
                            - type: object
                              properties:
                                id:
                                  type: integer
                                status:
                                  type: string
                                name:
                                  type: string
                                parent_id:
                                  type: integer
                                  nullable: true
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                          nullable: true
                        shipment_items:
                          type: array
                          description: Line items (present when the relation is loaded)
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                              updated_at:
                                type: string
                                format: date-time
                                nullable: true
                              supplier_purchase_order_shipment_id:
                                type: integer
                              supplier_purchase_order_id:
                                type: integer
                              supplier_purchase_order_item_id:
                                type: integer
                              quantity:
                                type: number
                                format: float
                              unit_of_measure_id:
                                type: integer
                              cbm:
                                type: number
                                format: float
                                nullable: true
                                description: Cubic meters (volume) for this line
                              carton_quantity:
                                type: integer
                                nullable: true
                                description: Number of cartons for this line
                              carton_dimensions:
                                type: string
                                nullable: true
                                description: Carton dimensions for this line
                        shipment_extra_costs:
                          type: array
                          description: Extra costs applied to the shipment (present when the relation is loaded)
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                              updated_at:
                                type: string
                                format: date-time
                                nullable: true
                              supplier_purchase_order_shipment_id:
                                type: integer
                              name:
                                type: string
                              quantity:
                                type: number
                                format: float
                              unit_price:
                                type: number
                                format: float
                              line_total:
                                type: number
                                format: float
                              cost_allocation_type:
                                type: string
                                nullable: true
                        custom_fields:
                          type: object
                          nullable: true
                          description: 'Custom field values for this shipment as a label => value map, e.g. `{ "Cargo Ready Date": "2026-10-20" }`. Only fields with a stored value appear, so a field defined for shipments but never filled in is absent and the object can be `{}`. Date values are `YYYY-MM-DD`. To list the fields defined for shipments (including unset ones), call `GET /custom-fields?object_type=SHIPMENT`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createPurchaseOrderShipment
      tags:
        - Purchase Order Shipments
      summary: Create purchase order shipment
      description: |
        Create one supplier purchase order shipment, using the same writer as the in-app form.
        The body uses the same snake_case field names as the shipment response.

        - `shipment_items` is required and must contain at least one line. Each line's
          `supplier_purchase_order_item_id` must belong to its `supplier_purchase_order_id`, otherwise `422`.
        - `unit_of_measure_id` is optional per line; when omitted it is taken from the purchase order
          line's ordered unit (`422` if that line has no ordered unit).
        - `reference_number` is optional and generated when omitted. A reference already used by another
          shipment returns `409`.
        - `shipped_by` and `shipment_type` accept any casing and are stored in their canonical form
          (e.g. `sea` → `Sea`).
        - A draft or cancelled purchase order on any line returns `422` and nothing is written.
        - `custom_fields` is an optional label => value map resolved the same way as
          `PUT /purchase-order-shipments/{id}/custom-fields`: an unknown label, or one defined only for
          another record type, is `422` and is never auto-created. When `custom_fields` is sent, every
          custom field marked required for purchase order shipments must be included. Omit it to create
          the shipment without setting any custom fields.
        - `total_shipping_cost` on the created shipment is the sum of the extra-cost line totals
          (`quantity × unit_price`).

        A successful create returns `201` with the shipment in `data` (same shape as
        `GET /purchase-order-shipments/{id}`). A request with more than 200 lines is queued instead and
        returns `202` with a `job_status_id`; the shipment is written by the background job.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - shipment_items
              properties:
                reference_number:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Supplier reference number. Generated when omitted; `409` when already in use.
                warehouse_id:
                  type: integer
                  nullable: true
                  description: Destination warehouse (location) ID
                shipment_status_id:
                  type: integer
                  nullable: true
                  description: Shipment status ID
                shipping_date:
                  type: string
                  format: date
                  nullable: true
                notes:
                  type: string
                  nullable: true
                tracking_number:
                  type: string
                  nullable: true
                  maxLength: 255
                shipped_by:
                  type: string
                  nullable: true
                  enum:
                    - Freight
                    - Supplier
                  description: Who is responsible for shipping (case-insensitive)
                shipment_type:
                  type: string
                  nullable: true
                  enum:
                    - Air
                    - Sea
                    - Road
                    - Rail
                    - Express
                  description: Mode of transport (case-insensitive)
                estimated_arrival:
                  type: string
                  format: date
                  nullable: true
                is_closed:
                  type: boolean
                  nullable: true
                  default: false
                volume_target_cbm:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: Container volume target in cubic meters
                shipment_items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - supplier_purchase_order_id
                      - supplier_purchase_order_item_id
                      - quantity
                    properties:
                      supplier_purchase_order_id:
                        type: integer
                        description: Purchase order ID. Must not be draft or cancelled.
                      supplier_purchase_order_item_id:
                        type: integer
                        description: Purchase order line ID. Must belong to `supplier_purchase_order_id`.
                      quantity:
                        type: number
                        format: float
                        minimum: 0
                        exclusiveMinimum: true
                      unit_of_measure_id:
                        type: integer
                        nullable: true
                        description: Defaults to the purchase order line's ordered unit when omitted.
                      cbm:
                        type: number
                        format: float
                        nullable: true
                        minimum: 0
                        description: Cubic meters (volume) for this line
                      carton_quantity:
                        type: integer
                        nullable: true
                        minimum: 0
                      carton_dimensions:
                        type: string
                        nullable: true
                        maxLength: 100
                shipment_extra_costs:
                  type: array
                  nullable: true
                  items:
                    type: object
                    required:
                      - name
                      - quantity
                      - unit_price
                    properties:
                      name:
                        type: string
                      quantity:
                        type: number
                        format: float
                      unit_price:
                        type: number
                        format: float
                      cost_allocation_type:
                        type: string
                        nullable: true
                      reference_number:
                        type: string
                        nullable: true
                      category_ids:
                        type: array
                        nullable: true
                        items:
                          type: integer
                      tag_ids:
                        type: array
                        nullable: true
                        items:
                          type: integer
                      internal_skus:
                        type: array
                        nullable: true
                        items:
                          type: integer
                      supplier_skus:
                        type: array
                        nullable: true
                        items:
                          type: integer
                      po_numbers:
                        type: array
                        nullable: true
                        items:
                          type: integer
                custom_fields:
                  type: object
                  nullable: true
                  additionalProperties: true
                  description: 'Custom field values as a label => value map, e.g. `{ "Cargo Ready Date": "2026-11-20" }`'
            example:
              reference_number: SHIP-1001
              warehouse_id: 4
              shipment_status_id: 2
              shipping_date: '2026-11-04'
              tracking_number: 1Z999
              shipped_by: Freight
              shipment_type: Sea
              estimated_arrival: '2026-12-01'
              volume_target_cbm: 68
              shipment_items:
                - supplier_purchase_order_id: 1001
                  supplier_purchase_order_item_id: 55
                  quantity: 10
                  cbm: 1.2
                  carton_quantity: 2
                  carton_dimensions: 40x30x20
              shipment_extra_costs:
                - name: Ocean freight
                  quantity: 1
                  unit_price: 450
              custom_fields:
                Cargo Ready Date: '2026-11-20'
      responses:
        '201':
          description: Shipment created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      reference_number:
                        type: string
                        description: Supplier reference number for this shipment
                      total_shipping_cost:
                        type: number
                        format: float
                      shipping_date:
                        type: string
                        format: date-time
                        nullable: true
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Destination warehouse ID
                      shipment_status_id:
                        type: integer
                        nullable: true
                      notes:
                        type: string
                        nullable: true
                        description: Free-text notes on the shipment
                      tracking_number:
                        type: string
                        nullable: true
                        description: Carrier tracking number
                      shipped_by:
                        type: string
                        nullable: true
                        enum:
                          - Freight
                          - Supplier
                        description: Who is responsible for shipping
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                        description: Mode of transport for the shipment
                      estimated_arrival:
                        type: string
                        format: date
                        nullable: true
                        description: Estimated arrival date
                      is_closed:
                        type: boolean
                        description: 'Whether the shipment is marked as closed. Closing has no enforced behavior (it does not gate edits, pushes, or receiving) and is provided for filtering and reporting. It can be set manually, and is also set to `true` automatically when a receiving report brings every shipment line to fully received (the shipment status is moved to its "received"/Arrived mapping at the same time). Automatic closing never reopens a shipment — if received quantity later drops (e.g. a voided receipt), `is_closed` stays `true`.'
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: Container volume target in cubic meters. Null when unset.
                      sync_status:
                        type: string
                        nullable: true
                        description: 'Integration sync status (e.g. "synced", "unsynced")'
                      last_synced_at:
                        type: string
                        format: date-time
                        nullable: true
                      last_synced_status:
                        description: Raw sync status payload from the integration (shape varies)
                        nullable: true
                      shipment_status:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      warehouse:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                              status:
                                type: string
                              name:
                                type: string
                              parent_id:
                                type: integer
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                      shipment_items:
                        type: array
                        description: Line items (present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            supplier_purchase_order_shipment_id:
                              type: integer
                            supplier_purchase_order_id:
                              type: integer
                            supplier_purchase_order_item_id:
                              type: integer
                            quantity:
                              type: number
                              format: float
                            unit_of_measure_id:
                              type: integer
                            cbm:
                              type: number
                              format: float
                              nullable: true
                              description: Cubic meters (volume) for this line
                            carton_quantity:
                              type: integer
                              nullable: true
                              description: Number of cartons for this line
                            carton_dimensions:
                              type: string
                              nullable: true
                              description: Carton dimensions for this line
                      shipment_extra_costs:
                        type: array
                        description: Extra costs applied to the shipment (present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            supplier_purchase_order_shipment_id:
                              type: integer
                            name:
                              type: string
                            quantity:
                              type: number
                              format: float
                            unit_price:
                              type: number
                              format: float
                            line_total:
                              type: number
                              format: float
                            cost_allocation_type:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field values for this shipment as a label => value map, e.g. `{ "Cargo Ready Date": "2026-10-20" }`. Only fields with a stored value appear, so a field defined for shipments but never filled in is absent and the object can be `{}`. Date values are `YYYY-MM-DD`. To list the fields defined for shipments (including unset ones), call `GET /custom-fields?object_type=SHIPMENT`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '202':
          description: More than 200 lines — creation was queued and the shipment is written by a background job
          content:
            application/json:
              schema:
                type: object
                properties:
                  job_status_id:
                    type: integer
                    nullable: true
                  status:
                    type: string
                    example: queued
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: '`reference_number` is already used by another shipment'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation failed, a line is not on the named purchase order, a purchase order is draft or cancelled, or a custom field was rejected. Nothing was written.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/purchase-order-shipments/{id}':
    get:
      operationId: getPurchaseOrderShipmentById
      tags:
        - Purchase Order Shipments
      summary: Get purchase order shipment
      description: Get a single supplier purchase order shipment by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Purchase order shipment ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      reference_number:
                        type: string
                        description: Supplier reference number for this shipment
                      total_shipping_cost:
                        type: number
                        format: float
                      shipping_date:
                        type: string
                        format: date-time
                        nullable: true
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Destination warehouse ID
                      shipment_status_id:
                        type: integer
                        nullable: true
                      notes:
                        type: string
                        nullable: true
                        description: Free-text notes on the shipment
                      tracking_number:
                        type: string
                        nullable: true
                        description: Carrier tracking number
                      shipped_by:
                        type: string
                        nullable: true
                        enum:
                          - Freight
                          - Supplier
                        description: Who is responsible for shipping
                      shipment_type:
                        type: string
                        nullable: true
                        enum:
                          - Air
                          - Sea
                          - Road
                          - Rail
                          - Express
                        description: Mode of transport for the shipment
                      estimated_arrival:
                        type: string
                        format: date
                        nullable: true
                        description: Estimated arrival date
                      is_closed:
                        type: boolean
                        description: 'Whether the shipment is marked as closed. Closing has no enforced behavior (it does not gate edits, pushes, or receiving) and is provided for filtering and reporting. It can be set manually, and is also set to `true` automatically when a receiving report brings every shipment line to fully received (the shipment status is moved to its "received"/Arrived mapping at the same time). Automatic closing never reopens a shipment — if received quantity later drops (e.g. a voided receipt), `is_closed` stays `true`.'
                      volume_target_cbm:
                        type: number
                        format: float
                        nullable: true
                        description: Container volume target in cubic meters. Null when unset.
                      sync_status:
                        type: string
                        nullable: true
                        description: 'Integration sync status (e.g. "synced", "unsynced")'
                      last_synced_at:
                        type: string
                        format: date-time
                        nullable: true
                      last_synced_status:
                        description: Raw sync status payload from the integration (shape varies)
                        nullable: true
                      shipment_status:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      warehouse:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                              status:
                                type: string
                              name:
                                type: string
                              parent_id:
                                type: integer
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                      shipment_items:
                        type: array
                        description: Line items (present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            supplier_purchase_order_shipment_id:
                              type: integer
                            supplier_purchase_order_id:
                              type: integer
                            supplier_purchase_order_item_id:
                              type: integer
                            quantity:
                              type: number
                              format: float
                            unit_of_measure_id:
                              type: integer
                            cbm:
                              type: number
                              format: float
                              nullable: true
                              description: Cubic meters (volume) for this line
                            carton_quantity:
                              type: integer
                              nullable: true
                              description: Number of cartons for this line
                            carton_dimensions:
                              type: string
                              nullable: true
                              description: Carton dimensions for this line
                      shipment_extra_costs:
                        type: array
                        description: Extra costs applied to the shipment (present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            supplier_purchase_order_shipment_id:
                              type: integer
                            name:
                              type: string
                            quantity:
                              type: number
                              format: float
                            unit_price:
                              type: number
                              format: float
                            line_total:
                              type: number
                              format: float
                            cost_allocation_type:
                              type: string
                              nullable: true
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field values for this shipment as a label => value map, e.g. `{ "Cargo Ready Date": "2026-10-20" }`. Only fields with a stored value appear, so a field defined for shipments but never filled in is absent and the object can be `{}`. Date values are `YYYY-MM-DD`. To list the fields defined for shipments (including unset ones), call `GET /custom-fields?object_type=SHIPMENT`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-order-shipments/{id}/packages/suggested':
    get:
      operationId: getPurchaseOrderShipmentSuggestedPackages
      tags:
        - Purchase Order Shipments
      summary: Suggest purchase order shipment cartons
      description: |
        Build a fresh carton suggestion from the shipment's lines. Nothing is saved, and saved cartons are ignored
        (`is_saved` is always false). Save it with `PUT /purchase-order-shipments/{id}/packages` to use it.

        Per line:
        - When the line has a Carton Qty (N), its units are spread as evenly as possible over exactly N cartons
          (9 units in 4 cartons → 1 × 3 + 3 × 2).
        - Otherwise the SKU's units per carton: full cartons plus one partial carton (20 at 6 → 3 × 6 + 1 × 2).
        - Otherwise one carton holding the whole line.

        Dimensions come from the SKU's carton dimensions, falling back to the line's carton dimensions text; weight is
        the SKU's carton weight (in lb), scaled when a carton holds a different count than a full SKU carton.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Purchase order shipment ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Carton structure of a purchase order shipment. Each entry in `packages` is one carton configuration:
                      `number_of_identical_packages` identical cartons, each holding the listed line quantities.
                    properties:
                      is_saved:
                        type: boolean
                        description: True when these are the shipment's saved cartons; false when they are a suggestion (nothing saved).
                      packages:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Carton configuration ID. Null on suggested (unsaved) cartons.
                            number_of_identical_packages:
                              type: integer
                            length:
                              type: number
                              nullable: true
                            width:
                              type: number
                              nullable: true
                            height:
                              type: number
                              nullable: true
                            dimension_unit:
                              type: string
                              enum:
                                - in
                                - cm
                            weight:
                              type: number
                              nullable: true
                              description: Weight of one carton.
                            weight_unit:
                              type: string
                              enum:
                                - lb
                                - oz
                                - kg
                                - g
                            package_type:
                              type: string
                              enum:
                                - carton
                                - pallet
                            carton_template_id:
                              type: integer
                              nullable: true
                            sscc:
                              type: string
                              nullable: true
                            tracking_number:
                              type: string
                              nullable: true
                            source:
                              type: string
                              enum:
                                - auto
                                - manual
                              description: '`auto` when built from line/SKU carton data, `manual` when saved through the API or app.'
                            items:
                              type: array
                              description: Units of each shipment line in one carton of this configuration.
                              items:
                                type: object
                                properties:
                                  supplier_purchase_order_shipment_item_id:
                                    type: integer
                                    description: 'Shipment line ID (`shipment_items[].id` on the purchase order shipment).'
                                  quantity_per_package:
                                    type: number
                      coverage:
                        type: array
                        description: |
                          Packing check per shipment line: units on the line vs units packed (sum of `quantity_per_package` ×
                          `number_of_identical_packages`). A push with saved cartons is refused while any line has `matches: false`.
                        items:
                          type: object
                          properties:
                            supplier_purchase_order_shipment_item_id:
                              type: integer
                            sku:
                              type: string
                              nullable: true
                            quantity:
                              type: number
                            packed:
                              type: number
                            matches:
                              type: boolean
                      box_labels_available:
                        type: boolean
                        description: True when the shipment has a pushed inbound at a 3PL that generates box content labels (Flexport).
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-order-shipments/{id}/packages':
    get:
      operationId: getPurchaseOrderShipmentPackages
      tags:
        - Purchase Order Shipments
      summary: Get purchase order shipment cartons
      description: |
        Get the shipment's saved cartons. When none are saved, returns a suggested carton structure instead
        (`is_saved: false`) built the same way as `GET /purchase-order-shipments/{id}/packages/suggested`. Includes the
        per-line packing check.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Purchase order shipment ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Carton structure of a purchase order shipment. Each entry in `packages` is one carton configuration:
                      `number_of_identical_packages` identical cartons, each holding the listed line quantities.
                    properties:
                      is_saved:
                        type: boolean
                        description: True when these are the shipment's saved cartons; false when they are a suggestion (nothing saved).
                      packages:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Carton configuration ID. Null on suggested (unsaved) cartons.
                            number_of_identical_packages:
                              type: integer
                            length:
                              type: number
                              nullable: true
                            width:
                              type: number
                              nullable: true
                            height:
                              type: number
                              nullable: true
                            dimension_unit:
                              type: string
                              enum:
                                - in
                                - cm
                            weight:
                              type: number
                              nullable: true
                              description: Weight of one carton.
                            weight_unit:
                              type: string
                              enum:
                                - lb
                                - oz
                                - kg
                                - g
                            package_type:
                              type: string
                              enum:
                                - carton
                                - pallet
                            carton_template_id:
                              type: integer
                              nullable: true
                            sscc:
                              type: string
                              nullable: true
                            tracking_number:
                              type: string
                              nullable: true
                            source:
                              type: string
                              enum:
                                - auto
                                - manual
                              description: '`auto` when built from line/SKU carton data, `manual` when saved through the API or app.'
                            items:
                              type: array
                              description: Units of each shipment line in one carton of this configuration.
                              items:
                                type: object
                                properties:
                                  supplier_purchase_order_shipment_item_id:
                                    type: integer
                                    description: 'Shipment line ID (`shipment_items[].id` on the purchase order shipment).'
                                  quantity_per_package:
                                    type: number
                      coverage:
                        type: array
                        description: |
                          Packing check per shipment line: units on the line vs units packed (sum of `quantity_per_package` ×
                          `number_of_identical_packages`). A push with saved cartons is refused while any line has `matches: false`.
                        items:
                          type: object
                          properties:
                            supplier_purchase_order_shipment_item_id:
                              type: integer
                            sku:
                              type: string
                              nullable: true
                            quantity:
                              type: number
                            packed:
                              type: number
                            matches:
                              type: boolean
                      box_labels_available:
                        type: boolean
                        description: True when the shipment has a pushed inbound at a 3PL that generates box content labels (Flexport).
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: replacePurchaseOrderShipmentPackages
      tags:
        - Purchase Order Shipments
      summary: Replace purchase order shipment cartons
      description: |
        Replace every carton on the shipment with the given list. Send an empty `packages` array to remove the saved
        cartons, so the shipment goes back to the suggested structure. Saved cartons are sent to the warehouse when the
        shipment is pushed as an inbound shipment (for mappings that use cartons).

        Returns the shipment's cartons after the save, in the same shape as the GET.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Purchase order shipment ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - packages
              properties:
                packages:
                  type: array
                  description: The full carton list. May be empty.
                  items:
                    type: object
                    required:
                      - number_of_identical_packages
                      - items
                    properties:
                      number_of_identical_packages:
                        type: integer
                        minimum: 1
                      length:
                        type: number
                        minimum: 0
                        nullable: true
                      width:
                        type: number
                        minimum: 0
                        nullable: true
                      height:
                        type: number
                        minimum: 0
                        nullable: true
                      dimension_unit:
                        type: string
                        enum:
                          - in
                          - cm
                        nullable: true
                        default: in
                      weight:
                        type: number
                        minimum: 0
                        nullable: true
                        description: Weight of one carton.
                      weight_unit:
                        type: string
                        enum:
                          - lb
                          - oz
                          - kg
                          - g
                        nullable: true
                        default: lb
                      package_type:
                        type: string
                        enum:
                          - carton
                          - pallet
                        nullable: true
                        default: carton
                      carton_template_id:
                        type: integer
                        nullable: true
                      sscc:
                        type: string
                        maxLength: 20
                        nullable: true
                      tracking_number:
                        type: string
                        maxLength: 255
                        nullable: true
                      items:
                        type: array
                        minItems: 1
                        description: Units of each shipment line in one carton of this configuration.
                        items:
                          type: object
                          required:
                            - supplier_purchase_order_shipment_item_id
                            - quantity_per_package
                          properties:
                            supplier_purchase_order_shipment_item_id:
                              type: integer
                              description: 'A current line of this shipment (`shipment_items[].id`). Any other ID returns `422`.'
                            quantity_per_package:
                              type: number
                              exclusiveMinimum: true
                              minimum: 0
      responses:
        '200':
          description: Cartons replaced
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Carton structure of a purchase order shipment. Each entry in `packages` is one carton configuration:
                      `number_of_identical_packages` identical cartons, each holding the listed line quantities.
                    properties:
                      is_saved:
                        type: boolean
                        description: True when these are the shipment's saved cartons; false when they are a suggestion (nothing saved).
                      packages:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Carton configuration ID. Null on suggested (unsaved) cartons.
                            number_of_identical_packages:
                              type: integer
                            length:
                              type: number
                              nullable: true
                            width:
                              type: number
                              nullable: true
                            height:
                              type: number
                              nullable: true
                            dimension_unit:
                              type: string
                              enum:
                                - in
                                - cm
                            weight:
                              type: number
                              nullable: true
                              description: Weight of one carton.
                            weight_unit:
                              type: string
                              enum:
                                - lb
                                - oz
                                - kg
                                - g
                            package_type:
                              type: string
                              enum:
                                - carton
                                - pallet
                            carton_template_id:
                              type: integer
                              nullable: true
                            sscc:
                              type: string
                              nullable: true
                            tracking_number:
                              type: string
                              nullable: true
                            source:
                              type: string
                              enum:
                                - auto
                                - manual
                              description: '`auto` when built from line/SKU carton data, `manual` when saved through the API or app.'
                            items:
                              type: array
                              description: Units of each shipment line in one carton of this configuration.
                              items:
                                type: object
                                properties:
                                  supplier_purchase_order_shipment_item_id:
                                    type: integer
                                    description: 'Shipment line ID (`shipment_items[].id` on the purchase order shipment).'
                                  quantity_per_package:
                                    type: number
                      coverage:
                        type: array
                        description: |
                          Packing check per shipment line: units on the line vs units packed (sum of `quantity_per_package` ×
                          `number_of_identical_packages`). A push with saved cartons is refused while any line has `matches: false`.
                        items:
                          type: object
                          properties:
                            supplier_purchase_order_shipment_item_id:
                              type: integer
                            sku:
                              type: string
                              nullable: true
                            quantity:
                              type: number
                            packed:
                              type: number
                            matches:
                              type: boolean
                      box_labels_available:
                        type: boolean
                        description: True when the shipment has a pushed inbound at a 3PL that generates box content labels (Flexport).
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or an item references a line that is not on the shipment'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-order-shipments/{id}/box-labels':
    get:
      operationId: getPurchaseOrderShipmentBoxLabels
      tags:
        - Purchase Order Shipments
      summary: Get purchase order shipment box labels
      description: |
        Get the 3PL's box content labels (PDF) for the shipment's pushed inbound. Currently available for Flexport
        inbounds only; check `box_labels_available` on the shipment's cartons.

        The link is requested fresh on every call and expires after about 15 minutes, so don't store it. Returns `202`
        with `ready: false` while the 3PL is still generating the labels. Limited to 30 requests per minute.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Purchase order shipment ID
      responses:
        '200':
          description: Labels ready
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      ready:
                        type: boolean
                        description: Whether the labels are ready to download.
                      url:
                        type: string
                        nullable: true
                        description: PDF link (expires after about 15 minutes). Null until ready.
        '202':
          description: The 3PL is still generating the labels; try again shortly
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      ready:
                        type: boolean
                        description: Whether the labels are ready to download.
                      url:
                        type: string
                        nullable: true
                        description: PDF link (expires after about 15 minutes). Null until ready.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Labels unavailable: the shipment has not been pushed to the warehouse, its inbound is not at a 3PL that makes
            box labels, or the 3PL did not return labels
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '429':
          description: Too many requests
  '/purchase-order-shipments/{id}/push-inbound-shipment':
    post:
      operationId: pushPurchaseOrderShipmentInboundShipment
      tags:
        - Purchase Order Shipments
      summary: Push purchase order shipment as inbound shipment to WMS
      description: |
        Push one purchase order shipment to its externally managed warehouse as an inbound shipment (TrackStar inbound
        shipment create). Requires a warehouse group with external management and OMS SKU mappings.

        Cartons are included when the warehouse's inbound mapping uses them: the shipment's saved cartons, or the
        suggested carton structure when none are saved. When the warehouse has no inbound mapping, the shipment's saved
        cartons are still sent as packages if the destination WMS accepts packages; suggested cartons are not sent on
        this path. When saved cartons no longer match the shipment's lines (a line
        was removed or its quantity changed after they were saved), the push is refused with `422`; update the cartons
        with `PUT /purchase-order-shipments/{id}/packages` and push again.

        Returns `409` when the shipment's `sync_status` is already `synced` unless `force` is true.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Purchase order shipment ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                force:
                  type: boolean
                  default: false
                  description: 'When true, push even if already synced (may duplicate WMS inbounds).'
      responses:
        '200':
          description: Push succeeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      purchase_order_shipment_id:
                        type: integer
                      sync_status:
                        type: string
                        nullable: true
                      last_synced_at:
                        type: string
                        format: date-time
                        nullable: true
                      external_shipment_id:
                        type: string
                        nullable: true
                      external_system_url:
                        type: string
                        nullable: true
                      inbound_shipment_id:
                        type: integer
                        nullable: true
                        description: ID of the Luminous inbound shipment created by the push.
                      box_labels_available:
                        type: boolean
                        description: 'True when box content labels can be fetched with `GET /purchase-order-shipments/{id}/box-labels`.'
        '400':
          description: Warehouse not externally managed or missing
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Shipment not found
        '409':
          description: |
            Already synced (use force=true to push again). Also returned when the shipment belongs to a
            transfer order's purchase order that was already pushed to the WMS whole, so it already
            carries every line of this shipment: "The transfer order's purchase order was already pushed
            as an inbound shipment with every line of this shipment. Set force=true to push again."
        '422':
          description: |
            Validation error, unmapped OMS SKUs (`errors` lists `unmapped_skus`, `unmapped_rfq_ids`,
            `app_integration_account_id`, `integration_label`), saved cartons that don't match the shipment's lines, or
            the push failed
  /cost-rules:
    get:
      operationId: getCostRules
      tags:
        - Cost Rules
      summary: List cost rules
      description: |
        Paginated list of cost rules (vendor-scoped tiered pricing / extra-cost rules).

        Requires the tenant **Cost Rules** feature flag. When the flag is off, all
        cost-rule endpoints return **404** with message
        `Cost Rules feature is not enabled for this tenant.`

        **If `status` is omitted, only `ACTIVE` rules are returned.** To walk every
        rule (including inactive or draft), pass an explicit `status`, or call once
        per status.
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: vendor_id
          schema:
            type: integer
          description: Filter by supplier / factory ID.
        - in: query
          name: status
          schema:
            type: string
            enum:
              - ACTIVE
              - INACTIVE
              - DRAFT
          description: 'Filter by status. If omitted, only `ACTIVE` rules are returned.'
        - in: query
          name: document_type
          schema:
            type: string
            enum:
              - PURCHASE_ORDER
              - WORK_ORDER
              - SHIPMENT
              - PRODUCTION_RUN
          description: Filter to rules that include this document type.
        - in: query
          name: name
          schema:
            type: string
          description: Name contains (LIKE). Alias — `search`.
        - in: query
          name: search
          schema:
            type: string
          description: Name contains (LIKE). Alias for `name`.
        - in: query
          name: description
          schema:
            type: string
          description: Description contains (LIKE).
      responses:
        '200':
          description: A list of cost rules.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A cost rule — vendor-scoped tiered pricing or extra-cost rule applied to
                        purchase orders, work orders, and shipments. Nested `scopes`, `conditions`,
                        and `tiers` (with `effects`) are only present when the relation is loaded
                        (always on `GET /cost-rules/{id}`).
                      properties:
                        id:
                          type: integer
                          description: Cost rule ID.
                        vendor_id:
                          type: integer
                          nullable: true
                          description: Supplier / factory ID the rule is scoped to. Null for an EXTRA_COST rule with no supplier condition.
                        vendor_name:
                          type: string
                          nullable: true
                          description: Supplier factory name. Only present when the vendor relation is loaded.
                        name:
                          type: string
                          description: 'Rule name, unique per vendor among non-deleted rules.'
                        description:
                          type: string
                          nullable: true
                        document_type:
                          type: string
                          nullable: true
                          description: First entry of `document_types` (convenience field).
                          enum:
                            - PURCHASE_ORDER
                            - WORK_ORDER
                            - SHIPMENT
                            - PRODUCTION_RUN
                        document_types:
                          type: array
                          description: Document types the rule applies to.
                          items:
                            type: string
                            enum:
                              - PURCHASE_ORDER
                              - WORK_ORDER
                              - SHIPMENT
                              - PRODUCTION_RUN
                        tier_mode:
                          type: string
                          nullable: true
                          enum:
                            - NON_GRADUATED
                            - GRADUATED
                        tier_quantity_basis:
                          type: string
                          nullable: true
                          enum:
                            - LINE
                            - SCOPE_GROUP
                            - PRODUCTION_RUN_TOTAL
                        priority:
                          type: integer
                          nullable: true
                          description: 'Evaluation priority (1–1000, lower wins).'
                        status:
                          type: string
                          enum:
                            - ACTIVE
                            - INACTIVE
                            - DRAFT
                        is_active:
                          type: boolean
                          description: Convenience flag — true when `status` is `ACTIVE`.
                        effective_from:
                          type: string
                          format: date
                          nullable: true
                        effective_to:
                          type: string
                          format: date
                          nullable: true
                        moq:
                          type: number
                          nullable: true
                          description: Minimum order quantity.
                        order_multiple:
                          type: number
                          nullable: true
                        output_kind:
                          type: string
                          nullable: true
                          enum:
                            - UNIT_COST
                            - EXTRA_COST
                        extra_cost_item_name:
                          type: string
                          nullable: true
                        cost_allocation_type:
                          type: string
                          nullable: true
                          enum:
                            - UNIT_BASED_ALLOCATION
                            - VOLUME_BASED_ALLOCATION
                            - WEIGHT_BASED_ALLOCATION
                            - VALUE_BASED_ALLOCATION
                        cost_basis:
                          type: string
                          nullable: true
                          enum:
                            - PERCENTAGE
                            - FIXED
                        cost_basis_amount:
                          type: number
                          nullable: true
                        shipment_type:
                          type: string
                          nullable: true
                          description: Optional Air/Sea/Road/Rail/Express scope for shipment rules.
                        options:
                          type: object
                          description: Rule-level options bag.
                          properties:
                            auto_apply:
                              type: boolean
                              description: Server fires this rule automatically on PO / shipment save.
                            add_as_additional_fee:
                              type: boolean
                              description: Mirror the produced line to a PO additional fee (PURCHASE_ORDER + EXTRA_COST only).
                        scopes:
                          type: array
                          description: Product / category / tag / supplier-SKU scopes. Present when loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              cost_rule_id:
                                type: integer
                              scope_type:
                                type: string
                                enum:
                                  - PRODUCT
                                  - SUPPLIER_SKU
                                  - CATEGORY
                                  - SUBCATEGORY
                                  - TAG
                                  - ATTRIBUTE
                              scope_value:
                                type: string
                              scope_operator:
                                type: string
                                nullable: true
                                enum:
                                  - EQUALS
                                  - NOT_EQUALS
                                  - IN
                                  - NOT_IN
                                  - CONTAINS
                                  - STARTS_WITH
                                  - ENDS_WITH
                                  - GREATER_THAN
                                  - LESS_THAN
                                  - GREATER_THAN_OR_EQUALS
                                  - LESS_THAN_OR_EQUALS
                                  - ALL
                              scope_extra:
                                type: object
                                nullable: true
                        conditions:
                          type: array
                          description: Document-level applicability gates (extra-cost rules). Present when loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              cost_rule_id:
                                type: integer
                              condition_type:
                                type: string
                                enum:
                                  - SUPPLIER
                                  - SOURCE_WAREHOUSE
                                  - DESTINATION_WAREHOUSE
                                  - SHIPMENT_TYPE
                                  - CUSTOM_FIELD
                              field_key:
                                type: string
                                nullable: true
                                description: Custom-field key the condition matches on. Populated only for `CUSTOM_FIELD` conditions (e.g. `Print Locations`); `null` for all other condition types.
                              operator:
                                type: string
                                nullable: true
                                enum:
                                  - IN
                                  - NOT_IN
                                  - BETWEEN
                                  - GREATER_THAN_OR_EQUALS
                                  - LESS_THAN_OR_EQUALS
                              values:
                                type: array
                                items:
                                  type: string
                        tiers:
                          type: array
                          description: Quantity tiers with their effects. Present when loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              cost_rule_id:
                                type: integer
                              min_quantity:
                                type: number
                              max_quantity:
                                type: number
                                nullable: true
                              effects:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    cost_rule_id:
                                      type: integer
                                    cost_rule_tier_id:
                                      type: integer
                                    effect_type:
                                      type: string
                                      enum:
                                        - BASE_PRICE
                                        - PERCENT_DISCOUNT
                                        - PERCENT_MARKUP
                                        - FIXED_PER_UNIT
                                        - FIXED_PER_LINE
                                        - FIXED_PER_DOCUMENT
                                        - MINIMUM_FLOOR
                                    amount:
                                      type: number
                                    order:
                                      type: integer
                                      nullable: true
                                      description: Effect sequence within the tier.
                                    description:
                                      type: string
                                      nullable: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Cost Rules feature is not enabled for this tenant.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createCostRule
      tags:
        - Cost Rules
      summary: Create a cost rule
      description: |
        Create a cost rule. Accepts the same snake_case body as the admin Cost Rules
        API. Requires the tenant **Cost Rules** feature flag.

        On create, `name` and `document_types` (or singular `document_type`) are
        required; `vendor_id` is required unless `output_kind` is `EXTRA_COST` or the
        document type is `PRODUCTION_RUN`. For `EXTRA_COST` rules `vendor_id` must
        **not** be set (a `422` is returned if one is supplied) — scope to specific
        suppliers with a `SUPPLIER` condition instead. When `output_kind` is
        `EXTRA_COST`, `cost_basis` and `cost_basis_amount` become required.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  properties:
                    vendor_id:
                      type: integer
                      description: |
                        Supplier / factory ID. Required on create **except** when `output_kind` is
                        `EXTRA_COST` or when the rule's document type is `PRODUCTION_RUN` (the
                        production run carries its own vendor). For `EXTRA_COST` rules a `vendor_id`
                        must **not** be set — the request is rejected with `422` if one is supplied
                        (on both create and update); scope the rule to specific suppliers with a
                        `SUPPLIER` condition instead. Optional on update for other rule kinds.
                    name:
                      type: string
                      maxLength: 255
                      description: Rule name. Required on create. Must be unique per vendor among non-deleted rules.
                    description:
                      type: string
                      maxLength: 1000
                      nullable: true
                    document_types:
                      type: array
                      description: Document types the rule applies to. Required on create (or provide singular `document_type`).
                      minItems: 1
                      items:
                        type: string
                        enum:
                          - PURCHASE_ORDER
                          - WORK_ORDER
                          - SHIPMENT
                          - PRODUCTION_RUN
                    document_type:
                      type: string
                      description: Singular alternative to `document_types` (back-compat).
                      enum:
                        - PURCHASE_ORDER
                        - WORK_ORDER
                        - SHIPMENT
                        - PRODUCTION_RUN
                    tier_mode:
                      type: string
                      enum:
                        - NON_GRADUATED
                        - GRADUATED
                      description: Defaults to `NON_GRADUATED`.
                    tier_quantity_basis:
                      type: string
                      enum:
                        - LINE
                        - SCOPE_GROUP
                        - PRODUCTION_RUN_TOTAL
                      description: |
                        Which quantity the tier thresholds are matched against. Defaults to `LINE`.
                        `PRODUCTION_RUN_TOTAL` sums the planned quantity across all work orders in the
                        production run (only meaningful for `PRODUCTION_RUN` document rules).
                    priority:
                      type: integer
                      minimum: 1
                      maximum: 1000
                      description: Defaults to `100`.
                    status:
                      type: string
                      enum:
                        - ACTIVE
                        - INACTIVE
                        - DRAFT
                      description: Defaults to `ACTIVE` on create.
                    effective_from:
                      type: string
                      format: date
                      nullable: true
                    effective_to:
                      type: string
                      format: date
                      nullable: true
                      description: Must be on or after `effective_from`.
                    moq:
                      type: number
                      minimum: 0
                      nullable: true
                    order_multiple:
                      type: number
                      minimum: 0
                      nullable: true
                    is_active:
                      type: boolean
                      nullable: true
                    output_kind:
                      type: string
                      enum:
                        - UNIT_COST
                        - EXTRA_COST
                      description: Defaults to `UNIT_COST`.
                    extra_cost_item_name:
                      type: string
                      maxLength: 255
                      nullable: true
                    cost_allocation_type:
                      type: string
                      enum:
                        - UNIT_BASED_ALLOCATION
                        - VOLUME_BASED_ALLOCATION
                        - WEIGHT_BASED_ALLOCATION
                        - VALUE_BASED_ALLOCATION
                      nullable: true
                    cost_basis:
                      type: string
                      enum:
                        - PERCENTAGE
                        - FIXED
                      nullable: true
                      description: Required when `output_kind` is `EXTRA_COST`.
                    cost_basis_amount:
                      type: number
                      minimum: 0
                      nullable: true
                      description: Required when `output_kind` is `EXTRA_COST`.
                    shipment_type:
                      type: string
                      maxLength: 30
                      nullable: true
                    options:
                      type: object
                      properties:
                        auto_apply:
                          type: boolean
                          description: Server fires this rule automatically on PO / shipment save.
                        add_as_additional_fee:
                          type: boolean
                          description: Mirror the produced line to a PO additional fee (PURCHASE_ORDER + EXTRA_COST only).
                    scopes:
                      type: array
                      description: Product / category / tag / supplier-SKU scopes. Replaces existing scopes when provided.
                      items:
                        type: object
                        required:
                          - scope_type
                          - scope_value
                        properties:
                          scope_type:
                            type: string
                            enum:
                              - PRODUCT
                              - SUPPLIER_SKU
                              - CATEGORY
                              - SUBCATEGORY
                              - TAG
                              - ATTRIBUTE
                          scope_value:
                            type: string
                          scope_operator:
                            type: string
                            enum:
                              - EQUALS
                              - NOT_EQUALS
                              - IN
                              - NOT_IN
                              - CONTAINS
                              - STARTS_WITH
                              - ENDS_WITH
                              - GREATER_THAN
                              - LESS_THAN
                              - GREATER_THAN_OR_EQUALS
                              - LESS_THAN_OR_EQUALS
                              - ALL
                          scope_extra:
                            type: object
                            nullable: true
                    conditions:
                      type: array
                      description: Document-level applicability gates. Replaces existing conditions when provided.
                      items:
                        type: object
                        required:
                          - condition_type
                          - values
                        properties:
                          condition_type:
                            type: string
                            enum:
                              - SUPPLIER
                              - SOURCE_WAREHOUSE
                              - DESTINATION_WAREHOUSE
                              - SHIPMENT_TYPE
                              - CUSTOM_FIELD
                          field_key:
                            type: string
                            maxLength: 100
                            nullable: true
                            description: |
                              The custom-field key to match against (e.g. `two_sided`, `front_color_bucket`).
                              **Required** when `condition_type` is `CUSTOM_FIELD`; ignored otherwise.
                          operator:
                            type: string
                            enum:
                              - IN
                              - NOT_IN
                              - BETWEEN
                              - GREATER_THAN_OR_EQUALS
                              - LESS_THAN_OR_EQUALS
                            description: |
                              How `values` are matched. Defaults to `IN`. The numeric operators
                              (`BETWEEN`, `GREATER_THAN_OR_EQUALS`, `LESS_THAN_OR_EQUALS`) are intended
                              for `CUSTOM_FIELD` range conditions; `BETWEEN` expects two `values`.
                          values:
                            type: array
                            minItems: 1
                            items:
                              type: string
                    tiers:
                      type: array
                      description: Quantity tiers with their effects. Replaces existing tiers when provided.
                      items:
                        type: object
                        required:
                          - min_quantity
                          - effects
                        properties:
                          min_quantity:
                            type: number
                            minimum: 0
                          max_quantity:
                            type: number
                            minimum: 0
                            nullable: true
                            description: Must be greater than or equal to `min_quantity`.
                          effects:
                            type: array
                            minItems: 1
                            items:
                              type: object
                              required:
                                - effect_type
                                - amount
                              properties:
                                effect_type:
                                  type: string
                                  enum:
                                    - BASE_PRICE
                                    - PERCENT_DISCOUNT
                                    - PERCENT_MARKUP
                                    - FIXED_PER_UNIT
                                    - FIXED_PER_LINE
                                    - FIXED_PER_DOCUMENT
                                    - MINIMUM_FLOOR
                                amount:
                                  type: number
                                sequence:
                                  type: integer
                                  minimum: 0
                                  nullable: true
                                description:
                                  type: string
                                  maxLength: 255
                                  nullable: true
                - required:
                    - name
            examples:
              unitCost:
                summary: Minimal unit-cost rule
                value:
                  vendor_id: 42
                  name: Material cost — SKU-ABC
                  document_types:
                    - PURCHASE_ORDER
                  status: ACTIVE
                  tiers:
                    - min_quantity: '0'
                      effects:
                        - effect_type: FIXED_PER_UNIT
                          amount: '12.50'
                          sequence: 1
                          description: Material cost
                  scopes:
                    - scope_type: PRODUCT
                      scope_value: '12345'
                      scope_operator: EQUALS
      responses:
        '201':
          description: Cost rule created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A cost rule — vendor-scoped tiered pricing or extra-cost rule applied to
                      purchase orders, work orders, and shipments. Nested `scopes`, `conditions`,
                      and `tiers` (with `effects`) are only present when the relation is loaded
                      (always on `GET /cost-rules/{id}`).
                    properties:
                      id:
                        type: integer
                        description: Cost rule ID.
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Supplier / factory ID the rule is scoped to. Null for an EXTRA_COST rule with no supplier condition.
                      vendor_name:
                        type: string
                        nullable: true
                        description: Supplier factory name. Only present when the vendor relation is loaded.
                      name:
                        type: string
                        description: 'Rule name, unique per vendor among non-deleted rules.'
                      description:
                        type: string
                        nullable: true
                      document_type:
                        type: string
                        nullable: true
                        description: First entry of `document_types` (convenience field).
                        enum:
                          - PURCHASE_ORDER
                          - WORK_ORDER
                          - SHIPMENT
                          - PRODUCTION_RUN
                      document_types:
                        type: array
                        description: Document types the rule applies to.
                        items:
                          type: string
                          enum:
                            - PURCHASE_ORDER
                            - WORK_ORDER
                            - SHIPMENT
                            - PRODUCTION_RUN
                      tier_mode:
                        type: string
                        nullable: true
                        enum:
                          - NON_GRADUATED
                          - GRADUATED
                      tier_quantity_basis:
                        type: string
                        nullable: true
                        enum:
                          - LINE
                          - SCOPE_GROUP
                          - PRODUCTION_RUN_TOTAL
                      priority:
                        type: integer
                        nullable: true
                        description: 'Evaluation priority (1–1000, lower wins).'
                      status:
                        type: string
                        enum:
                          - ACTIVE
                          - INACTIVE
                          - DRAFT
                      is_active:
                        type: boolean
                        description: Convenience flag — true when `status` is `ACTIVE`.
                      effective_from:
                        type: string
                        format: date
                        nullable: true
                      effective_to:
                        type: string
                        format: date
                        nullable: true
                      moq:
                        type: number
                        nullable: true
                        description: Minimum order quantity.
                      order_multiple:
                        type: number
                        nullable: true
                      output_kind:
                        type: string
                        nullable: true
                        enum:
                          - UNIT_COST
                          - EXTRA_COST
                      extra_cost_item_name:
                        type: string
                        nullable: true
                      cost_allocation_type:
                        type: string
                        nullable: true
                        enum:
                          - UNIT_BASED_ALLOCATION
                          - VOLUME_BASED_ALLOCATION
                          - WEIGHT_BASED_ALLOCATION
                          - VALUE_BASED_ALLOCATION
                      cost_basis:
                        type: string
                        nullable: true
                        enum:
                          - PERCENTAGE
                          - FIXED
                      cost_basis_amount:
                        type: number
                        nullable: true
                      shipment_type:
                        type: string
                        nullable: true
                        description: Optional Air/Sea/Road/Rail/Express scope for shipment rules.
                      options:
                        type: object
                        description: Rule-level options bag.
                        properties:
                          auto_apply:
                            type: boolean
                            description: Server fires this rule automatically on PO / shipment save.
                          add_as_additional_fee:
                            type: boolean
                            description: Mirror the produced line to a PO additional fee (PURCHASE_ORDER + EXTRA_COST only).
                      scopes:
                        type: array
                        description: Product / category / tag / supplier-SKU scopes. Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            scope_type:
                              type: string
                              enum:
                                - PRODUCT
                                - SUPPLIER_SKU
                                - CATEGORY
                                - SUBCATEGORY
                                - TAG
                                - ATTRIBUTE
                            scope_value:
                              type: string
                            scope_operator:
                              type: string
                              nullable: true
                              enum:
                                - EQUALS
                                - NOT_EQUALS
                                - IN
                                - NOT_IN
                                - CONTAINS
                                - STARTS_WITH
                                - ENDS_WITH
                                - GREATER_THAN
                                - LESS_THAN
                                - GREATER_THAN_OR_EQUALS
                                - LESS_THAN_OR_EQUALS
                                - ALL
                            scope_extra:
                              type: object
                              nullable: true
                      conditions:
                        type: array
                        description: Document-level applicability gates (extra-cost rules). Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            condition_type:
                              type: string
                              enum:
                                - SUPPLIER
                                - SOURCE_WAREHOUSE
                                - DESTINATION_WAREHOUSE
                                - SHIPMENT_TYPE
                                - CUSTOM_FIELD
                            field_key:
                              type: string
                              nullable: true
                              description: Custom-field key the condition matches on. Populated only for `CUSTOM_FIELD` conditions (e.g. `Print Locations`); `null` for all other condition types.
                            operator:
                              type: string
                              nullable: true
                              enum:
                                - IN
                                - NOT_IN
                                - BETWEEN
                                - GREATER_THAN_OR_EQUALS
                                - LESS_THAN_OR_EQUALS
                            values:
                              type: array
                              items:
                                type: string
                      tiers:
                        type: array
                        description: Quantity tiers with their effects. Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            min_quantity:
                              type: number
                            max_quantity:
                              type: number
                              nullable: true
                            effects:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  cost_rule_id:
                                    type: integer
                                  cost_rule_tier_id:
                                    type: integer
                                  effect_type:
                                    type: string
                                    enum:
                                      - BASE_PRICE
                                      - PERCENT_DISCOUNT
                                      - PERCENT_MARKUP
                                      - FIXED_PER_UNIT
                                      - FIXED_PER_LINE
                                      - FIXED_PER_DOCUMENT
                                      - MINIMUM_FLOOR
                                  amount:
                                    type: number
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Effect sequence within the tier.
                                  description:
                                    type: string
                                    nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Cost Rules feature is not enabled for this tenant.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error — e.g. missing `name`, missing vendor on a non
            extra-cost rule, duplicate name for the vendor, invalid enum value, or
            `cost_basis` / `cost_basis_amount` missing on an `EXTRA_COST` rule.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/cost-rules/{id}':
    get:
      operationId: getCostRuleById
      tags:
        - Cost Rules
      summary: Single cost rule
      description: |
        Get a single cost rule by ID, including nested `scopes`, `conditions`,
        `tiers` (with `effects`), and `vendor_name`. Requires the tenant
        **Cost Rules** feature flag.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Cost rule ID.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A cost rule — vendor-scoped tiered pricing or extra-cost rule applied to
                      purchase orders, work orders, and shipments. Nested `scopes`, `conditions`,
                      and `tiers` (with `effects`) are only present when the relation is loaded
                      (always on `GET /cost-rules/{id}`).
                    properties:
                      id:
                        type: integer
                        description: Cost rule ID.
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Supplier / factory ID the rule is scoped to. Null for an EXTRA_COST rule with no supplier condition.
                      vendor_name:
                        type: string
                        nullable: true
                        description: Supplier factory name. Only present when the vendor relation is loaded.
                      name:
                        type: string
                        description: 'Rule name, unique per vendor among non-deleted rules.'
                      description:
                        type: string
                        nullable: true
                      document_type:
                        type: string
                        nullable: true
                        description: First entry of `document_types` (convenience field).
                        enum:
                          - PURCHASE_ORDER
                          - WORK_ORDER
                          - SHIPMENT
                          - PRODUCTION_RUN
                      document_types:
                        type: array
                        description: Document types the rule applies to.
                        items:
                          type: string
                          enum:
                            - PURCHASE_ORDER
                            - WORK_ORDER
                            - SHIPMENT
                            - PRODUCTION_RUN
                      tier_mode:
                        type: string
                        nullable: true
                        enum:
                          - NON_GRADUATED
                          - GRADUATED
                      tier_quantity_basis:
                        type: string
                        nullable: true
                        enum:
                          - LINE
                          - SCOPE_GROUP
                          - PRODUCTION_RUN_TOTAL
                      priority:
                        type: integer
                        nullable: true
                        description: 'Evaluation priority (1–1000, lower wins).'
                      status:
                        type: string
                        enum:
                          - ACTIVE
                          - INACTIVE
                          - DRAFT
                      is_active:
                        type: boolean
                        description: Convenience flag — true when `status` is `ACTIVE`.
                      effective_from:
                        type: string
                        format: date
                        nullable: true
                      effective_to:
                        type: string
                        format: date
                        nullable: true
                      moq:
                        type: number
                        nullable: true
                        description: Minimum order quantity.
                      order_multiple:
                        type: number
                        nullable: true
                      output_kind:
                        type: string
                        nullable: true
                        enum:
                          - UNIT_COST
                          - EXTRA_COST
                      extra_cost_item_name:
                        type: string
                        nullable: true
                      cost_allocation_type:
                        type: string
                        nullable: true
                        enum:
                          - UNIT_BASED_ALLOCATION
                          - VOLUME_BASED_ALLOCATION
                          - WEIGHT_BASED_ALLOCATION
                          - VALUE_BASED_ALLOCATION
                      cost_basis:
                        type: string
                        nullable: true
                        enum:
                          - PERCENTAGE
                          - FIXED
                      cost_basis_amount:
                        type: number
                        nullable: true
                      shipment_type:
                        type: string
                        nullable: true
                        description: Optional Air/Sea/Road/Rail/Express scope for shipment rules.
                      options:
                        type: object
                        description: Rule-level options bag.
                        properties:
                          auto_apply:
                            type: boolean
                            description: Server fires this rule automatically on PO / shipment save.
                          add_as_additional_fee:
                            type: boolean
                            description: Mirror the produced line to a PO additional fee (PURCHASE_ORDER + EXTRA_COST only).
                      scopes:
                        type: array
                        description: Product / category / tag / supplier-SKU scopes. Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            scope_type:
                              type: string
                              enum:
                                - PRODUCT
                                - SUPPLIER_SKU
                                - CATEGORY
                                - SUBCATEGORY
                                - TAG
                                - ATTRIBUTE
                            scope_value:
                              type: string
                            scope_operator:
                              type: string
                              nullable: true
                              enum:
                                - EQUALS
                                - NOT_EQUALS
                                - IN
                                - NOT_IN
                                - CONTAINS
                                - STARTS_WITH
                                - ENDS_WITH
                                - GREATER_THAN
                                - LESS_THAN
                                - GREATER_THAN_OR_EQUALS
                                - LESS_THAN_OR_EQUALS
                                - ALL
                            scope_extra:
                              type: object
                              nullable: true
                      conditions:
                        type: array
                        description: Document-level applicability gates (extra-cost rules). Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            condition_type:
                              type: string
                              enum:
                                - SUPPLIER
                                - SOURCE_WAREHOUSE
                                - DESTINATION_WAREHOUSE
                                - SHIPMENT_TYPE
                                - CUSTOM_FIELD
                            field_key:
                              type: string
                              nullable: true
                              description: Custom-field key the condition matches on. Populated only for `CUSTOM_FIELD` conditions (e.g. `Print Locations`); `null` for all other condition types.
                            operator:
                              type: string
                              nullable: true
                              enum:
                                - IN
                                - NOT_IN
                                - BETWEEN
                                - GREATER_THAN_OR_EQUALS
                                - LESS_THAN_OR_EQUALS
                            values:
                              type: array
                              items:
                                type: string
                      tiers:
                        type: array
                        description: Quantity tiers with their effects. Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            min_quantity:
                              type: number
                            max_quantity:
                              type: number
                              nullable: true
                            effects:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  cost_rule_id:
                                    type: integer
                                  cost_rule_tier_id:
                                    type: integer
                                  effect_type:
                                    type: string
                                    enum:
                                      - BASE_PRICE
                                      - PERCENT_DISCOUNT
                                      - PERCENT_MARKUP
                                      - FIXED_PER_UNIT
                                      - FIXED_PER_LINE
                                      - FIXED_PER_DOCUMENT
                                      - MINIMUM_FLOOR
                                  amount:
                                    type: number
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Effect sequence within the tier.
                                  description:
                                    type: string
                                    nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Cost rule not found, or Cost Rules feature not enabled for this tenant.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateCostRule
      tags:
        - Cost Rules
      summary: Update a cost rule
      description: |
        Update an existing cost rule. Same body shape as create, but every field is
        optional — send the fields you intend to change. Nested collections
        (`scopes`, `conditions`, `tiers`) **replace** the existing set when provided.
        Requires the tenant **Cost Rules** feature flag.

        This endpoint also accepts `POST /cost-rules/{id}` for clients that cannot
        send `PUT`.

        To remove a rule use `DELETE /cost-rules/{id}`. A rule that has already
        been applied (it has cost-rule resolutions) cannot be deleted — set
        `status` to `INACTIVE` to deactivate it instead.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Cost rule ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                vendor_id:
                  type: integer
                  description: |
                    Supplier / factory ID. Required on create **except** when `output_kind` is
                    `EXTRA_COST` or when the rule's document type is `PRODUCTION_RUN` (the
                    production run carries its own vendor). For `EXTRA_COST` rules a `vendor_id`
                    must **not** be set — the request is rejected with `422` if one is supplied
                    (on both create and update); scope the rule to specific suppliers with a
                    `SUPPLIER` condition instead. Optional on update for other rule kinds.
                name:
                  type: string
                  maxLength: 255
                  description: Rule name. Required on create. Must be unique per vendor among non-deleted rules.
                description:
                  type: string
                  maxLength: 1000
                  nullable: true
                document_types:
                  type: array
                  description: Document types the rule applies to. Required on create (or provide singular `document_type`).
                  minItems: 1
                  items:
                    type: string
                    enum:
                      - PURCHASE_ORDER
                      - WORK_ORDER
                      - SHIPMENT
                      - PRODUCTION_RUN
                document_type:
                  type: string
                  description: Singular alternative to `document_types` (back-compat).
                  enum:
                    - PURCHASE_ORDER
                    - WORK_ORDER
                    - SHIPMENT
                    - PRODUCTION_RUN
                tier_mode:
                  type: string
                  enum:
                    - NON_GRADUATED
                    - GRADUATED
                  description: Defaults to `NON_GRADUATED`.
                tier_quantity_basis:
                  type: string
                  enum:
                    - LINE
                    - SCOPE_GROUP
                    - PRODUCTION_RUN_TOTAL
                  description: |
                    Which quantity the tier thresholds are matched against. Defaults to `LINE`.
                    `PRODUCTION_RUN_TOTAL` sums the planned quantity across all work orders in the
                    production run (only meaningful for `PRODUCTION_RUN` document rules).
                priority:
                  type: integer
                  minimum: 1
                  maximum: 1000
                  description: Defaults to `100`.
                status:
                  type: string
                  enum:
                    - ACTIVE
                    - INACTIVE
                    - DRAFT
                  description: Defaults to `ACTIVE` on create.
                effective_from:
                  type: string
                  format: date
                  nullable: true
                effective_to:
                  type: string
                  format: date
                  nullable: true
                  description: Must be on or after `effective_from`.
                moq:
                  type: number
                  minimum: 0
                  nullable: true
                order_multiple:
                  type: number
                  minimum: 0
                  nullable: true
                is_active:
                  type: boolean
                  nullable: true
                output_kind:
                  type: string
                  enum:
                    - UNIT_COST
                    - EXTRA_COST
                  description: Defaults to `UNIT_COST`.
                extra_cost_item_name:
                  type: string
                  maxLength: 255
                  nullable: true
                cost_allocation_type:
                  type: string
                  enum:
                    - UNIT_BASED_ALLOCATION
                    - VOLUME_BASED_ALLOCATION
                    - WEIGHT_BASED_ALLOCATION
                    - VALUE_BASED_ALLOCATION
                  nullable: true
                cost_basis:
                  type: string
                  enum:
                    - PERCENTAGE
                    - FIXED
                  nullable: true
                  description: Required when `output_kind` is `EXTRA_COST`.
                cost_basis_amount:
                  type: number
                  minimum: 0
                  nullable: true
                  description: Required when `output_kind` is `EXTRA_COST`.
                shipment_type:
                  type: string
                  maxLength: 30
                  nullable: true
                options:
                  type: object
                  properties:
                    auto_apply:
                      type: boolean
                      description: Server fires this rule automatically on PO / shipment save.
                    add_as_additional_fee:
                      type: boolean
                      description: Mirror the produced line to a PO additional fee (PURCHASE_ORDER + EXTRA_COST only).
                scopes:
                  type: array
                  description: Product / category / tag / supplier-SKU scopes. Replaces existing scopes when provided.
                  items:
                    type: object
                    required:
                      - scope_type
                      - scope_value
                    properties:
                      scope_type:
                        type: string
                        enum:
                          - PRODUCT
                          - SUPPLIER_SKU
                          - CATEGORY
                          - SUBCATEGORY
                          - TAG
                          - ATTRIBUTE
                      scope_value:
                        type: string
                      scope_operator:
                        type: string
                        enum:
                          - EQUALS
                          - NOT_EQUALS
                          - IN
                          - NOT_IN
                          - CONTAINS
                          - STARTS_WITH
                          - ENDS_WITH
                          - GREATER_THAN
                          - LESS_THAN
                          - GREATER_THAN_OR_EQUALS
                          - LESS_THAN_OR_EQUALS
                          - ALL
                      scope_extra:
                        type: object
                        nullable: true
                conditions:
                  type: array
                  description: Document-level applicability gates. Replaces existing conditions when provided.
                  items:
                    type: object
                    required:
                      - condition_type
                      - values
                    properties:
                      condition_type:
                        type: string
                        enum:
                          - SUPPLIER
                          - SOURCE_WAREHOUSE
                          - DESTINATION_WAREHOUSE
                          - SHIPMENT_TYPE
                          - CUSTOM_FIELD
                      field_key:
                        type: string
                        maxLength: 100
                        nullable: true
                        description: |
                          The custom-field key to match against (e.g. `two_sided`, `front_color_bucket`).
                          **Required** when `condition_type` is `CUSTOM_FIELD`; ignored otherwise.
                      operator:
                        type: string
                        enum:
                          - IN
                          - NOT_IN
                          - BETWEEN
                          - GREATER_THAN_OR_EQUALS
                          - LESS_THAN_OR_EQUALS
                        description: |
                          How `values` are matched. Defaults to `IN`. The numeric operators
                          (`BETWEEN`, `GREATER_THAN_OR_EQUALS`, `LESS_THAN_OR_EQUALS`) are intended
                          for `CUSTOM_FIELD` range conditions; `BETWEEN` expects two `values`.
                      values:
                        type: array
                        minItems: 1
                        items:
                          type: string
                tiers:
                  type: array
                  description: Quantity tiers with their effects. Replaces existing tiers when provided.
                  items:
                    type: object
                    required:
                      - min_quantity
                      - effects
                    properties:
                      min_quantity:
                        type: number
                        minimum: 0
                      max_quantity:
                        type: number
                        minimum: 0
                        nullable: true
                        description: Must be greater than or equal to `min_quantity`.
                      effects:
                        type: array
                        minItems: 1
                        items:
                          type: object
                          required:
                            - effect_type
                            - amount
                          properties:
                            effect_type:
                              type: string
                              enum:
                                - BASE_PRICE
                                - PERCENT_DISCOUNT
                                - PERCENT_MARKUP
                                - FIXED_PER_UNIT
                                - FIXED_PER_LINE
                                - FIXED_PER_DOCUMENT
                                - MINIMUM_FLOOR
                            amount:
                              type: number
                            sequence:
                              type: integer
                              minimum: 0
                              nullable: true
                            description:
                              type: string
                              maxLength: 255
                              nullable: true
            examples:
              changeAmount:
                summary: Change the unit amount on an existing rule
                value:
                  name: Material cost — SKU-ABC
                  tiers:
                    - min_quantity: '0'
                      effects:
                        - effect_type: FIXED_PER_UNIT
                          amount: '13.75'
                          sequence: 1
                          description: Material cost
      responses:
        '200':
          description: Cost rule updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A cost rule — vendor-scoped tiered pricing or extra-cost rule applied to
                      purchase orders, work orders, and shipments. Nested `scopes`, `conditions`,
                      and `tiers` (with `effects`) are only present when the relation is loaded
                      (always on `GET /cost-rules/{id}`).
                    properties:
                      id:
                        type: integer
                        description: Cost rule ID.
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Supplier / factory ID the rule is scoped to. Null for an EXTRA_COST rule with no supplier condition.
                      vendor_name:
                        type: string
                        nullable: true
                        description: Supplier factory name. Only present when the vendor relation is loaded.
                      name:
                        type: string
                        description: 'Rule name, unique per vendor among non-deleted rules.'
                      description:
                        type: string
                        nullable: true
                      document_type:
                        type: string
                        nullable: true
                        description: First entry of `document_types` (convenience field).
                        enum:
                          - PURCHASE_ORDER
                          - WORK_ORDER
                          - SHIPMENT
                          - PRODUCTION_RUN
                      document_types:
                        type: array
                        description: Document types the rule applies to.
                        items:
                          type: string
                          enum:
                            - PURCHASE_ORDER
                            - WORK_ORDER
                            - SHIPMENT
                            - PRODUCTION_RUN
                      tier_mode:
                        type: string
                        nullable: true
                        enum:
                          - NON_GRADUATED
                          - GRADUATED
                      tier_quantity_basis:
                        type: string
                        nullable: true
                        enum:
                          - LINE
                          - SCOPE_GROUP
                          - PRODUCTION_RUN_TOTAL
                      priority:
                        type: integer
                        nullable: true
                        description: 'Evaluation priority (1–1000, lower wins).'
                      status:
                        type: string
                        enum:
                          - ACTIVE
                          - INACTIVE
                          - DRAFT
                      is_active:
                        type: boolean
                        description: Convenience flag — true when `status` is `ACTIVE`.
                      effective_from:
                        type: string
                        format: date
                        nullable: true
                      effective_to:
                        type: string
                        format: date
                        nullable: true
                      moq:
                        type: number
                        nullable: true
                        description: Minimum order quantity.
                      order_multiple:
                        type: number
                        nullable: true
                      output_kind:
                        type: string
                        nullable: true
                        enum:
                          - UNIT_COST
                          - EXTRA_COST
                      extra_cost_item_name:
                        type: string
                        nullable: true
                      cost_allocation_type:
                        type: string
                        nullable: true
                        enum:
                          - UNIT_BASED_ALLOCATION
                          - VOLUME_BASED_ALLOCATION
                          - WEIGHT_BASED_ALLOCATION
                          - VALUE_BASED_ALLOCATION
                      cost_basis:
                        type: string
                        nullable: true
                        enum:
                          - PERCENTAGE
                          - FIXED
                      cost_basis_amount:
                        type: number
                        nullable: true
                      shipment_type:
                        type: string
                        nullable: true
                        description: Optional Air/Sea/Road/Rail/Express scope for shipment rules.
                      options:
                        type: object
                        description: Rule-level options bag.
                        properties:
                          auto_apply:
                            type: boolean
                            description: Server fires this rule automatically on PO / shipment save.
                          add_as_additional_fee:
                            type: boolean
                            description: Mirror the produced line to a PO additional fee (PURCHASE_ORDER + EXTRA_COST only).
                      scopes:
                        type: array
                        description: Product / category / tag / supplier-SKU scopes. Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            scope_type:
                              type: string
                              enum:
                                - PRODUCT
                                - SUPPLIER_SKU
                                - CATEGORY
                                - SUBCATEGORY
                                - TAG
                                - ATTRIBUTE
                            scope_value:
                              type: string
                            scope_operator:
                              type: string
                              nullable: true
                              enum:
                                - EQUALS
                                - NOT_EQUALS
                                - IN
                                - NOT_IN
                                - CONTAINS
                                - STARTS_WITH
                                - ENDS_WITH
                                - GREATER_THAN
                                - LESS_THAN
                                - GREATER_THAN_OR_EQUALS
                                - LESS_THAN_OR_EQUALS
                                - ALL
                            scope_extra:
                              type: object
                              nullable: true
                      conditions:
                        type: array
                        description: Document-level applicability gates (extra-cost rules). Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            condition_type:
                              type: string
                              enum:
                                - SUPPLIER
                                - SOURCE_WAREHOUSE
                                - DESTINATION_WAREHOUSE
                                - SHIPMENT_TYPE
                                - CUSTOM_FIELD
                            field_key:
                              type: string
                              nullable: true
                              description: Custom-field key the condition matches on. Populated only for `CUSTOM_FIELD` conditions (e.g. `Print Locations`); `null` for all other condition types.
                            operator:
                              type: string
                              nullable: true
                              enum:
                                - IN
                                - NOT_IN
                                - BETWEEN
                                - GREATER_THAN_OR_EQUALS
                                - LESS_THAN_OR_EQUALS
                            values:
                              type: array
                              items:
                                type: string
                      tiers:
                        type: array
                        description: Quantity tiers with their effects. Present when loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            cost_rule_id:
                              type: integer
                            min_quantity:
                              type: number
                            max_quantity:
                              type: number
                              nullable: true
                            effects:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  cost_rule_id:
                                    type: integer
                                  cost_rule_tier_id:
                                    type: integer
                                  effect_type:
                                    type: string
                                    enum:
                                      - BASE_PRICE
                                      - PERCENT_DISCOUNT
                                      - PERCENT_MARKUP
                                      - FIXED_PER_UNIT
                                      - FIXED_PER_LINE
                                      - FIXED_PER_DOCUMENT
                                      - MINIMUM_FLOOR
                                  amount:
                                    type: number
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Effect sequence within the tier.
                                  description:
                                    type: string
                                    nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '400':
          description: Update failed (e.g. invalid state transition).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Cost rule not found, or Cost Rules feature not enabled for this tenant.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteCostRule
      tags:
        - Cost Rules
      summary: Delete a cost rule
      description: |
        Permanently delete a cost rule. Requires the tenant **Cost Rules** feature
        flag.

        A rule that has already been applied — it has one or more cost-rule
        resolutions — is refused with `422`. Deactivate such a rule by setting its
        `status` to `INACTIVE` via the update endpoint instead.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Cost rule ID.
      responses:
        '200':
          description: Cost rule deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Cost rule deleted.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Cost rule not found, or Cost Rules feature not enabled for this tenant.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The rule has been applied and cannot be deleted — deactivate it instead.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /deals:
    get:
      operationId: getDeals
      tags:
        - Deals
      summary: List deals
      description: List CRM deals with optional filters and pagination.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: limit
          schema:
            type: integer
            default: 25
            maximum: 200
          description: Number of records per page.
        - in: query
          name: page
          schema:
            type: integer
          description: Page number.
        - in: query
          name: pipeline_id
          schema:
            type: integer
          description: Restrict to a specific pipeline.
        - in: query
          name: stage_id
          schema:
            type: integer
          description: Restrict to a specific pipeline stage.
        - in: query
          name: status
          schema:
            type: string
            enum:
              - open
              - won
              - lost
          description: Restrict to deals in this status.
        - in: query
          name: business_account_id
          schema:
            type: integer
          description: Restrict to deals on a specific company.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        name:
                          type: string
                        status:
                          type: string
                          enum:
                            - open
                            - won
                            - lost
                        amount:
                          type: number
                          format: float
                        expected_close_date:
                          type: string
                          format: date
                          nullable: true
                        closed_at:
                          type: string
                          format: date-time
                          nullable: true
                        lost_reason:
                          type: string
                          nullable: true
                        stage_changed_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: When the deal last moved to its current pipeline stage. Used to compute time-in-stage.
                        notes:
                          type: string
                          nullable: true
                        business_account_id:
                          type: integer
                          nullable: true
                        primary_contact_id:
                          type: integer
                          nullable: true
                        owner_id:
                          type: integer
                          nullable: true
                        deal_pipeline_id:
                          type: integer
                        deal_pipeline_stage_id:
                          type: integer
                        sales_orders_count:
                          type: integer
                        invoices_count:
                          type: integer
                        bills_count:
                          type: integer
                        purchase_orders_count:
                          type: integer
                        work_orders_count:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/deals/{dealId}':
    get:
      operationId: getDealById
      tags:
        - Deals
      summary: Single deal
      description: 'Get details of a specific deal by ID. Includes aggregate counts of linked sales orders, invoices, bills, supplier purchase orders, and work orders.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      name:
                        type: string
                      status:
                        type: string
                        enum:
                          - open
                          - won
                          - lost
                      amount:
                        type: number
                        format: float
                      expected_close_date:
                        type: string
                        format: date
                        nullable: true
                      closed_at:
                        type: string
                        format: date-time
                        nullable: true
                      lost_reason:
                        type: string
                        nullable: true
                      stage_changed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When the deal last moved to its current pipeline stage. Used to compute time-in-stage.
                      notes:
                        type: string
                        nullable: true
                      business_account_id:
                        type: integer
                        nullable: true
                      primary_contact_id:
                        type: integer
                        nullable: true
                      owner_id:
                        type: integer
                        nullable: true
                      deal_pipeline_id:
                        type: integer
                      deal_pipeline_stage_id:
                        type: integer
                      sales_orders_count:
                        type: integer
                      invoices_count:
                        type: integer
                      bills_count:
                        type: integer
                      purchase_orders_count:
                        type: integer
                      work_orders_count:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/deals/{dealId}/bills':
    get:
      operationId: getDealBills
      tags:
        - Deals
      summary: List bills linked to a deal
      description: List AP bills linked to the given CRM deal.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        bill_number:
                          type: string
                          nullable: true
                        vendor_id:
                          type: integer
                          nullable: true
                        vendor_name:
                          type: string
                          nullable: true
                        status:
                          type: string
                          nullable: true
                        currency_code:
                          type: string
                          nullable: true
                        gross_amount:
                          type: number
                          format: float
                        outstanding_amount:
                          type: number
                          format: float
                        bill_date:
                          type: string
                          format: date
                          nullable: true
                        due_date:
                          type: string
                          format: date
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/deals/{dealId}/bills/{billId}':
    post:
      operationId: linkBillToDeal
      tags:
        - Deals
      summary: Link a bill to a deal
      description: |
        Link an existing AP bill to a CRM deal. Idempotent — linking the same bill
        twice has no additional effect. An entry is added to the deal's activity log.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
        - in: path
          name: billId
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Successful response — returns the linked bill summary.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal or bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: unlinkBillFromDeal
      tags:
        - Deals
      summary: Unlink a bill from a deal
      description: Remove the link between a deal and a bill. The bill itself is not deleted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
        - in: path
          name: billId
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Bill unlinked
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/deals/{dealId}/purchase-orders':
    get:
      operationId: getDealPurchaseOrders
      tags:
        - Deals
      summary: List supplier POs linked to a deal
      description: List supplier purchase orders linked to the given CRM deal.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        po_number:
                          type: string
                        vendor_id:
                          type: integer
                          nullable: true
                        vendor_name:
                          type: string
                          nullable: true
                        status:
                          type: string
                          nullable: true
                        total_cost:
                          type: number
                          format: float
                        total_paid:
                          type: number
                          format: float
                        due_amount:
                          type: number
                          format: float
                        created_at:
                          type: string
                          format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/deals/{dealId}/purchase-orders/{purchaseOrderId}':
    post:
      operationId: linkPurchaseOrderToDeal
      tags:
        - Deals
      summary: Link a supplier PO to a deal
      description: |
        Link an existing supplier purchase order to a CRM deal. Idempotent.
        An entry is added to the deal's activity log.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Supplier purchase order ID
      responses:
        '200':
          description: Successful response — returns the linked PO summary.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal or PO not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: unlinkPurchaseOrderFromDeal
      tags:
        - Deals
      summary: Unlink a supplier PO from a deal
      description: Remove the link between a deal and a supplier purchase order. The PO itself is not deleted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Supplier purchase order ID
      responses:
        '200':
          description: Purchase order unlinked
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/deals/{dealId}/work-orders':
    get:
      operationId: getDealWorkOrders
      tags:
        - Deals
      summary: List work orders linked to a deal
      description: List work orders linked to the given CRM deal.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        work_order_number:
                          type: string
                        status:
                          type: string
                        produced_sku_id:
                          type: integer
                          nullable: true
                        produced_sku:
                          type: string
                          nullable: true
                        produced_product_name:
                          type: string
                          nullable: true
                        planned_qty:
                          type: string
                        expected_completion_date:
                          type: string
                          format: date
                          nullable: true
                        production_warehouse_id:
                          type: integer
                          nullable: true
                        destination_warehouse_id:
                          type: integer
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/deals/{dealId}/work-orders/{workOrderId}':
    post:
      operationId: linkWorkOrderToDeal
      tags:
        - Deals
      summary: Link a work order to a deal
      description: |
        Link an existing work order to a CRM deal. Idempotent.
        An entry is added to the deal's activity log.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: Work order ID
      responses:
        '200':
          description: Successful response — returns the linked work order summary.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal or work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: unlinkWorkOrderFromDeal
      tags:
        - Deals
      summary: Unlink a work order from a deal
      description: Remove the link between a deal and a work order. The work order itself is not deleted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: dealId
          required: true
          schema:
            type: integer
          description: Deal ID
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: Work order ID
      responses:
        '200':
          description: Work order unlinked
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Deal not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /inventory/adjustments:
    get:
      operationId: getInventoryAdjustments
      tags:
        - Inventory
      summary: Inventory adjustments
      description: |
        Get a paginated list of posted inventory adjustments, so integrations can
        audit the adjustments they have submitted. Results default to newest first
        (`created_at:desc`). Each item is an adjustment header; the per-line
        `entries` are returned only by `GET /inventory/adjustments/{adjustmentId}`.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### DateTime Filters
        - `created_at`: When the adjustment was created
        - `updated_at`: When the adjustment was last updated
        - `effective_date`: The adjustment's business/effective date

        ### Boolean Filters
        - `is_correction`: Whether the adjustment was posted as a correction

        ### String Filters
        - `remarks`: Remarks recorded on the adjustment

        ## Examples
        ```
        # Adjustments created since a date
        ?created_at[gte]=2026-01-01

        # Only corrections
        ?is_correction[eq]=true
        ```
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: sort
          schema:
            type: string
            default: 'created_at:desc'
          description: |
            Sort results by field and direction. Format: `field:direction`

            Available sort fields:
            - `id`
            - `created_at`
            - `updated_at`
            - `effective_date`
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: effective_date
          schema:
            type: string
            format: date
          description: Filter by effective date
        - in: query
          name: is_correction
          schema:
            type: boolean
          description: Filter by whether the adjustment is a correction
        - in: query
          name: remarks
          schema:
            type: string
          description: Filter by remarks
      responses:
        '200':
          description: A list of inventory adjustments
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: 'A posted inventory adjustment header. Returned by the adjustment history list (`GET /inventory/adjustments`) and the single-adjustment endpoint (`GET /inventory/adjustments/{adjustmentId}`), which additionally includes the per-line `entries`.'
                      properties:
                        id:
                          type: integer
                          description: Unique identifier of the adjustment.
                        item_count:
                          type: integer
                          description: Number of detail lines (entries) in the adjustment.
                        remarks:
                          type: string
                          nullable: true
                          description: Free-text remarks recorded when the adjustment was posted.
                        status:
                          type: integer
                          description: Status code of the adjustment.
                        is_correction:
                          type: boolean
                          description: Whether the adjustment was posted as a correction of another record (e.g. a receiving-report quantity correction) rather than a standalone adjustment.
                        corrects_type:
                          type: string
                          nullable: true
                          description: 'Type of the record this adjustment corrects, when `is_correction` is `true`.'
                        corrects_id:
                          type: integer
                          nullable: true
                          description: 'ID of the record this adjustment corrects, when `is_correction` is `true`.'
                        effective_date:
                          type: string
                          format: date
                          nullable: true
                          description: Business/effective date of the adjustment.
                        posted_by:
                          type: integer
                          description: ID of the user who posted the adjustment.
                        posted_by_name:
                          type: string
                          nullable: true
                          description: Full name of the user who posted the adjustment.
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp of when the adjustment was created.
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp of when the adjustment was last updated.
                        entries:
                          type: array
                          description: Per-SKU/location detail lines of the adjustment. Present only on the single-adjustment endpoint; omitted from the list response.
                          items:
                            type: object
                            description: 'A single per-SKU/location detail line of a posted inventory adjustment. Returned only on the single-adjustment endpoint (`GET /inventory/adjustments/{adjustmentId}`), inside the `entries` array.'
                            properties:
                              rfq_id:
                                type: integer
                                description: Internal product ID the line applies to.
                              sku:
                                type: string
                                description: SKU of the adjusted product.
                              stock_id:
                                type: integer
                                nullable: true
                                description: ID of the stock record the line adjusted.
                              warehouse_id:
                                type: integer
                                description: Warehouse the line applied to.
                              location_id:
                                type: integer
                                nullable: true
                                description: Location within the warehouse the line applied to.
                              qty_onhand:
                                type: number
                                nullable: true
                                description: On-hand delta that was applied by this line.
                              adjusted_onhand_qty:
                                type: number
                                nullable: true
                                description: Applied on-hand quantity delta.
                              adjusted_incoming_qty:
                                type: number
                                nullable: true
                                description: Applied incoming quantity delta.
                              adjusted_pending_qty:
                                type: number
                                nullable: true
                                description: Applied pending quantity delta.
                              total_cost_value:
                                type: number
                                nullable: true
                                description: Total cost value change recorded for the line.
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
    post:
      operationId: createInventoryAdjustment
      tags:
        - Inventory
      summary: Adjust inventory stock
      description: |-
        Adjust on-hand stock for any given product in a given location. Either the product `sku` or `product_id` is required to identify the product.

        Up to 3000 entries may be submitted per request. Requests with more than 500 entries are processed asynchronously: the adjustment header is created and returned immediately, while the individual stock changes are applied in the background shortly after.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - adjustment_entries
              properties:
                remarks:
                  type: string
                  description: Optional remarks for the adjustment
                effective_date:
                  type: string
                  format: date
                  nullable: true
                  description: 'Optional business date the adjustment posts on. Lets an integration backdate an adjustment (for example, to land it in a prior accounting period) in a single call instead of posting and then correcting. Omit to post on the current date.'
                is_correction:
                  type: boolean
                  description: 'Marks this adjustment as a correction of another record. When `true`, both `corrects_type` and `corrects_id` are required — a correction must name the record it corrects. Supplying any of the three correction fields requires the complete set; an incomplete correction reference returns a 422. Defaults to `false` (a normal, non-correction adjustment).'
                corrects_type:
                  type: string
                  nullable: true
                  enum:
                    - adjustment
                    - receiving_report
                  description: The kind of record this adjustment corrects. Required when `is_correction` is `true` (or when `corrects_id` is supplied).
                corrects_id:
                  type: integer
                  minimum: 1
                  nullable: true
                  description: ID of the record (of type `corrects_type`) this adjustment corrects. Required when `is_correction` is `true` (or when `corrects_type` is supplied).
                adjustment_entries:
                  type: array
                  maxItems: 3000
                  description: 'One entry per stock adjustment. A maximum of 3000 entries may be submitted in a single request (exceeding this returns a 422). Payloads larger than 500 entries are posted asynchronously in the background: the response returns the created adjustment header immediately, but the individual stock changes finish posting shortly afterward rather than within the request.'
                  items:
                    type: object
                    required:
                      - warehouse_id
                      - location_id
                      - qty_onhand
                    properties:
                      warehouse_id:
                        type: integer
                        description: ID of the warehouse
                      location_id:
                        type: integer
                        description: ID of the location within the warehouse
                      product_id:
                        type: integer
                        description: 'ID of the product, required if sku is not provided'
                      sku:
                        type: string
                        description: 'SKU of the product, required if product_id is not provided'
                      qty_onhand:
                        type: integer
                        description: 'Additive change to on-hand quantity (a delta, not an absolute target): a positive value adds to current on-hand, a negative value removes. There is no single-call "set on-hand to X" mode.'
                      lot_id:
                        type: integer
                        nullable: true
                        description: 'ID of the product lot to adjust. Provide either `lot_id` or `lot_number`, not both. Required when the product has lot tracking enabled.'
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number to adjust (resolved to a lot for the product). Use instead of `lot_id`. Required when the product has lot tracking enabled.
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
                      create_lot:
                        type: boolean
                        description: 'Opt-in lot auto-create. When `true` and the given `lot_number` does not yet exist for the product, the lot is created (metadata only, seeded from the fields below) before the stock is posted. Defaults to `false`.'
                      production_date:
                        type: string
                        format: date
                        nullable: true
                        description: Production date used to seed a lot created via `create_lot`. Ignored when the lot already exists.
                      expiry_date:
                        type: string
                        format: date
                        nullable: true
                        description: Expiry date used to seed a lot created via `create_lot`. Ignored when the lot already exists.
                      manufacturer_code:
                        type: string
                        nullable: true
                        description: Manufacturer code used to seed a lot created via `create_lot`. Ignored when the lot already exists.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: ID of the created adjustment
                  remarks:
                    type: string
                    description: Remarks for the adjustment
                  posted_by:
                    type: integer
                    description: ID of the user who posted the adjustment
                  created_at:
                    type: string
                    format: date-time
                    description: Timestamp of when the adjustment was created
                  updated_at:
                    type: string
                    format: date-time
                    description: Timestamp of when the adjustment was last updated
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/inventory/adjustments/{adjustmentId}':
    get:
      operationId: getInventoryAdjustment
      tags:
        - Inventory
      summary: Inventory adjustment
      description: 'Get a single posted inventory adjustment, including its per-SKU/location detail lines in the `entries` array.'
      security:
        - BearerAuth: []
      parameters:
        - name: adjustmentId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the adjustment.
      responses:
        '200':
          description: Adjustment details
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A posted inventory adjustment header. Returned by the adjustment history list (`GET /inventory/adjustments`) and the single-adjustment endpoint (`GET /inventory/adjustments/{adjustmentId}`), which additionally includes the per-line `entries`.'
                    properties:
                      id:
                        type: integer
                        description: Unique identifier of the adjustment.
                      item_count:
                        type: integer
                        description: Number of detail lines (entries) in the adjustment.
                      remarks:
                        type: string
                        nullable: true
                        description: Free-text remarks recorded when the adjustment was posted.
                      status:
                        type: integer
                        description: Status code of the adjustment.
                      is_correction:
                        type: boolean
                        description: Whether the adjustment was posted as a correction of another record (e.g. a receiving-report quantity correction) rather than a standalone adjustment.
                      corrects_type:
                        type: string
                        nullable: true
                        description: 'Type of the record this adjustment corrects, when `is_correction` is `true`.'
                      corrects_id:
                        type: integer
                        nullable: true
                        description: 'ID of the record this adjustment corrects, when `is_correction` is `true`.'
                      effective_date:
                        type: string
                        format: date
                        nullable: true
                        description: Business/effective date of the adjustment.
                      posted_by:
                        type: integer
                        description: ID of the user who posted the adjustment.
                      posted_by_name:
                        type: string
                        nullable: true
                        description: Full name of the user who posted the adjustment.
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp of when the adjustment was created.
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp of when the adjustment was last updated.
                      entries:
                        type: array
                        description: Per-SKU/location detail lines of the adjustment. Present only on the single-adjustment endpoint; omitted from the list response.
                        items:
                          type: object
                          description: 'A single per-SKU/location detail line of a posted inventory adjustment. Returned only on the single-adjustment endpoint (`GET /inventory/adjustments/{adjustmentId}`), inside the `entries` array.'
                          properties:
                            rfq_id:
                              type: integer
                              description: Internal product ID the line applies to.
                            sku:
                              type: string
                              description: SKU of the adjusted product.
                            stock_id:
                              type: integer
                              nullable: true
                              description: ID of the stock record the line adjusted.
                            warehouse_id:
                              type: integer
                              description: Warehouse the line applied to.
                            location_id:
                              type: integer
                              nullable: true
                              description: Location within the warehouse the line applied to.
                            qty_onhand:
                              type: number
                              nullable: true
                              description: On-hand delta that was applied by this line.
                            adjusted_onhand_qty:
                              type: number
                              nullable: true
                              description: Applied on-hand quantity delta.
                            adjusted_incoming_qty:
                              type: number
                              nullable: true
                              description: Applied incoming quantity delta.
                            adjusted_pending_qty:
                              type: number
                              nullable: true
                              description: Applied pending quantity delta.
                            total_cost_value:
                              type: number
                              nullable: true
                              description: Total cost value change recorded for the line.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  /inventory/stocks/export:
    get:
      operationId: exportInventoryStocks
      tags:
        - Inventory
      summary: Export inventory stock (cursor pagination)
      description: |
        Bulk-export stock for all active products (`status > 0`) using cursor-based
        keyset pagination. Designed for full inventory syncs and reporting pipelines
        that need every product's warehouse, location, and lot-level stock in one pass.

        Each row aggregates warehouse-level quantities and a per-location breakdown,
        with per-lot detail for lot-tracked products and FIFO landed unit cost at both
        the product and warehouse level.

        ## Pagination

        | Parameter | Description |
        |-----------|-------------|
        | `cursor`  | Opaque token from `next_cursor` on the previous response. Omit on the **first** page. |
        | `limit`   | Max products per page. Default `100`, maximum `1000`. |

        Pages are ordered ascending by product `id` (keyset). The run is anchored to a
        fixed cutoff captured on the first request, so pages stay stable while records
        change mid-run.

        ## Example flow

        ```
        # 1. Start a run
        GET /inventory/stocks/export?limit=1000

        # 2. Continue while has_more is true
        GET /inventory/stocks/export?cursor=<next_cursor>

        # 3. Stop when has_more is false
        ```

        ## Notes

        - The cursor is cryptographically signed; do not modify it.
        - Only `cursor` and `limit` are accepted. Any other query parameter returns
          a **422**. Some deployments rewrite to `index.php?q=$uri&$args`; the server
          ignores the `q` query parameter during validation.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: cursor
          schema:
            type: string
          description: |
            Signed continuation token from a previous response's `next_cursor`.
            Omit on the first page.
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 100
          description: Maximum number of products to return per page.
      responses:
        '200':
          description: Successful export page
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - next_cursor
                  - has_more
                  - meta
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        One product row from the bulk stock export. Aggregates warehouse-level and
                        per-location stock for a single active product, with per-lot breakdowns for
                        lot-tracked products. Quantities are rolled up across all locations at the top
                        level and broken out under `location_stocks`.
                      properties:
                        id:
                          type: integer
                          description: Product ID.
                        sku:
                          type: string
                          description: Internal product SKU.
                        name:
                          type: string
                          description: Product name.
                        type:
                          type: string
                          description: Product type.
                        category_id:
                          type: integer
                          nullable: true
                          description: Product category ID.
                        category_name:
                          type: string
                          nullable: true
                          description: Product category name.
                        sub_category_id:
                          type: integer
                          nullable: true
                          description: Product sub-category ID.
                        sub_category_name:
                          type: string
                          nullable: true
                          description: Product sub-category name.
                        qty_onhand:
                          type: number
                          format: float
                          description: Total quantity on hand across all locations.
                        qty_incoming:
                          type: number
                          format: float
                          description: Total quantity incoming across all locations.
                        qty_available:
                          type: number
                          format: float
                          description: 'Total quantity available across all locations (`qty_onhand - qty_pending`). When the organization has unfulfillable stock tracking enabled, `qty_unfulfillable` is also subtracted (`qty_onhand - qty_pending - qty_unfulfillable`).'
                        qty_committed_wo:
                          type: number
                          format: float
                          description: Quantity across all locations committed (reserved) by in-progress work orders. `0` when none.
                        qty_free_to_use:
                          type: number
                          format: float
                          description: Quantity across all locations free to use after work-order commitments (`qty_onhand - qty_committed_wo`). Not floored at zero — a negative value means the SKU is short.
                        qty_needed_draft_wo:
                          type: number
                          format: float
                          description: 'Gross planned demand across all locations from draft (not yet started) work orders. `0` when none. Can exceed the sum of `location_stocks[].qty_needed_draft_wo`, since a draft work order can need the SKU at a warehouse with no stock row.'
                        qty_pending:
                          type: number
                          format: float
                          description: Total quantity pending across all locations.
                        qty_unfulfillable:
                          type: number
                          format: float
                          description: 'Total quantity reported as unfulfillable (e.g. damaged, quarantined, or otherwise not shippable) by the external 3PL/WMS across all locations. Always returned (`0` when none). Only subtracted from `qty_available` when the organization has unfulfillable stock tracking enabled.'
                        qty_backordered:
                          type: number
                          format: float
                          description: Quantity backordered for the product.
                        qty_available_via_assembly:
                          type: number
                          format: float
                          description: Quantity available via assembly for the product.
                        qty_recoverable_via_disassembly:
                          type: number
                          format: float
                          description: Quantity recoverable via disassembly for the product.
                        qty_outstanding:
                          type: number
                          format: float
                          description: Outstanding quantity for the product.
                        qty_reserved_fc_transfer:
                          type: number
                          format: float
                          nullable: true
                          description: 'Amazon FBA units being transferred between fulfillment centers, summed over the FBA warehouses in `location_stocks`. `null` (not `0`) when none of them is stocked by an Amazon FBA integration account.'
                        qty_reserved_fc_processing:
                          type: number
                          format: float
                          nullable: true
                          description: 'Amazon FBA units held for fulfillment-center processing (e.g. receiving or investigation), summed over the FBA warehouses in `location_stocks`. `null` when none of them is an FBA warehouse.'
                        qty_reserved_customer_order:
                          type: number
                          format: float
                          nullable: true
                          description: 'Amazon FBA units reserved for open Amazon customer orders, summed over the FBA warehouses in `location_stocks`. `null` when none of them is an FBA warehouse.'
                        current_landed_unit_cost:
                          type: number
                          format: float
                          nullable: true
                          description: |
                            Current landed unit cost from the oldest active cost layer with remaining
                            quantity across all warehouses (FIFO). `null` when no active cost layer exists.
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: |
                            Most recent stock-row update timestamp across the product's locations.
                            Falls back to the product's `created_at` when no stock rows exist.
                        location_stocks:
                          type: array
                          description: Per-warehouse/location stock breakdown.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Stock row ID.
                              warehouse:
                                type: object
                                description: Warehouse or location node as returned by the stock export.
                                properties:
                                  id:
                                    type: integer
                                    description: Warehouse/location ID.
                                  status:
                                    type: string
                                    nullable: true
                                    description: Warehouse/location status label.
                                  name:
                                    type: string
                                    nullable: true
                                    description: Warehouse/location name.
                                  parent_id:
                                    type: integer
                                    description: Parent warehouse/location ID (`0` when none).
                                  parent:
                                    nullable: true
                                    description: Always `null` on the export; use `parent_id` to resolve hierarchy.
                                  is_pick_location:
                                    type: boolean
                                    description: Whether this node is a pick location.
                                  created_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  updated_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                              location:
                                allOf:
                                  - type: object
                                    description: Warehouse or location node as returned by the stock export.
                                    properties:
                                      id:
                                        type: integer
                                        description: Warehouse/location ID.
                                      status:
                                        type: string
                                        nullable: true
                                        description: Warehouse/location status label.
                                      name:
                                        type: string
                                        nullable: true
                                        description: Warehouse/location name.
                                      parent_id:
                                        type: integer
                                        description: Parent warehouse/location ID (`0` when none).
                                      parent:
                                        nullable: true
                                        description: Always `null` on the export; use `parent_id` to resolve hierarchy.
                                      is_pick_location:
                                        type: boolean
                                        description: Whether this node is a pick location.
                                      created_at:
                                        type: string
                                        format: date-time
                                        nullable: true
                                      updated_at:
                                        type: string
                                        format: date-time
                                        nullable: true
                                nullable: true
                                description: Bin/location within the warehouse. `null` when the stock row is not bin-tracked.
                              qty_onhand:
                                type: number
                                format: float
                                description: Quantity on hand at this warehouse/location.
                              qty_incoming:
                                type: number
                                format: float
                                description: Quantity incoming at this warehouse/location.
                              qty_pending:
                                type: number
                                format: float
                                description: Quantity pending at this warehouse/location.
                              qty_unfulfillable:
                                type: number
                                format: float
                                description: 'Quantity at this warehouse/location reported as unfulfillable (e.g. damaged, quarantined, or otherwise not shippable) by the external 3PL/WMS. Always returned (`0` when none). Only subtracted from `qty_available` when the organization has unfulfillable stock tracking enabled.'
                              qty_available:
                                type: number
                                format: float
                                description: 'Quantity available at this warehouse/location (`qty_onhand - qty_pending`). When the organization has unfulfillable stock tracking enabled, `qty_unfulfillable` is also subtracted (`qty_onhand - qty_pending - qty_unfulfillable`).'
                              qty_committed_wo:
                                type: number
                                format: float
                                description: Quantity at this warehouse/location committed (reserved) by in-progress work orders. `0` when none.
                              qty_free_to_use:
                                type: number
                                format: float
                                description: Quantity at this warehouse/location free to use after work-order commitments (`qty_onhand - qty_committed_wo`). Not floored at zero — a negative value means the SKU is short.
                              qty_needed_draft_wo:
                                type: number
                                format: float
                                description: Gross planned demand at this warehouse/location from draft (not yet started) work orders. `0` when none.
                              qty_available_via_assembly:
                                type: number
                                format: float
                                description: Quantity available via assembly at this warehouse/location.
                              qty_recoverable_via_disassembly:
                                type: number
                                format: float
                                description: Quantity recoverable via disassembly at this warehouse/location.
                              qty_reserved_fc_transfer:
                                type: number
                                format: float
                                nullable: true
                                description: 'Amazon FBA units being transferred between fulfillment centers, from the latest Trackstar stock sync. `null` (not `0`) when this warehouse is not stocked by an Amazon FBA integration account.'
                              qty_reserved_fc_processing:
                                type: number
                                format: float
                                nullable: true
                                description: 'Amazon FBA units held for fulfillment-center processing, from the latest Trackstar stock sync. `null` when this warehouse is not an FBA warehouse.'
                              qty_reserved_customer_order:
                                type: number
                                format: float
                                nullable: true
                                description: 'Amazon FBA units reserved for open Amazon customer orders, from the latest Trackstar stock sync. `null` when this warehouse is not an FBA warehouse.'
                              current_landed_unit_cost:
                                type: number
                                format: float
                                nullable: true
                                description: |
                                  Current landed unit cost from the oldest active cost layer with
                                  remaining quantity for this warehouse (FIFO). `null` when none exists.
                              lot_stocks:
                                type: array
                                description: Per-lot stock breakdown at this location. Populated only for lot-tracked products; an empty array otherwise.
                                items:
                                  type: object
                                  properties:
                                    lot_id:
                                      type: integer
                                      description: Lot ID.
                                    lot_number:
                                      type: string
                                      nullable: true
                                      description: Lot number.
                                    production_date:
                                      type: string
                                      format: date
                                      nullable: true
                                      description: Lot production date.
                                    expiry_date:
                                      type: string
                                      format: date
                                      nullable: true
                                      description: Lot expiry date.
                                    location_id:
                                      type: integer
                                      description: ID of the location holding this lot's stock.
                                    qty_onhand:
                                      type: number
                                      format: float
                                      description: Quantity on hand for this lot at the location.
                  next_cursor:
                    type: string
                    nullable: true
                    description: Signed cursor token to fetch the next page. `null` when the export is complete.
                  has_more:
                    type: boolean
                    description: '`true` when the page is full (`data.length === limit`), indicating more rows may exist.'
                  meta:
                    type: object
                    required:
                      - rows
                    properties:
                      rows:
                        type: integer
                        minimum: 0
                        description: Number of items in `data` for this response.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '422':
          description: 'Validation error (invalid `cursor`/`limit`, or unsupported query parameter)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /inventory/stocks:
    get:
      operationId: getInventoryStocks
      tags:
        - Inventory
      summary: Inventory stock
      description: |
        Get a paginated list of inventory stock levels with various filter options.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## ⚠️ Important: Default Sorting and Pagination

        **By default, results are sorted by `updated_at` in descending order.** This field changes frequently as stock levels are updated, which can cause issues when paginating through results:

        - Items may be skipped or duplicated between pages
        - The same item may appear on multiple pages
        - Some items may never appear if they're updated while you're paginating

        **Recommendation:** When pulling all stocks or paginating through large datasets, use a more stable sort field such as:
        - `product.id:asc` - Sort by product ID (most stable)
        - `product.sku:asc` - Sort by product SKU
        - `product.name:asc` - Sort by product name

        Example: `?sort=product.id:asc&per_page=100`

        ## Available Sort Fields

        - `product.id` - Sort by product ID
        - `product.sku` - Sort by product SKU
        - `product.name` - Sort by product name
        - `updated_at` - Sort by last stock update date (default: `updated_at:desc`)

        Sort format: `field:direction` where direction is `asc` (ascending) or `desc` (descending).

        Examples:
        - `?sort=product.id:asc` - Sort by product ID ascending
        - `?sort=product.sku:desc` - Sort by product SKU descending
        - `?sort=product.name:asc` - Sort by product name ascending
        - `?sort=updated_at:asc` - Sort by update date ascending (overrides default)

        ## Available Filters
        ### Inventory Filters
        - `location`: Filter by location ID
        - `warehouse_ids`: Filter by warehouse ID(s), comma-separated
        - `warehouse_group_ids`: Filter by warehouse group ID(s), comma-separated
        - `qty_onhand`: Filter by quantity on hand
        - `qty_pending`: Filter by pending quantity
        - `qty_available`: Filter by available quantity (nets out unfulfillable stock when unfulfillable stock tracking is enabled, matching the `qty_available` response field)
        - `qty_incoming`: Filter by incoming quantity
        - `qty_backordered`: Filter by quantity backordered
        - `qty_available_via_assembly`: Filter by quantity available via assembly
        - `qty_recoverable_via_disassembly`: Filter by quantity recoverable via disassembly
        - `qty_outstanding`: Filter by quantity outstanding
        - `updated_at`: Filter by last stock update date
        - `discontinued`: Filter by discontinued status (0 = not discontinued, 1 = discontinued, 2+ = all)
        - `sku`: Filter by SKU (searches product name, internal SKU, UPC, and alternate SKUs)
        - `product_name`: Filter by product name
        - `category_id`: Filter by category ID(s), comma-separated
        - `subcategory_ids`: Filter by subcategory ID(s), comma-separated

        ### Product String Filters
        - `product.name`: Product name
        - `product.description`: Product description
        - `product.sku`: Product SKU (searches both internal SKU and alternate SKUs)
        - `product.upc`: Product UPC/Barcode
        - `product.tag`: Product tags
        - `product.q`: General search matches name OR upc OR sku
        - `product.category.name`: Filter by category name
        - `product.sub_category.name`: Filter by sub-category name
        - `product.supplier.name`: Filter by supplier name

        ### Product Integer Filters
        - `product.id`: Filter by product ID
        - `product.category.id`: Filter by category ID
        - `product.sub_category.id`: Filter by sub-category ID
        - `product.supplier.id`: Filter by supplier ID
        - `product_type_id`: Filter by product type ID

        ### Product String Filters (Product Type)
        - `product_type`: Filter by product type

        ### Product Float Filters
        - `product.retail_price`: Product retail price
        - `product.wholesale_price`: Product wholesale price
        - `product.product_weight`: Product weight
        - `product.product_length`: Product length (in inches)
        - `product.product_width`: Product width (in inches)
        - `product.product_height`: Product height (in inches)
        - `product.box_length`: Box length (in inches)
        - `product.box_width`: Box width (in inches)
        - `product.box_height`: Box height (in inches)
        - `product.carton_length`: Carton length (in inches)
        - `product.carton_width`: Carton width (in inches)
        - `product.carton_height`: Carton height (in inches)
        - `product.shipping_length`: Shipping length (in inches)
        - `product.shipping_width`: Shipping width (in inches)
        - `product.shipping_height`: Shipping height (in inches)
        - `product.pallet_length`: Pallet length (in inches)
        - `product.pallet_width`: Pallet width (in inches)
        - `product.pallet_height`: Pallet height (in inches)

        ### Product String Filters (Dimension Weights)
        - `product.box_weight`: Box weight
        - `product.carton_weight`: Carton weight
        - `product.shipping_weight`: Shipping weight
        - `product.pallet_weight`: Pallet weight

        ### Product Boolean Filters
        - `product.sellable`: If the product is sellable or not
        - `product.discontinued`: If the product is discontinued

        ### Product DateTime Filters
        - `product.created_at`: When the product was created
        - `product.updated_at`: When the product was last updated

        ## Examples
        ```
        # Find stock for products by SKU
        ?product.sku[eq]=SKU-001

        # Find stock for products by multiple SKUs
        ?product.sku[in]=SKU-001,SKU-002,SKU-003

        # Find stock for specific product by ID
        ?product.id[eq]=12345

        # Find stock for multiple products by ID
        ?product.id[in]=12345,67890,11111

        # Find stock for products in specific price range
        ?product.retail_price[gte]=50.00&product.retail_price[lte]=100.00

        # Find stock for recently updated products
        ?product.updated_at[gte]=2024-01-01 00:00:00

        # Find stock for products where name contains "Partial text"
        ?product.name[contains]=Partial text

        # Find stock for products in specific category and location
        ?product.category.name[eq]=Electronics&location=123

        # Find stock for products from specific supplier in certain warehouses
        ?product.supplier.name[contains]=Acme&warehouse_ids=1,2,3

        # Find stock with specific quantity levels
        ?qty_onhand[gte]=100&qty_available[gt]=0

        # Find stock with low inventory
        ?qty_onhand[lte]=10

        # Find stock with pending quantities
        ?qty_pending[gt]=0

        # Find stock with incoming inventory
        ?qty_incoming[gte]=50

        # Find stock with backordered quantities
        ?qty_backordered[gt]=0

        # Find stock with assembly availability
        ?qty_available_via_assembly[gte]=10

        # Find stock recoverable via disassembly
        ?qty_recoverable_via_disassembly[gt]=5

        # Find stock with outstanding quantities
        ?qty_outstanding[gt]=0

        # Find stock updated after a specific date
        ?updated_at[gte]=2024-01-01 00:00:00

        # Find stock by product type
        ?product_type[eq]=KIT

        # Find stock by product type ID
        ?product_type_id[eq]=1

        # Find stock for sellable products only
        ?product.sellable=1

        # Find stock for discontinued products
        ?product.discontinued=1

        # Search across multiple product fields
        ?product.q[contains]=laptop

        # Sort examples (recommended for pagination)
        # Sort by product ID for stable pagination
        ?sort=product.id:asc&per_page=100

        # Sort by product SKU
        ?sort=product.sku:asc

        # Sort by product name
        ?sort=product.name:asc

        # Sort by update date ascending (overrides default DESC)
        ?sort=updated_at:asc

        # Combine sorting with filters
        ?product.category.id[eq]=5&sort=product.name:asc&per_page=50
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 100
          description: Number of items per page
        - in: query
          name: sort
          schema:
            type: string
            default: 'updated_at:desc'
          description: |
            Sort results by field and direction. Format: `field:direction`

            **⚠️ Warning:** Default sorting by `updated_at` changes frequently and can cause pagination issues. 
            For stable pagination, use `product.id:asc`, `product.sku:asc`, or `product.name:asc`.

            Available sort fields:
            - `product.id` - Product ID
            - `product.sku` - Product SKU
            - `product.name` - Product name
            - `updated_at` - Last stock update date (default)

            Examples:
            - `product.id:asc` - Sort by product ID ascending
            - `product.sku:desc` - Sort by product SKU descending
            - `product.name:asc` - Sort by product name ascending
            - `updated_at:asc` - Sort by update date ascending
        - in: query
          name: location
          schema:
            type: integer
          description: Filter by location ID
        - in: query
          name: warehouse_ids
          schema:
            type: string
          description: 'Filter by warehouse ID(s), comma-separated'
        - in: query
          name: warehouse_group_ids
          schema:
            type: string
          description: 'Filter by warehouse group ID(s), comma-separated'
        - in: query
          name: qty_onhand
          schema:
            type: integer
          description: Filter by quantity on hand
        - in: query
          name: qty_pending
          schema:
            type: integer
          description: Filter by pending quantity
        - in: query
          name: qty_available
          schema:
            type: integer
          description: 'Filter by available quantity. When the organization has unfulfillable stock tracking enabled, available is `qty_onhand - qty_pending - qty_unfulfillable`; otherwise `qty_onhand - qty_pending`.'
        - in: query
          name: qty_incoming
          schema:
            type: integer
          description: Filter by incoming quantity
        - in: query
          name: qty_backordered
          schema:
            type: number
            format: float
          description: Filter by quantity backordered
        - in: query
          name: qty_available_via_assembly
          schema:
            type: number
            format: float
          description: Filter by quantity available via assembly
        - in: query
          name: qty_recoverable_via_disassembly
          schema:
            type: number
            format: float
          description: Filter by quantity recoverable via disassembly
        - in: query
          name: qty_outstanding
          schema:
            type: number
            format: float
          description: Filter by quantity outstanding
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last stock update date
        - in: query
          name: discontinued
          schema:
            type: integer
          description: 'Filter by discontinued status (0 = not discontinued, 1 = discontinued, 2+ = all)'
        - in: query
          name: sku
          schema:
            type: string
          description: 'Filter by SKU (searches product name, internal SKU, UPC, and alternate SKUs)'
        - in: query
          name: product_name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: category_id
          schema:
            type: string
          description: 'Filter by category ID(s), comma-separated'
        - in: query
          name: subcategory_ids
          schema:
            type: string
          description: 'Filter by subcategory ID(s), comma-separated'
        - in: query
          name: product_type
          schema:
            type: string
          description: Filter by product type
        - in: query
          name: product_type_id
          schema:
            type: integer
          description: Filter by product type ID
        - in: query
          name: product.q
          schema:
            type: string
          description: Filter by name OR upc OR sku
        - in: query
          name: product.id
          schema:
            type: integer
          description: Filter by product ID
        - in: query
          name: product.name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: product.description
          schema:
            type: string
          description: Filter by product description
        - in: query
          name: product.sku
          schema:
            type: string
          description: Filter by SKU (searches both internal and alternate SKUs)
        - in: query
          name: product.upc
          schema:
            type: string
          description: Filter by UPC/Barcode
        - in: query
          name: product.sellable
          schema:
            type: boolean
          description: Filter by sellable status
        - in: query
          name: product.discontinued
          schema:
            type: boolean
          description: Filter by whether the product is discontinued
        - in: query
          name: product.retail_price
          schema:
            type: number
            format: float
          description: Filter by retail price
        - in: query
          name: product.wholesale_price
          schema:
            type: number
            format: float
          description: Filter by wholesale price
        - in: query
          name: product.created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: product.updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: product.tag
          schema:
            type: string
          description: Filter by product tags
        - in: query
          name: product.category.id
          schema:
            type: integer
          description: Filter by category ID
        - in: query
          name: product.category.name
          schema:
            type: string
          description: Filter by category name
        - in: query
          name: product.sub_category.id
          schema:
            type: integer
          description: Filter by sub-category ID
        - in: query
          name: product.sub_category.name
          schema:
            type: string
          description: Filter by sub-category name
        - in: query
          name: product.supplier.id
          schema:
            type: integer
          description: Filter by supplier ID
        - in: query
          name: product.supplier.name
          schema:
            type: string
          description: Filter by supplier name
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Product ID
                        sku:
                          type: string
                          description: Product SKU
                        name:
                          type: string
                          description: Name of the product
                        type:
                          type: string
                          description: Type of the product
                        qty_onhand:
                          type: number
                          format: float
                          description: Total quantity on hand across all locations
                        qty_pending:
                          type: number
                          format: float
                          description: Total quantity pending across all locations
                        qty_unfulfillable:
                          type: number
                          format: float
                          description: 'Total quantity reported as unfulfillable (e.g. damaged, quarantined, or otherwise not shippable) by the external 3PL/WMS across all locations. Always returned (`0` when none). Only subtracted from `qty_available` when the organization has unfulfillable stock tracking enabled.'
                        qty_available:
                          type: number
                          format: float
                          description: 'Total quantity available across all locations (`qty_onhand - qty_pending`). When the organization has unfulfillable stock tracking enabled, `qty_unfulfillable` is also subtracted (`qty_onhand - qty_pending - qty_unfulfillable`).'
                        qty_committed_wo:
                          type: number
                          format: float
                          description: Quantity across all locations committed (reserved) by in-progress work orders. `0` when none.
                        qty_free_to_use:
                          type: number
                          format: float
                          description: Quantity across all locations free to use after work-order commitments (`qty_onhand - qty_committed_wo`). Not floored at zero — a negative value means the SKU is short.
                        qty_needed_draft_wo:
                          type: number
                          format: float
                          description: 'Gross planned demand across all locations from draft (not yet started) work orders. `0` when none. Respects the request''s warehouse/location filter, and can include demand at warehouses that have no stock row for the product.'
                        qty_incoming:
                          type: number
                          format: float
                          description: Total quantity incoming across all locations
                        qty_backordered:
                          type: number
                          format: float
                          description: Total quantity backordered across all locations
                        qty_available_via_assembly:
                          type: number
                          format: float
                          description: Total quantity available via assembly across all locations
                        qty_recoverable_via_disassembly:
                          type: number
                          format: float
                          description: Total quantity recoverable via disassembly across all locations
                        qty_outstanding:
                          type: number
                          format: float
                          description: Total quantity outstanding across all locations
                        qty_reserved_fc_transfer:
                          type: number
                          format: float
                          nullable: true
                          description: 'Amazon FBA units being transferred between fulfillment centers, summed over the FBA warehouses in `location_stocks`. `null` (not `0`) when none of them is stocked by an Amazon FBA integration account.'
                        qty_reserved_fc_processing:
                          type: number
                          format: float
                          nullable: true
                          description: 'Amazon FBA units held for fulfillment-center processing (e.g. receiving or investigation), summed over the FBA warehouses in `location_stocks`. `null` when none of them is an FBA warehouse.'
                        qty_reserved_customer_order:
                          type: number
                          format: float
                          nullable: true
                          description: 'Amazon FBA units reserved for open Amazon customer orders, summed over the FBA warehouses in `location_stocks`. `null` when none of them is an FBA warehouse.'
                        current_landed_unit_cost:
                          type: number
                          format: float
                          nullable: true
                          description: |
                            Current landed unit cost from the oldest active cost layer with remaining quantity across all warehouses.
                            The cost is derived from cost layers using FIFO (First-In, First-Out) logic, selecting the oldest cost layer 
                            that has a remaining quantity greater than zero. Returns null if no active cost layer exists.
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: Last update timestamp for the stock
                        category_id:
                          type: integer
                          description: ID of the product category
                        sub_category_id:
                          type: integer
                          description: ID of the product subcategory
                        category_name:
                          type: string
                          description: Name of the product category
                        sub_category_name:
                          type: string
                          description: Name of the product subcategory
                        location_stocks:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                nullable: true
                                description: Stock location ID (null for virtual locations with no stock)
                              warehouse:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  status:
                                    type: string
                                  name:
                                    type: string
                                  parent_id:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                              location:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  status:
                                    type: string
                                  name:
                                    type: string
                                  parent_id:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                              qty_onhand:
                                type: number
                                format: float
                                description: Quantity on hand at location
                              qty_pending:
                                type: number
                                format: float
                                description: Quantity pending at location
                              qty_unfulfillable:
                                type: number
                                format: float
                                description: 'Quantity at location reported as unfulfillable (e.g. damaged, quarantined, or otherwise not shippable) by the external 3PL/WMS. Always returned (`0` when none). Only subtracted from `qty_available` when the organization has unfulfillable stock tracking enabled.'
                              qty_available:
                                type: number
                                format: float
                                description: 'Quantity available at location (`qty_onhand - qty_pending`). When the organization has unfulfillable stock tracking enabled, `qty_unfulfillable` is also subtracted (`qty_onhand - qty_pending - qty_unfulfillable`).'
                              qty_committed_wo:
                                type: number
                                format: float
                                description: Quantity at location committed (reserved) by in-progress work orders. `0` when none.
                              qty_free_to_use:
                                type: number
                                format: float
                                description: Quantity at location free to use after work-order commitments (`qty_onhand - qty_committed_wo`). Not floored at zero — a negative value means the SKU is short.
                              qty_needed_draft_wo:
                                type: number
                                format: float
                                description: Gross planned demand at location from draft (not yet started) work orders. `0` when none.
                              qty_incoming:
                                type: number
                                format: float
                                description: Quantity incoming at location
                              qty_available_via_assembly:
                                type: number
                                format: float
                                description: Quantity available via assembly at location
                              qty_recoverable_via_disassembly:
                                type: number
                                format: float
                                description: Quantity recoverable via disassembly at location
                              qty_reserved_fc_transfer:
                                type: number
                                format: float
                                nullable: true
                                description: 'Amazon FBA units being transferred between fulfillment centers, from the latest Trackstar stock sync. `null` (not `0`) when this warehouse is not stocked by an Amazon FBA integration account.'
                              qty_reserved_fc_processing:
                                type: number
                                format: float
                                nullable: true
                                description: 'Amazon FBA units held for fulfillment-center processing (e.g. receiving or investigation), from the latest Trackstar stock sync. `null` when this warehouse is not an FBA warehouse.'
                              qty_reserved_customer_order:
                                type: number
                                format: float
                                nullable: true
                                description: 'Amazon FBA units reserved for open Amazon customer orders, from the latest Trackstar stock sync. `null` when this warehouse is not an FBA warehouse.'
                              current_landed_unit_cost:
                                type: number
                                format: float
                                nullable: true
                                description: |
                                  Current landed unit cost from the oldest active cost layer with remaining quantity for this specific warehouse.
                                  The cost is derived from cost layers using FIFO (First-In, First-Out) logic, selecting the oldest cost layer 
                                  that has a remaining quantity greater than zero. Returns null if no active cost layer exists.
                              lot_stocks:
                                type: array
                                description: Per-lot stock breakdown at this location. Only populated for products with lot tracking enabled (and when lot data is loaded); otherwise an empty array.
                                items:
                                  type: object
                                  properties:
                                    lot_id:
                                      type: integer
                                      description: Lot ID.
                                    lot_number:
                                      type: string
                                      nullable: true
                                      description: Lot number.
                                    manufacturer_code:
                                      type: string
                                      nullable: true
                                      description: Manufacturer code recorded on the lot.
                                    production_date:
                                      type: string
                                      format: date
                                      nullable: true
                                      description: Lot production date.
                                    expiry_date:
                                      type: string
                                      format: date
                                      nullable: true
                                      description: Lot expiry date.
                                    location_id:
                                      type: integer
                                      description: ID of the location holding this lot's stock.
                                    qty_onhand:
                                      type: number
                                      format: float
                                      description: Quantity on hand for this lot at the location.
                                    qty_reserved:
                                      type: number
                                      format: float
                                      description: Quantity of this lot at the location already committed to other allocations. A picker cannot draw against reserved units.
                                    qty_available:
                                      type: number
                                      format: float
                                      description: '`qty_onhand - qty_reserved`, floored at `0`. An over-reserved bin (reserved greater than on-hand) reports `0` rather than a negative allowance.'
                              non_lot_stocks:
                                type: array
                                description: 'Per-bin breakdown of non-lot stock (stock rows with no lot) at this warehouse. Returned for all products, not just lot-tracked ones. The warehouse-level `location_stocks` rollup nets non-lot and lot layers together, so a non-lot layer offsetting a lot layer can be invisible in the rollup; this array surfaces each non-lot bin row individually. Empty for virtual (zero-stock) warehouse rows that have no stock-location data.'
                                items:
                                  type: object
                                  properties:
                                    location_id:
                                      type: integer
                                      description: ID of the bin (location) holding this non-lot stock.
                                    qty_onhand:
                                      type: number
                                      format: float
                                      description: Quantity on hand for this non-lot row at the bin.
                          description: List of stock entries across all locations
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /inventory/cost-layers:
    get:
      operationId: listCostLayers
      tags:
        - Inventory
      summary: List cost layers
      description: |
        List **legacy** FIFO/WAC cost layers (`rfq_stock_cost_layers`) with offset pagination.
        Each layer represents a quantity of a product received into a warehouse at a specific
        unit cost.

        <Note>
        These are legacy cost layers, **not** Luminous Core inventory-cost ledger rows. For the
        Core ledger use [`GET /core/inventory-costs`](/api-reference/core-inventory-ledger/list-core-inventory-costs).
        </Note>

        ## Depleted vs active layers
        Empty/depleted layers are **included by default**. To narrow the result:
        - Depleted only: `remaining_quantity[eq]=0`
        - Active only: `with_remaining_quantity=true` or `remaining_quantity[gt]=0`

        Soft-deleted layers are always excluded. On large tenants, combine with a `product_id`
        or `sku` filter.

        For filter operators and bracket syntax, see the [Filter System Documentation](/filters).
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Page number for pagination.
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 10
          description: Rows per page (max 100).
        - in: query
          name: product_id
          schema:
            type: integer
          description: 'Filter by product (RFQ) ID. Example `product_id[eq]=678`.'
        - in: query
          name: sku
          schema:
            type: string
          description: 'Filter by product internal SKU. Example `sku[eq]=ABC-001`.'
        - in: query
          name: warehouse_id
          schema:
            type: integer
          description: Filter by warehouse / location ID.
        - in: query
          name: remaining_quantity
          schema:
            type: number
          description: 'Filter by remaining quantity on the layer. Example `remaining_quantity[eq]=0` for depleted layers.'
        - in: query
          name: initial_quantity
          schema:
            type: number
          description: Filter by original (initial) quantity.
        - in: query
          name: cost_per_unit
          schema:
            type: number
          description: Filter by unit cost.
        - in: query
          name: is_variance
          schema:
            type: boolean
          description: Filter by whether the layer is a variance/adjustment layer.
        - in: query
          name: with_remaining_quantity
          schema:
            type: boolean
          description: 'When `true`, only returns layers with `remaining_quantity > 0`.'
      responses:
        '200':
          description: Paginated list of cost layers.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A legacy FIFO/WAC cost layer (`rfq_stock_cost_layers`). Each layer represents a
                        quantity of a product received into a warehouse at a specific unit cost. These are
                        distinct from Luminous Core inventory-cost ledger rows (see `/core/inventory-costs`).
                      properties:
                        layer_id:
                          type: integer
                          description: Cost layer ID.
                        received_at:
                          type: string
                          nullable: true
                          description: 'When the layer was received (`YYYY-MM-DD HH:mm:ss`). Derived from the layer creation date.'
                          example: '2024-06-01 14:22:00'
                        original_quantity:
                          type: number
                          format: float
                          description: Original quantity received into the layer.
                        remaining_quantity:
                          type: number
                          format: float
                          description: Quantity still remaining on the layer. `0` for fully depleted layers.
                        unit_cost:
                          type: number
                          format: float
                          description: Cost per unit for the layer.
                        extended_value:
                          type: number
                          format: float
                          description: Remaining value of the layer (`remaining_quantity` × `unit_cost`).
                        product_id:
                          type: integer
                          description: Product (RFQ) ID the layer belongs to.
                        sku:
                          type: string
                          nullable: true
                          description: Product internal SKU. Only present when the product relation is loaded.
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: Warehouse / location ID the layer is held at.
                        is_variance:
                          type: boolean
                          description: Whether the layer was created from an inventory variance/adjustment.
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/inventory/cost-layers/{costLayerId}':
    get:
      operationId: getCostLayer
      tags:
        - Inventory
      summary: Get cost layer by ID
      description: |
        Retrieve a single legacy FIFO/WAC cost layer (`rfq_stock_cost_layers`) by ID.
        Returns the same object shape as the list endpoint.

        Returns `404` when the layer does not exist or has been soft-deleted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: costLayerId
          required: true
          schema:
            type: integer
          description: The cost layer ID.
      responses:
        '200':
          description: The requested cost layer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A legacy FIFO/WAC cost layer (`rfq_stock_cost_layers`). Each layer represents a
                      quantity of a product received into a warehouse at a specific unit cost. These are
                      distinct from Luminous Core inventory-cost ledger rows (see `/core/inventory-costs`).
                    properties:
                      layer_id:
                        type: integer
                        description: Cost layer ID.
                      received_at:
                        type: string
                        nullable: true
                        description: 'When the layer was received (`YYYY-MM-DD HH:mm:ss`). Derived from the layer creation date.'
                        example: '2024-06-01 14:22:00'
                      original_quantity:
                        type: number
                        format: float
                        description: Original quantity received into the layer.
                      remaining_quantity:
                        type: number
                        format: float
                        description: Quantity still remaining on the layer. `0` for fully depleted layers.
                      unit_cost:
                        type: number
                        format: float
                        description: Cost per unit for the layer.
                      extended_value:
                        type: number
                        format: float
                        description: Remaining value of the layer (`remaining_quantity` × `unit_cost`).
                      product_id:
                        type: integer
                        description: Product (RFQ) ID the layer belongs to.
                      sku:
                        type: string
                        nullable: true
                        description: Product internal SKU. Only present when the product relation is loaded.
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Warehouse / location ID the layer is held at.
                      is_variance:
                        type: boolean
                        description: Whether the layer was created from an inventory variance/adjustment.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Cost layer not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /lots:
    post:
      operationId: createLot
      tags:
        - Lots
      summary: Create a lot
      description: |
        Creates a single lot (batch) for a lot-tracked product. Metadata only — no
        stock is placed. Add or change lot quantities with
        [`POST /inventory/adjustments`](/api-reference/inventory/post-inventoryadjustments).

        Identify the product with either `product_id` or `sku`; if both are sent,
        `product_id` wins. The resolved product must exist and be lot-tracked.

        When `lot_number` is omitted, a lot number is auto-generated from the
        production and expiry dates — so both `production_date` and `expiry_date`
        are required in that case. When a `lot_number` is supplied, the dates are
        optional. If both dates are present, `expiry_date` must be on or after
        `production_date`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                product_id:
                  type: integer
                  description: |
                    Luminous product (rfq) ID. Provide this or `sku`; `product_id`
                    takes precedence when both are given.
                sku:
                  type: string
                  description: |
                    Product SKU (internal or alternate). Resolved to an active,
                    lot-tracked product. Provide this or `product_id`.
                lot_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: |
                    Lot number, unique per product. When omitted, it is
                    auto-generated from `production_date` and `expiry_date` (both
                    then required).
                manufacturer_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Optional manufacturer code for the lot
                production_date:
                  type: string
                  format: date
                  nullable: true
                  description: |
                    Production date. Required when `lot_number` is omitted.
                expiry_date:
                  type: string
                  format: date
                  nullable: true
                  description: |
                    Expiry date. Required when `lot_number` is omitted. Must be on or
                    after `production_date`.
      responses:
        '201':
          description: Lot created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A product lot (batch) for a lot-tracked product. Holds metadata only —
                      lot quantities live in inventory stock and are changed through inventory
                      adjustments, not through the lot endpoints.
                    properties:
                      id:
                        type: integer
                        description: Unique lot identifier
                      createdAt:
                        type: string
                        format: date-time
                        description: When the lot was created
                      updatedAt:
                        type: string
                        format: date-time
                        description: When the lot was last updated
                      status:
                        type: integer
                        description: Lot status flag (1 = active)
                      rfqId:
                        type: integer
                        description: Luminous product (rfq) ID this lot belongs to
                      lotNumber:
                        type: string
                        nullable: true
                        description: |
                          Lot number, unique per product. Auto-generated from the production and
                          expiry dates when omitted on create.
                      manufacturerCode:
                        type: string
                        nullable: true
                        description: Optional manufacturer code for the lot
                      originalQuantity:
                        type: number
                        format: float
                        description: Quantity originally recorded against the lot
                      productionDate:
                        type: string
                        format: date-time
                        nullable: true
                        description: Production date of the lot
                      expiryDate:
                        type: string
                        format: date-time
                        nullable: true
                        description: Expiry date of the lot; always on or after the production date
                      deletedAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: |
                          `null` for a live lot; when the lot was soft-deleted (only returned
                          with `include_deleted=1` on `GET /products/{productId}/lots`)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error — e.g. no valid product resolved, product is not
            lot-tracked, duplicate lot number for the product, missing required
            dates, or `expiry_date` earlier than `production_date`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /lots/bulk-delete:
    post:
      operationId: bulkDeleteLots
      tags:
        - Lots
      summary: Bulk delete lots
      description: |
        Best-effort bulk soft-delete of lots. Each lot follows the same UI-parity
        behavior as `DELETE /lots/{lotId}`: its regular on-hand stock is auto-cleared
        (via an inventory adjustment posted by the authenticated user) and the lot is
        soft-deleted. A per-lot failure — an unknown ID, or a lot whose stock could
        not be cleared first (picklist-committed stock, no base unit of measure, or
        stock remaining after the auto-clear adjustment) — is captured in that lot's
        `results` row and does **not** abort the rest of the batch, so the call
        returns `200` even on a partial failure. Inspect `deleted`, `failed`, and
        `results` for per-lot outcomes.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - lot_ids
              properties:
                lot_ids:
                  type: array
                  description: |
                    Lot IDs to delete. 1–200 per call; duplicates are de-duplicated.
                  minItems: 1
                  maxItems: 200
                  items:
                    type: integer
                    minimum: 1
      responses:
        '200':
          description: |
            Batch processed. Always returned even when some lots failed — check the
            per-lot `results`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Deleted 2 of 3 lot(s).
                  deleted:
                    type: integer
                    description: Number of lots successfully deleted
                    example: 2
                  failed:
                    type: integer
                    description: Number of lots that could not be deleted
                    example: 1
                  results:
                    type: array
                    description: 'Per-lot outcome, one row per requested lot ID'
                    items:
                      type: object
                      properties:
                        lot_id:
                          type: integer
                          example: 1234
                        status:
                          type: string
                          enum:
                            - deleted
                            - failed
                          description: '`deleted` on success, `failed` otherwise'
                        message:
                          type: string
                          description: Outcome detail (e.g. the reason a lot failed)
                          example: Lot deleted.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error — e.g. `lot_ids` missing, empty, over 200 entries, or
            containing a non-integer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/lots/{lotId}':
    get:
      operationId: getLot
      tags:
        - Lots
      summary: Get a lot
      description: |
        Returns a single lot's full metadata, including fields the inventory stock
        view omits (`manufacturerCode`, `status`, `originalQuantity`).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: lotId
          required: true
          schema:
            type: integer
          description: Lot ID
      responses:
        '200':
          description: The lot
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A product lot (batch) for a lot-tracked product. Holds metadata only —
                      lot quantities live in inventory stock and are changed through inventory
                      adjustments, not through the lot endpoints.
                    properties:
                      id:
                        type: integer
                        description: Unique lot identifier
                      createdAt:
                        type: string
                        format: date-time
                        description: When the lot was created
                      updatedAt:
                        type: string
                        format: date-time
                        description: When the lot was last updated
                      status:
                        type: integer
                        description: Lot status flag (1 = active)
                      rfqId:
                        type: integer
                        description: Luminous product (rfq) ID this lot belongs to
                      lotNumber:
                        type: string
                        nullable: true
                        description: |
                          Lot number, unique per product. Auto-generated from the production and
                          expiry dates when omitted on create.
                      manufacturerCode:
                        type: string
                        nullable: true
                        description: Optional manufacturer code for the lot
                      originalQuantity:
                        type: number
                        format: float
                        description: Quantity originally recorded against the lot
                      productionDate:
                        type: string
                        format: date-time
                        nullable: true
                        description: Production date of the lot
                      expiryDate:
                        type: string
                        format: date-time
                        nullable: true
                        description: Expiry date of the lot; always on or after the production date
                      deletedAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: |
                          `null` for a live lot; when the lot was soft-deleted (only returned
                          with `include_deleted=1` on `GET /products/{productId}/lots`)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Lot not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    patch:
      operationId: updateLot
      tags:
        - Lots
      summary: Update a lot
      description: |
        Partially updates a lot's metadata. Only fields present in the body are
        changed; omitted fields are left untouched. Pass `null` to clear a nullable
        field. Metadata only — lot quantities are changed through inventory
        adjustments, not here.

        `lot_number` must stay unique within the lot's product. When a date is
        edited, the `expiry_date` >= `production_date` rule is checked against the
        lot's stored dates, so changing one date alone is still validated.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: lotId
          required: true
          schema:
            type: integer
          description: Lot ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                lot_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: 'Lot number, unique per product'
                manufacturer_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Manufacturer code for the lot
                production_date:
                  type: string
                  format: date
                  nullable: true
                  description: Production date
                expiry_date:
                  type: string
                  format: date
                  nullable: true
                  description: Expiry date; must be on or after the production date
      responses:
        '200':
          description: Updated lot
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A product lot (batch) for a lot-tracked product. Holds metadata only —
                      lot quantities live in inventory stock and are changed through inventory
                      adjustments, not through the lot endpoints.
                    properties:
                      id:
                        type: integer
                        description: Unique lot identifier
                      createdAt:
                        type: string
                        format: date-time
                        description: When the lot was created
                      updatedAt:
                        type: string
                        format: date-time
                        description: When the lot was last updated
                      status:
                        type: integer
                        description: Lot status flag (1 = active)
                      rfqId:
                        type: integer
                        description: Luminous product (rfq) ID this lot belongs to
                      lotNumber:
                        type: string
                        nullable: true
                        description: |
                          Lot number, unique per product. Auto-generated from the production and
                          expiry dates when omitted on create.
                      manufacturerCode:
                        type: string
                        nullable: true
                        description: Optional manufacturer code for the lot
                      originalQuantity:
                        type: number
                        format: float
                        description: Quantity originally recorded against the lot
                      productionDate:
                        type: string
                        format: date-time
                        nullable: true
                        description: Production date of the lot
                      expiryDate:
                        type: string
                        format: date-time
                        nullable: true
                        description: Expiry date of the lot; always on or after the production date
                      deletedAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: |
                          `null` for a live lot; when the lot was soft-deleted (only returned
                          with `include_deleted=1` on `GET /products/{productId}/lots`)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Lot not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error — e.g. duplicate lot number for the product or
            `expiry_date` earlier than `production_date`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteLot
      tags:
        - Lots
      summary: Delete a lot
      description: |
        Soft-deletes a lot, mirroring the UI delete: the lot's regular on-hand stock
        is automatically cleared to zero (via an inventory adjustment posted by the
        authenticated user) and then the lot is soft-deleted.

        The request is rejected (422) when the lot cannot be safely emptied first:

        - stock is committed to a picklist (which the auto-clear cannot write off),
        - the product has no base unit of measure (so a count-to-zero adjustment
          cannot be built), or
        - stock still remains after the auto-clear adjustment is posted.

        Clear the lot via an inventory adjustment and retry.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: lotId
          required: true
          schema:
            type: integer
          description: Lot ID
      responses:
        '200':
          description: Lot deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Lot deleted.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Lot not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Lot could not be deleted because its stock could not be cleared first —
            picklist-committed stock remains, the product has no base unit of measure,
            or stock remains after the auto-clear adjustment.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /transfer-orders:
    get:
      operationId: getTransferOrders
      tags:
        - Transfer Orders
      summary: Transfer orders
      description: |
        Get a paginated list of transfer orders.

        If the API user is assigned to specific warehouses (set per user in the app), only
        transfer orders whose destination is one of those warehouses are returned. Users with no
        warehouse assignment see every transfer order.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
          description: Number of items per page
        - in: query
          name: number
          schema:
            type: string
          description: Filter by transfer order number
        - in: query
          name: source_warehouse_ids
          schema:
            type: string
          description: Comma-separated list of source warehouse IDs
        - in: query
          name: destination_warehouse_ids
          schema:
            type: string
          description: Comma-separated list of destination warehouse IDs
        - in: query
          name: date
          schema:
            type: string
            format: date
          description: Filter by transfer order date
        - in: query
          name: arrival_date
          schema:
            type: string
            format: date
          description: Filter by arrival date
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the transfer order
                        number:
                          type: string
                          description: Transfer order number
                        date:
                          type: string
                          format: date
                          description: Date of the transfer order
                        arrival_date:
                          type: string
                          format: date
                          description: Expected arrival date
                        items_cost:
                          type: number
                          format: float
                          description: Total cost of items
                        shipping_cost:
                          type: number
                          format: float
                          description: Shipping cost
                        shipping_method:
                          type: string
                          description: Method of shipping
                        source_warehouse_id:
                          type: integer
                          description: ID of the source warehouse
                        destination_warehouse_id:
                          type: integer
                          description: ID of the destination warehouse
                        channel_id:
                          type: integer
                          nullable: true
                          description: ID of the fulfillment source channel
                        note:
                          type: string
                          nullable: true
                          description: Note on the transfer order
                        sales_order_id:
                          type: integer
                          nullable: true
                          description: ID of the sales order created when the transfer order was posted. `null` until posted.
                        purchase_order_id:
                          type: integer
                          nullable: true
                          description: ID of the purchase order created when the transfer order was posted. `null` until posted.
                        status:
                          type: string
                          description: Status of the transfer order (`DRAFT` or `POSTED`)
                        created_at:
                          type: string
                          format: date-time
                          description: Creation timestamp
                        updated_at:
                          type: string
                          format: date-time
                          description: Last update timestamp
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createTransferOrder
      tags:
        - Transfer Orders
      summary: Create a transfer order
      description: 'Create a new transfer order. Send `status: DRAFT` to create a draft you can edit with `PUT /transfer-orders/{id}` and post later with `POST /transfer-orders/{id}/post`, or `status: POSTED` to post it immediately. Creating with `status: POSTED` returns `403` when the API user is assigned to specific warehouses and the destination warehouse is not one of them.'
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - date
                - arrival_date
                - source_warehouse_id
                - destination_warehouse_id
                - shipping_cost
                - status
                - items
                - channel_id
              properties:
                number:
                  type: string
                  nullable: true
                  description: Transfer order number. Must be unique across transfer orders.
                date:
                  type: string
                  format: date
                  description: Date of the transfer order
                arrival_date:
                  type: string
                  format: date
                  description: Expected arrival date
                items_cost:
                  type: number
                  format: float
                  description: Total cost of items
                shipping_cost:
                  type: number
                  format: float
                  description: Shipping cost
                shipping_method:
                  type: string
                  nullable: true
                  description: 'Method of shipping. Optional — if omitted or empty, defaults to "Standard".'
                source_warehouse_id:
                  type: integer
                  description: ID of the source warehouse
                destination_warehouse_id:
                  type: integer
                  description: ID of the destination warehouse
                status:
                  type: string
                  enum:
                    - DRAFT
                    - POSTED
                  description: Status of the transfer order
                channel_id:
                  type: integer
                  description: 'ID of the fulfillment source channel. Required, as on the transfer order screen: a missing or `null` value returns `422` "Fulfillment source (channel_id) is required.", and an unknown ID returns `422` "Fulfillment source (channel_id) does not match an existing channel.". Posting uses it for the sales order the transfer order creates, so that sales order can generate fulfillment orders.'
                note:
                  type: string
                  nullable: true
                  description: Note on the transfer order
                auto_receive_order_on_arrival:
                  type: boolean
                  description: Automatically receive the transfer order when it arrives
                items:
                  type: array
                  items:
                    type: object
                    required:
                      - quantity
                      - ordered_uom_id
                      - product_id
                    properties:
                      quantity:
                        type: integer
                        description: Quantity of the item
                      ordered_uom_id:
                        type: integer
                        description: ID of the ordered unit of measure
                      product_id:
                        type: integer
                        description: ID of the product
                      lot_id:
                        type: integer
                        nullable: true
                        description: ID of an existing product lot to transfer. Provide either `lot_id` or `lot_number` (the lot must already exist; lots are not created on transfer). Required when the product has lot tracking enabled.
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number to transfer (resolved to an existing lot for the product). Use instead of `lot_id`. Required when the product has lot tracking enabled.
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
                extra_costs:
                  type: array
                  nullable: true
                  description: 'Extra costs (freight, duty, ...) for the transfer. When the transfer order is posted, each extra cost is copied onto its purchase order, prorated onto its receiving reports, and added to the landed cost of the received units. Separate from `shipping_cost`, which is unchanged. Line filters (`category_ids`, `tag_ids`, `internal_skus`, `supplier_skus`) are not supported and are rejected.'
                  items:
                    type: object
                    required:
                      - name
                      - unit_price
                    properties:
                      name:
                        type: string
                        maxLength: 255
                        description: Extra cost name
                      unit_price:
                        type: number
                        minimum: 0
                        description: Price per unit
                      quantity:
                        type: integer
                        minimum: 1
                        default: 1
                        nullable: true
                        description: Quantity. `line_total = quantity × unit_price`.
                      cost_allocation_type:
                        type: string
                        nullable: true
                        enum:
                          - UNIT_BASED_ALLOCATION
                          - VALUE_BASED_ALLOCATION
                          - WEIGHT_BASED_ALLOCATION
                          - VOLUME_BASED_ALLOCATION
                        description: Allocation method. Blank uses the tenant default.
                      cost_type:
                        type: string
                        nullable: true
                        enum:
                          - freight
                          - duty
                          - service
                          - other
                        description: Cost type. Blank is inferred from the name.
                      reference_number:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Carrier invoice / booking reference
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the transfer order
                      number:
                        type: string
                        description: Transfer order number
                      date:
                        type: string
                        format: date
                        description: Date of the transfer order
                      arrival_date:
                        type: string
                        format: date
                        description: Expected arrival date
                      items_cost:
                        type: number
                        format: float
                        description: Total cost of items
                      shipping_cost:
                        type: number
                        format: float
                        description: Shipping cost
                      shipping_method:
                        type: string
                        description: Method of shipping
                      source_warehouse_id:
                        type: integer
                        description: ID of the source warehouse
                      destination_warehouse_id:
                        type: integer
                        description: ID of the destination warehouse
                      channel_id:
                        type: integer
                        nullable: true
                        description: ID of the fulfillment source channel
                      note:
                        type: string
                        nullable: true
                        description: Note on the transfer order
                      sales_order_id:
                        type: integer
                        nullable: true
                        description: ID of the sales order created when the transfer order was posted. `null` until posted.
                      purchase_order_id:
                        type: integer
                        nullable: true
                        description: ID of the purchase order created when the transfer order was posted. `null` until posted.
                      status:
                        type: string
                        description: Status of the transfer order (`DRAFT` or `POSTED`)
                      created_at:
                        type: string
                        format: date-time
                        description: Creation timestamp
                      updated_at:
                        type: string
                        format: date-time
                        description: Last update timestamp
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the transfer order item
                            transfer_order_id:
                              type: integer
                              description: ID of the associated transfer order
                            product_id:
                              type: integer
                              description: ID of the product
                            sku:
                              type: string
                              description: SKU of the product
                            product_name:
                              type: string
                              description: Name of the product
                            description:
                              type: string
                              description: Description of the item
                            quantity:
                              type: number
                              description: Quantity of the item
                            ordered_qty:
                              type: number
                              description: Ordered quantity of the item
                            base_uom_id:
                              type: integer
                              description: ID of the base unit of measure
                            ordered_uom_id:
                              type: integer
                              description: ID of the ordered unit of measure
                            unit_cost:
                              type: number
                              description: Unit cost of the item
                            line_item_cost:
                              type: number
                              description: Total cost of the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                        description: List of items in the transfer order
                      extra_costs:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the extra cost
                            name:
                              type: string
                              description: 'Extra cost name (e.g. "Freight", "Customs duty")'
                            cost_type:
                              type: string
                              nullable: true
                              enum:
                                - freight
                                - duty
                                - service
                                - other
                              description: Cost type. Inferred from the name when not supplied on create.
                            reference_number:
                              type: string
                              nullable: true
                              description: Carrier invoice / booking reference
                            quantity:
                              type: integer
                              description: Quantity
                            unit_price:
                              type: number
                              description: Price per unit
                            line_total:
                              type: number
                              description: '`quantity` × `unit_price`'
                            cost_allocation_type:
                              type: string
                              nullable: true
                              enum:
                                - UNIT_BASED_ALLOCATION
                                - VALUE_BASED_ALLOCATION
                                - WEIGHT_BASED_ALLOCATION
                                - VOLUME_BASED_ALLOCATION
                              description: How the cost is allocated across the received units
                        description: 'Extra costs (freight, duty, ...) on the transfer order'
                      custom_fields:
                        type: object
                        description: 'Custom field values on the transfer order, keyed by label (`{}` when none are set). A token restricted from PII gets `{}`. Read or change them with `GET`/`PUT /transfer-orders/{recordId}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: array
                              items:
                                oneOf:
                                  - type: string
                                  - type: number
                        example:
                          Carrier: FedEx Freight
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: 'Returned when the API user is assigned to specific warehouses and the transfer order''s destination warehouse is not one of them: `You are not assigned to the destination warehouse of this transfer order.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error. `error` holds the first validation message.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  '/transfer-orders/{id}':
    get:
      operationId: getTransferOrder
      tags:
        - Transfer Orders
      summary: Single transfer order
      description: Get details of a specific transfer order by ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the transfer order to retrieve
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the transfer order
                      number:
                        type: string
                        description: Transfer order number
                      date:
                        type: string
                        format: date
                        description: Date of the transfer order
                      arrival_date:
                        type: string
                        format: date
                        description: Expected arrival date
                      items_cost:
                        type: number
                        format: float
                        description: Total cost of items
                      shipping_cost:
                        type: number
                        format: float
                        description: Shipping cost
                      shipping_method:
                        type: string
                        description: Method of shipping
                      source_warehouse_id:
                        type: integer
                        description: ID of the source warehouse
                      destination_warehouse_id:
                        type: integer
                        description: ID of the destination warehouse
                      channel_id:
                        type: integer
                        nullable: true
                        description: ID of the fulfillment source channel
                      note:
                        type: string
                        nullable: true
                        description: Note on the transfer order
                      sales_order_id:
                        type: integer
                        nullable: true
                        description: ID of the sales order created when the transfer order was posted. `null` until posted.
                      purchase_order_id:
                        type: integer
                        nullable: true
                        description: ID of the purchase order created when the transfer order was posted. `null` until posted.
                      status:
                        type: string
                        description: Status of the transfer order (`DRAFT` or `POSTED`)
                      created_at:
                        type: string
                        format: date-time
                        description: Creation timestamp
                      updated_at:
                        type: string
                        format: date-time
                        description: Last update timestamp
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the transfer order item
                            transfer_order_id:
                              type: integer
                              description: ID of the associated transfer order
                            product_id:
                              type: integer
                              description: ID of the product
                            sku:
                              type: string
                              description: SKU of the product
                            product_name:
                              type: string
                              description: Name of the product
                            description:
                              type: string
                              description: Description of the item
                            quantity:
                              type: number
                              description: Quantity of the item
                            ordered_qty:
                              type: number
                              description: Ordered quantity of the item
                            base_uom_id:
                              type: integer
                              description: ID of the base unit of measure
                            ordered_uom_id:
                              type: integer
                              description: ID of the ordered unit of measure
                            unit_cost:
                              type: number
                              description: Unit cost of the item
                            line_item_cost:
                              type: number
                              description: Total cost of the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                        description: List of items in the transfer order
                      extra_costs:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the extra cost
                            name:
                              type: string
                              description: 'Extra cost name (e.g. "Freight", "Customs duty")'
                            cost_type:
                              type: string
                              nullable: true
                              enum:
                                - freight
                                - duty
                                - service
                                - other
                              description: Cost type. Inferred from the name when not supplied on create.
                            reference_number:
                              type: string
                              nullable: true
                              description: Carrier invoice / booking reference
                            quantity:
                              type: integer
                              description: Quantity
                            unit_price:
                              type: number
                              description: Price per unit
                            line_total:
                              type: number
                              description: '`quantity` × `unit_price`'
                            cost_allocation_type:
                              type: string
                              nullable: true
                              enum:
                                - UNIT_BASED_ALLOCATION
                                - VALUE_BASED_ALLOCATION
                                - WEIGHT_BASED_ALLOCATION
                                - VOLUME_BASED_ALLOCATION
                              description: How the cost is allocated across the received units
                        description: 'Extra costs (freight, duty, ...) on the transfer order'
                      custom_fields:
                        type: object
                        description: 'Custom field values on the transfer order, keyed by label (`{}` when none are set). A token restricted from PII gets `{}`. Read or change them with `GET`/`PUT /transfer-orders/{recordId}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: array
                              items:
                                oneOf:
                                  - type: string
                                  - type: number
                        example:
                          Carrier: FedEx Freight
        '404':
          description: Transfer order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateTransferOrder
      tags:
        - Transfer Orders
      summary: Update a draft transfer order
      description: 'Replace a draft transfer order. The body is the same as `POST /transfer-orders`; items and extra costs are replaced with the ones sent. Only drafts can be updated, and `status` must be `DRAFT` (use `POST /transfer-orders/{id}/post` to post). The order can keep its own `number`. Shipment type, supplier, auto-ship settings, and auto-receive on arrival are not changed by this endpoint. `channel_id` (fulfillment source) is required here too; send the stored value to keep it.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the transfer order to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  required:
                    - date
                    - arrival_date
                    - source_warehouse_id
                    - destination_warehouse_id
                    - shipping_cost
                    - status
                    - items
                    - channel_id
                  properties:
                    number:
                      type: string
                      nullable: true
                      description: Transfer order number. Must be unique across transfer orders.
                    date:
                      type: string
                      format: date
                      description: Date of the transfer order
                    arrival_date:
                      type: string
                      format: date
                      description: Expected arrival date
                    items_cost:
                      type: number
                      format: float
                      description: Total cost of items
                    shipping_cost:
                      type: number
                      format: float
                      description: Shipping cost
                    shipping_method:
                      type: string
                      nullable: true
                      description: 'Method of shipping. Optional — if omitted or empty, defaults to "Standard".'
                    source_warehouse_id:
                      type: integer
                      description: ID of the source warehouse
                    destination_warehouse_id:
                      type: integer
                      description: ID of the destination warehouse
                    status:
                      type: string
                      enum:
                        - DRAFT
                        - POSTED
                      description: Status of the transfer order
                    channel_id:
                      type: integer
                      description: 'ID of the fulfillment source channel. Required, as on the transfer order screen: a missing or `null` value returns `422` "Fulfillment source (channel_id) is required.", and an unknown ID returns `422` "Fulfillment source (channel_id) does not match an existing channel.". Posting uses it for the sales order the transfer order creates, so that sales order can generate fulfillment orders.'
                    note:
                      type: string
                      nullable: true
                      description: Note on the transfer order
                    auto_receive_order_on_arrival:
                      type: boolean
                      description: Automatically receive the transfer order when it arrives
                    items:
                      type: array
                      items:
                        type: object
                        required:
                          - quantity
                          - ordered_uom_id
                          - product_id
                        properties:
                          quantity:
                            type: integer
                            description: Quantity of the item
                          ordered_uom_id:
                            type: integer
                            description: ID of the ordered unit of measure
                          product_id:
                            type: integer
                            description: ID of the product
                          lot_id:
                            type: integer
                            nullable: true
                            description: ID of an existing product lot to transfer. Provide either `lot_id` or `lot_number` (the lot must already exist; lots are not created on transfer). Required when the product has lot tracking enabled.
                          lot_number:
                            type: string
                            nullable: true
                            description: Lot number to transfer (resolved to an existing lot for the product). Use instead of `lot_id`. Required when the product has lot tracking enabled.
                          lot_name:
                            type: string
                            nullable: true
                            description: Alias for `lot_number`.
                    extra_costs:
                      type: array
                      nullable: true
                      description: 'Extra costs (freight, duty, ...) for the transfer. When the transfer order is posted, each extra cost is copied onto its purchase order, prorated onto its receiving reports, and added to the landed cost of the received units. Separate from `shipping_cost`, which is unchanged. Line filters (`category_ids`, `tag_ids`, `internal_skus`, `supplier_skus`) are not supported and are rejected.'
                      items:
                        type: object
                        required:
                          - name
                          - unit_price
                        properties:
                          name:
                            type: string
                            maxLength: 255
                            description: Extra cost name
                          unit_price:
                            type: number
                            minimum: 0
                            description: Price per unit
                          quantity:
                            type: integer
                            minimum: 1
                            default: 1
                            nullable: true
                            description: Quantity. `line_total = quantity × unit_price`.
                          cost_allocation_type:
                            type: string
                            nullable: true
                            enum:
                              - UNIT_BASED_ALLOCATION
                              - VALUE_BASED_ALLOCATION
                              - WEIGHT_BASED_ALLOCATION
                              - VOLUME_BASED_ALLOCATION
                            description: Allocation method. Blank uses the tenant default.
                          cost_type:
                            type: string
                            nullable: true
                            enum:
                              - freight
                              - duty
                              - service
                              - other
                            description: Cost type. Blank is inferred from the name.
                          reference_number:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: Carrier invoice / booking reference
                - type: object
                  properties:
                    status:
                      type: string
                      enum:
                        - DRAFT
                      description: Must be `DRAFT`.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the transfer order
                      number:
                        type: string
                        description: Transfer order number
                      date:
                        type: string
                        format: date
                        description: Date of the transfer order
                      arrival_date:
                        type: string
                        format: date
                        description: Expected arrival date
                      items_cost:
                        type: number
                        format: float
                        description: Total cost of items
                      shipping_cost:
                        type: number
                        format: float
                        description: Shipping cost
                      shipping_method:
                        type: string
                        description: Method of shipping
                      source_warehouse_id:
                        type: integer
                        description: ID of the source warehouse
                      destination_warehouse_id:
                        type: integer
                        description: ID of the destination warehouse
                      channel_id:
                        type: integer
                        nullable: true
                        description: ID of the fulfillment source channel
                      note:
                        type: string
                        nullable: true
                        description: Note on the transfer order
                      sales_order_id:
                        type: integer
                        nullable: true
                        description: ID of the sales order created when the transfer order was posted. `null` until posted.
                      purchase_order_id:
                        type: integer
                        nullable: true
                        description: ID of the purchase order created when the transfer order was posted. `null` until posted.
                      status:
                        type: string
                        description: Status of the transfer order (`DRAFT` or `POSTED`)
                      created_at:
                        type: string
                        format: date-time
                        description: Creation timestamp
                      updated_at:
                        type: string
                        format: date-time
                        description: Last update timestamp
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the transfer order item
                            transfer_order_id:
                              type: integer
                              description: ID of the associated transfer order
                            product_id:
                              type: integer
                              description: ID of the product
                            sku:
                              type: string
                              description: SKU of the product
                            product_name:
                              type: string
                              description: Name of the product
                            description:
                              type: string
                              description: Description of the item
                            quantity:
                              type: number
                              description: Quantity of the item
                            ordered_qty:
                              type: number
                              description: Ordered quantity of the item
                            base_uom_id:
                              type: integer
                              description: ID of the base unit of measure
                            ordered_uom_id:
                              type: integer
                              description: ID of the ordered unit of measure
                            unit_cost:
                              type: number
                              description: Unit cost of the item
                            line_item_cost:
                              type: number
                              description: Total cost of the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                        description: List of items in the transfer order
                      extra_costs:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the extra cost
                            name:
                              type: string
                              description: 'Extra cost name (e.g. "Freight", "Customs duty")'
                            cost_type:
                              type: string
                              nullable: true
                              enum:
                                - freight
                                - duty
                                - service
                                - other
                              description: Cost type. Inferred from the name when not supplied on create.
                            reference_number:
                              type: string
                              nullable: true
                              description: Carrier invoice / booking reference
                            quantity:
                              type: integer
                              description: Quantity
                            unit_price:
                              type: number
                              description: Price per unit
                            line_total:
                              type: number
                              description: '`quantity` × `unit_price`'
                            cost_allocation_type:
                              type: string
                              nullable: true
                              enum:
                                - UNIT_BASED_ALLOCATION
                                - VALUE_BASED_ALLOCATION
                                - WEIGHT_BASED_ALLOCATION
                                - VOLUME_BASED_ALLOCATION
                              description: How the cost is allocated across the received units
                        description: 'Extra costs (freight, duty, ...) on the transfer order'
                      custom_fields:
                        type: object
                        description: 'Custom field values on the transfer order, keyed by label (`{}` when none are set). A token restricted from PII gets `{}`. Read or change them with `GET`/`PUT /transfer-orders/{recordId}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: array
                              items:
                                oneOf:
                                  - type: string
                                  - type: number
                        example:
                          Carrier: FedEx Freight
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Transfer order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Transfer order not found.
        '422':
          description: 'The transfer order is not a draft (`Only draft transfer orders can be updated.`), `status` is not `DRAFT`, or another validation error. `error` holds the message.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  '/transfer-orders/{id}/post':
    post:
      operationId: postTransferOrder
      tags:
        - Transfer Orders
      summary: Post a draft transfer order
      description: |
        Post a draft transfer order. Posting creates the linked sales order and purchase order
        (returned as `sales_order_id` and `purchase_order_id`).

        If the API user is assigned to specific warehouses (set per user in the app), the transfer
        order's destination warehouse must be one of them (`403` otherwise); the source warehouse can be
        any.

        Set `push_to_wms` to also create the inbound shipment at the destination warehouse's WMS in the
        same call. The outcome is returned in `data.wms_push`:

        - **Pushed** (or the linked purchase order was already pushed): `success: true`, plus the same
          fields `POST /transfer-orders/{id}/push-inbound-shipment` returns (`purchase_order_id`,
          `sync_status`, `last_synced_at`, `external_shipment_id`, `external_system_url`,
          `inbound_shipment`), so you can link the WMS shipment without pushing again.
        - **Queued**: when the destination's warehouse group already auto-pushes this purchase order
          (its "auto-push transfer orders" setting, or "auto-push purchase orders" with the order's status
          allowlisted), the post does not push a second time. You get `success: true` and `queued: true`;
          the push runs in the background.
        - **Failed**: a failed WMS push does not undo the post. The response is still `200`, with
          `success: false` and the error in `message`. Retry the push with
          `POST /transfer-orders/{id}/push-inbound-shipment`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the transfer order to post
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                push_to_wms:
                  type: boolean
                  default: false
                  description: Also create the WMS inbound shipment for the posted transfer order.
                tracking_number:
                  type: string
                  nullable: true
                  description: Tracking number passed to the WMS inbound shipment when `push_to_wms` is true.
      responses:
        '200':
          description: Transfer order posted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    allOf:
                      - type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the transfer order
                          number:
                            type: string
                            description: Transfer order number
                          date:
                            type: string
                            format: date
                            description: Date of the transfer order
                          arrival_date:
                            type: string
                            format: date
                            description: Expected arrival date
                          items_cost:
                            type: number
                            format: float
                            description: Total cost of items
                          shipping_cost:
                            type: number
                            format: float
                            description: Shipping cost
                          shipping_method:
                            type: string
                            description: Method of shipping
                          source_warehouse_id:
                            type: integer
                            description: ID of the source warehouse
                          destination_warehouse_id:
                            type: integer
                            description: ID of the destination warehouse
                          channel_id:
                            type: integer
                            nullable: true
                            description: ID of the fulfillment source channel
                          note:
                            type: string
                            nullable: true
                            description: Note on the transfer order
                          sales_order_id:
                            type: integer
                            nullable: true
                            description: ID of the sales order created when the transfer order was posted. `null` until posted.
                          purchase_order_id:
                            type: integer
                            nullable: true
                            description: ID of the purchase order created when the transfer order was posted. `null` until posted.
                          status:
                            type: string
                            description: Status of the transfer order (`DRAFT` or `POSTED`)
                          created_at:
                            type: string
                            format: date-time
                            description: Creation timestamp
                          updated_at:
                            type: string
                            format: date-time
                            description: Last update timestamp
                          items:
                            type: array
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the transfer order item
                                transfer_order_id:
                                  type: integer
                                  description: ID of the associated transfer order
                                product_id:
                                  type: integer
                                  description: ID of the product
                                sku:
                                  type: string
                                  description: SKU of the product
                                product_name:
                                  type: string
                                  description: Name of the product
                                description:
                                  type: string
                                  description: Description of the item
                                quantity:
                                  type: number
                                  description: Quantity of the item
                                ordered_qty:
                                  type: number
                                  description: Ordered quantity of the item
                                base_uom_id:
                                  type: integer
                                  description: ID of the base unit of measure
                                ordered_uom_id:
                                  type: integer
                                  description: ID of the ordered unit of measure
                                unit_cost:
                                  type: number
                                  description: Unit cost of the item
                                line_item_cost:
                                  type: number
                                  description: Total cost of the line item
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Creation timestamp
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Last update timestamp
                            description: List of items in the transfer order
                          extra_costs:
                            type: array
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the extra cost
                                name:
                                  type: string
                                  description: 'Extra cost name (e.g. "Freight", "Customs duty")'
                                cost_type:
                                  type: string
                                  nullable: true
                                  enum:
                                    - freight
                                    - duty
                                    - service
                                    - other
                                  description: Cost type. Inferred from the name when not supplied on create.
                                reference_number:
                                  type: string
                                  nullable: true
                                  description: Carrier invoice / booking reference
                                quantity:
                                  type: integer
                                  description: Quantity
                                unit_price:
                                  type: number
                                  description: Price per unit
                                line_total:
                                  type: number
                                  description: '`quantity` × `unit_price`'
                                cost_allocation_type:
                                  type: string
                                  nullable: true
                                  enum:
                                    - UNIT_BASED_ALLOCATION
                                    - VALUE_BASED_ALLOCATION
                                    - WEIGHT_BASED_ALLOCATION
                                    - VOLUME_BASED_ALLOCATION
                                  description: How the cost is allocated across the received units
                            description: 'Extra costs (freight, duty, ...) on the transfer order'
                          custom_fields:
                            type: object
                            description: 'Custom field values on the transfer order, keyed by label (`{}` when none are set). A token restricted from PII gets `{}`. Read or change them with `GET`/`PUT /transfer-orders/{recordId}/custom-fields`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                            additionalProperties:
                              oneOf:
                                - type: string
                                - type: number
                                - type: array
                                  items:
                                    oneOf:
                                      - type: string
                                      - type: number
                            example:
                              Carrier: FedEx Freight
                      - type: object
                        properties:
                          wms_push:
                            type: object
                            description: Result of the WMS push. Only present when `push_to_wms` is true.
                            properties:
                              success:
                                type: boolean
                                description: 'Whether the push was made, was already done, or was queued'
                              queued:
                                type: boolean
                                description: |
                                  `true` when the warehouse group's auto-push setting queued the push instead.
                                  Only present in that case.
                              message:
                                type: string
                                description: 'Outcome message, or the WMS error when `success` is `false`'
                                example: WMS shipment created.
                              purchase_order_id:
                                type: integer
                                description: Linked purchase order that was pushed. Present when the push was made or already done.
                              sync_status:
                                type: string
                                description: Purchase order's WMS sync status. Present when the push was made or already done.
                              last_synced_at:
                                type: string
                                format: date-time
                                nullable: true
                              external_shipment_id:
                                type: string
                                nullable: true
                                description: The WMS's inbound shipment id
                              external_system_url:
                                type: string
                                nullable: true
                                description: Link to the inbound shipment in the WMS
                              inbound_shipment:
                                type: object
                                nullable: true
                                description: 'The local inbound shipment the push created or updated, when one exists.'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: 'Returned when the API user is assigned to specific warehouses and the transfer order''s destination warehouse is not one of them: `You are not assigned to the destination warehouse of this transfer order.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Transfer order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Transfer order not found.
        '422':
          description: 'The transfer order is already posted or is not a draft, or posting failed. `error` holds the message.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  '/transfer-orders/{id}/push-inbound-shipment':
    post:
      operationId: pushTransferOrderInboundShipment
      tags:
        - Transfer Orders
      summary: Push transfer order as inbound shipment to WMS
      description: |
        Push a posted transfer order to the WMS as an inbound shipment. This pushes the purchase order that
        posting the transfer order created, the same way as `POST /purchase-orders/{purchaseOrderId}/push-inbound-shipment`
        (including sending an EDI 943 instead when the warehouse group is externally managed by an EDI account).

        Returns `409` when the linked purchase order's `sync_status` is already `synced`, because a second push creates a
        second WMS shipment. Send `force: true` to push again.

        Requirements:
        - The transfer order is `POSTED`.
        - The linked purchase order's warehouse is externally managed.
        - The line items have OMS product mappings for that warehouse's integration account.

        The request body is optional.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the transfer order to push
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                force:
                  type: boolean
                  default: false
                  description: 'When true, push even if the linked purchase order is already synced (may duplicate WMS inbounds).'
      responses:
        '200':
          description: Push succeeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      transfer_order_id:
                        type: integer
                      message:
                        type: string
                      purchase_order_id:
                        type: integer
                        description: Linked purchase order that was pushed.
                      sync_status:
                        type: string
                      last_synced_at:
                        type: string
                        format: date-time
                        nullable: true
                      external_shipment_id:
                        type: string
                        nullable: true
                      external_system_url:
                        type: string
                        nullable: true
                      inbound_shipment:
                        type: object
                        nullable: true
                        description: 'The local inbound shipment the push created or updated, when one exists.'
        '400':
          description: The warehouse is missing or not externally managed
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Transfer order (or its linked purchase order) not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '409':
          description: Already pushed as an inbound shipment (use `force=true` to push again)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '422':
          description: '`force` is not a boolean, the transfer order is not posted (`error`), or line items have no OMS product mapping. For unmapped SKUs, `errors` contains `unmapped_skus`, `unmapped_rfq_ids`, `app_integration_account_id`, and `integration_label`.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/transfer-orders/{recordId}/custom-fields':
    get:
      operationId: getTransferOrderCustomFields
      tags:
        - Transfer Orders
      summary: Get transfer order custom fields
      description: 'List the custom field values on one transfer order, keyed by label. Every custom field defined for transfer orders is listed, with `null` for fields that have no value on this transfer order. A token restricted from PII gets `{}`. Equivalent to `GET /{recordType}/{recordId}/custom-fields` with `recordType` `transfer-orders`.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: recordId
          required: true
          schema:
            type: integer
          description: ID of the transfer order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  nullable: true
                  oneOf:
                    - type: string
                    - type: number
                    - type: array
                      description: Selected values for a `multi_dropdown` custom field
                      items:
                        oneOf:
                          - type: string
                          - type: number
                example:
                  Carrier: FedEx Freight
                  Delivery Terms: null
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Transfer order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateTransferOrderCustomFields
      tags:
        - Transfer Orders
      summary: Update transfer order custom fields
      description: |
        Set custom field values on one transfer order, whatever its status. Send a
        `{label: value}` object; the update is partial and validated against the custom
        fields defined for transfer orders:
        - Only the labels sent are changed; other fields keep their values.
        - Labels are matched case-insensitively. A label that is not defined for transfer
          orders is rejected with a `422`; it is never created automatically. Define fields
          in Manage > Custom Fields first.
        - Sending `null`, `""` or `[]` for a field clears it. Clearing a required field is
          rejected with a `422`.
        - Each value is checked against its field's type. If any entry is invalid, nothing
          is saved and the `422` lists every rejected entry under `custom_fields.{label}`.
        - An empty body is rejected with a `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: recordId
          required: true
          schema:
            type: integer
          description: ID of the transfer order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties:
                nullable: true
                oneOf:
                  - type: string
                  - type: number
                  - type: array
                    description: Selected values for a `multi_dropdown` custom field
                    items:
                      oneOf:
                        - type: string
                        - type: number
              example:
                Carrier: FedEx Freight
      responses:
        '200':
          description: Custom fields updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Custom fields updated successfully
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Transfer order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (unknown label, invalid value, cleared required field, or empty body). Nothing is saved.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /transfer-routes:
    get:
      operationId: getTransferRoutes
      tags:
        - Transfer Orders
      summary: List transfer routes
      description: |
        A **transfer route** is the per warehouse-pair default for transfers from one warehouse to
        another: each side is either `worked` (people handle it) or `automated` (it happens on its own).
        The source side can also be `three_pl` ("Shipped by 3PL"): the transfer ships on the date the
        source warehouse's 3PL reports it shipped.
        A route pre-fills **new** transfer orders between its two warehouses; it never changes existing
        transfers, and a pair with no route keeps the normal defaults. Routes are the same records as
        **Settings › Transfer Orders** in the app.

        Returns all routes, ordered by source then destination. Pass both filters to get the one route
        for a pair (or an empty list). Not paginated.
      security:
        - BearerAuth: []
      parameters:
        - name: source_warehouse_id
          in: query
          required: false
          description: 'Only routes from this warehouse. `source_warehouse_id[eq]=22` also works.'
          schema:
            type: integer
        - name: destination_warehouse_id
          in: query
          required: false
          description: 'Only routes to this warehouse. `destination_warehouse_id[eq]=2` also works.'
          schema:
            type: integer
      responses:
        '200':
          description: Transfer routes
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 1
                        source_warehouse:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 22
                            name:
                              type: string
                              nullable: true
                              example: LA Warehouse
                        destination_warehouse:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 2
                            name:
                              type: string
                              nullable: true
                              example: Milwaukee Warehouse
                        source_mode:
                          type: string
                          enum:
                            - worked
                            - automated
                            - three_pl
                          description: |
                            `worked`: an FO is generated and picked/packed here or pushed to the 3PL/WMS.
                            `automated`: the transfer's sales order is marked shipped automatically on the order date.
                            `three_pl` ("Shipped by 3PL", source side only): the transfer's sales order is marked shipped
                            on the date the source warehouse's 3PL first reports its copy of the order (same order number)
                            as shipped, read through Trackstar. No auto-ship date is set up front, so
                            `transfer_order_defaults.auto_mark_so_as_shipped` and `auto_ship_on_order_date` are `false`.
                        destination_mode:
                          type: string
                          enum:
                            - worked
                            - automated
                          description: |
                            `worked`: the transfer PO is received by receiving report, the mobile app or WMS inbound receipts.
                            `automated`: the transfer is received automatically on the arrival date.
                        channel:
                          type: object
                          nullable: true
                          description: 'Optional fulfillment channel for the source side, or `null`'
                          properties:
                            id:
                              type: integer
                            label:
                              type: string
                              nullable: true
                        transfer_order_defaults:
                          type: object
                          readOnly: true
                          description: |
                            What a new transfer order between this pair starts with (the transfer-order fields the route
                            pre-fills). If the channel pushes orders to a 3PL, `auto_mark_so_as_shipped` is `false` even
                            for an automated source, because the 3PL ships those transfers.
                          properties:
                            auto_mark_so_as_shipped:
                              type: boolean
                            auto_ship_on_order_date:
                              type: boolean
                            auto_receive_order_on_arrival:
                              type: boolean
                            channel_id:
                              type: integer
                              nullable: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: A filter is not an integer (`<field> must be an integer.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: upsertTransferRoute
      tags:
        - Transfer Orders
      summary: Create or replace a transfer route
      description: |
        Create or replace the route for a warehouse pair, keyed by `source_warehouse_id` →
        `destination_warehouse_id`. Idempotent: applying the same body twice changes nothing, so this is
        the call to use for configuration. `PATCH /transfer-routes` (on the collection) behaves the same.

        Returns `201` when the route was created and `200` when an existing one was replaced. Omitting
        `channel_id` clears the channel.

        Refused with `422` when the source and destination are the same warehouse, or when an
        `automated` or `three_pl` source is combined with a channel that pushes orders to a 3PL (the 3PL
        ships those transfers, so it would never auto-ship), or when a `three_pl` source warehouse is not
        in an externally managed warehouse group connected through Trackstar.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - source_warehouse_id
                - destination_warehouse_id
                - source_mode
                - destination_mode
              properties:
                source_warehouse_id:
                  type: integer
                  description: Active warehouse (location) the transfer ships from
                  example: 22
                destination_warehouse_id:
                  type: integer
                  description: Active warehouse (location) the transfer ships to; must differ from the source
                  example: 2
                source_mode:
                  type: string
                  enum:
                    - worked
                    - automated
                    - three_pl
                  example: automated
                  description: |
                    `three_pl` ("Shipped by 3PL") ships the transfer on the date the source warehouse's 3PL reports
                    it shipped. It is accepted only on the source side, and the source warehouse must be in an
                    externally managed warehouse group connected through Trackstar.
                destination_mode:
                  type: string
                  enum:
                    - worked
                    - automated
                  example: worked
                channel_id:
                  type: integer
                  nullable: true
                  description: Existing channel used to fulfill the source side. Omit or send `null` to clear it.
                  example: null
      responses:
        '200':
          description: Existing route replaced
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 1
                      source_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 22
                          name:
                            type: string
                            nullable: true
                            example: LA Warehouse
                      destination_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 2
                          name:
                            type: string
                            nullable: true
                            example: Milwaukee Warehouse
                      source_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                          - three_pl
                        description: |
                          `worked`: an FO is generated and picked/packed here or pushed to the 3PL/WMS.
                          `automated`: the transfer's sales order is marked shipped automatically on the order date.
                          `three_pl` ("Shipped by 3PL", source side only): the transfer's sales order is marked shipped
                          on the date the source warehouse's 3PL first reports its copy of the order (same order number)
                          as shipped, read through Trackstar. No auto-ship date is set up front, so
                          `transfer_order_defaults.auto_mark_so_as_shipped` and `auto_ship_on_order_date` are `false`.
                      destination_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                        description: |
                          `worked`: the transfer PO is received by receiving report, the mobile app or WMS inbound receipts.
                          `automated`: the transfer is received automatically on the arrival date.
                      channel:
                        type: object
                        nullable: true
                        description: 'Optional fulfillment channel for the source side, or `null`'
                        properties:
                          id:
                            type: integer
                          label:
                            type: string
                            nullable: true
                      transfer_order_defaults:
                        type: object
                        readOnly: true
                        description: |
                          What a new transfer order between this pair starts with (the transfer-order fields the route
                          pre-fills). If the channel pushes orders to a 3PL, `auto_mark_so_as_shipped` is `false` even
                          for an automated source, because the 3PL ships those transfers.
                        properties:
                          auto_mark_so_as_shipped:
                            type: boolean
                          auto_ship_on_order_date:
                            type: boolean
                          auto_receive_order_on_arrival:
                            type: boolean
                          channel_id:
                            type: integer
                            nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '201':
          description: Route created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 1
                      source_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 22
                          name:
                            type: string
                            nullable: true
                            example: LA Warehouse
                      destination_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 2
                          name:
                            type: string
                            nullable: true
                            example: Milwaukee Warehouse
                      source_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                          - three_pl
                        description: |
                          `worked`: an FO is generated and picked/packed here or pushed to the 3PL/WMS.
                          `automated`: the transfer's sales order is marked shipped automatically on the order date.
                          `three_pl` ("Shipped by 3PL", source side only): the transfer's sales order is marked shipped
                          on the date the source warehouse's 3PL first reports its copy of the order (same order number)
                          as shipped, read through Trackstar. No auto-ship date is set up front, so
                          `transfer_order_defaults.auto_mark_so_as_shipped` and `auto_ship_on_order_date` are `false`.
                      destination_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                        description: |
                          `worked`: the transfer PO is received by receiving report, the mobile app or WMS inbound receipts.
                          `automated`: the transfer is received automatically on the arrival date.
                      channel:
                        type: object
                        nullable: true
                        description: 'Optional fulfillment channel for the source side, or `null`'
                        properties:
                          id:
                            type: integer
                          label:
                            type: string
                            nullable: true
                      transfer_order_defaults:
                        type: object
                        readOnly: true
                        description: |
                          What a new transfer order between this pair starts with (the transfer-order fields the route
                          pre-fills). If the channel pushes orders to a 3PL, `auto_mark_so_as_shipped` is `false` even
                          for an automated source, because the 3PL ships those transfers.
                        properties:
                          auto_mark_so_as_shipped:
                            type: boolean
                          auto_ship_on_order_date:
                            type: boolean
                          auto_receive_order_on_arrival:
                            type: boolean
                          channel_id:
                            type: integer
                            nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation failed: missing/invalid field, inactive or unknown warehouse, same source and
            destination ("The source and destination warehouses must be different."), or an automated
            source on a 3PL-pushing channel ("This channel pushes orders to a fulfillment partner, which
            ships the transfer itself. Set the source to worked."), or a `three_pl` source whose warehouse
            is not connected through Trackstar ("Shipped by 3PL needs the source warehouse in an
            externally managed warehouse group connected through Trackstar.")
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    patch:
      operationId: upsertTransferRoutePatch
      tags:
        - Transfer Orders
      summary: Create or replace a transfer route (PATCH alias)
      description: |
        Same as `PUT /transfer-routes`: creates or replaces the route for the warehouse pair in the body
        (`201` created, `200` replaced). To change only some fields of an existing route, use
        `PATCH /transfer-routes/{transferRouteId}`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - source_warehouse_id
                - destination_warehouse_id
                - source_mode
                - destination_mode
              properties:
                source_warehouse_id:
                  type: integer
                  description: Active warehouse (location) the transfer ships from
                  example: 22
                destination_warehouse_id:
                  type: integer
                  description: Active warehouse (location) the transfer ships to; must differ from the source
                  example: 2
                source_mode:
                  type: string
                  enum:
                    - worked
                    - automated
                    - three_pl
                  example: automated
                  description: |
                    `three_pl` ("Shipped by 3PL") ships the transfer on the date the source warehouse's 3PL reports
                    it shipped. It is accepted only on the source side, and the source warehouse must be in an
                    externally managed warehouse group connected through Trackstar.
                destination_mode:
                  type: string
                  enum:
                    - worked
                    - automated
                  example: worked
                channel_id:
                  type: integer
                  nullable: true
                  description: Existing channel used to fulfill the source side. Omit or send `null` to clear it.
                  example: null
      responses:
        '200':
          description: Existing route replaced
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 1
                      source_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 22
                          name:
                            type: string
                            nullable: true
                            example: LA Warehouse
                      destination_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 2
                          name:
                            type: string
                            nullable: true
                            example: Milwaukee Warehouse
                      source_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                          - three_pl
                        description: |
                          `worked`: an FO is generated and picked/packed here or pushed to the 3PL/WMS.
                          `automated`: the transfer's sales order is marked shipped automatically on the order date.
                          `three_pl` ("Shipped by 3PL", source side only): the transfer's sales order is marked shipped
                          on the date the source warehouse's 3PL first reports its copy of the order (same order number)
                          as shipped, read through Trackstar. No auto-ship date is set up front, so
                          `transfer_order_defaults.auto_mark_so_as_shipped` and `auto_ship_on_order_date` are `false`.
                      destination_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                        description: |
                          `worked`: the transfer PO is received by receiving report, the mobile app or WMS inbound receipts.
                          `automated`: the transfer is received automatically on the arrival date.
                      channel:
                        type: object
                        nullable: true
                        description: 'Optional fulfillment channel for the source side, or `null`'
                        properties:
                          id:
                            type: integer
                          label:
                            type: string
                            nullable: true
                      transfer_order_defaults:
                        type: object
                        readOnly: true
                        description: |
                          What a new transfer order between this pair starts with (the transfer-order fields the route
                          pre-fills). If the channel pushes orders to a 3PL, `auto_mark_so_as_shipped` is `false` even
                          for an automated source, because the 3PL ships those transfers.
                        properties:
                          auto_mark_so_as_shipped:
                            type: boolean
                          auto_ship_on_order_date:
                            type: boolean
                          auto_receive_order_on_arrival:
                            type: boolean
                          channel_id:
                            type: integer
                            nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '201':
          description: Route created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 1
                      source_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 22
                          name:
                            type: string
                            nullable: true
                            example: LA Warehouse
                      destination_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 2
                          name:
                            type: string
                            nullable: true
                            example: Milwaukee Warehouse
                      source_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                          - three_pl
                        description: |
                          `worked`: an FO is generated and picked/packed here or pushed to the 3PL/WMS.
                          `automated`: the transfer's sales order is marked shipped automatically on the order date.
                          `three_pl` ("Shipped by 3PL", source side only): the transfer's sales order is marked shipped
                          on the date the source warehouse's 3PL first reports its copy of the order (same order number)
                          as shipped, read through Trackstar. No auto-ship date is set up front, so
                          `transfer_order_defaults.auto_mark_so_as_shipped` and `auto_ship_on_order_date` are `false`.
                      destination_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                        description: |
                          `worked`: the transfer PO is received by receiving report, the mobile app or WMS inbound receipts.
                          `automated`: the transfer is received automatically on the arrival date.
                      channel:
                        type: object
                        nullable: true
                        description: 'Optional fulfillment channel for the source side, or `null`'
                        properties:
                          id:
                            type: integer
                          label:
                            type: string
                            nullable: true
                      transfer_order_defaults:
                        type: object
                        readOnly: true
                        description: |
                          What a new transfer order between this pair starts with (the transfer-order fields the route
                          pre-fills). If the channel pushes orders to a 3PL, `auto_mark_so_as_shipped` is `false` even
                          for an automated source, because the 3PL ships those transfers.
                        properties:
                          auto_mark_so_as_shipped:
                            type: boolean
                          auto_ship_on_order_date:
                            type: boolean
                          auto_receive_order_on_arrival:
                            type: boolean
                          channel_id:
                            type: integer
                            nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation failed (same rules as `PUT /transfer-routes`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/transfer-routes/{transferRouteId}':
    get:
      operationId: getTransferRoute
      tags:
        - Transfer Orders
      summary: Get a transfer route
      description: Return one transfer route.
      security:
        - BearerAuth: []
      parameters:
        - name: transferRouteId
          in: path
          required: true
          description: Transfer route ID
          schema:
            type: integer
      responses:
        '200':
          description: The transfer route
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 1
                      source_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 22
                          name:
                            type: string
                            nullable: true
                            example: LA Warehouse
                      destination_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 2
                          name:
                            type: string
                            nullable: true
                            example: Milwaukee Warehouse
                      source_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                          - three_pl
                        description: |
                          `worked`: an FO is generated and picked/packed here or pushed to the 3PL/WMS.
                          `automated`: the transfer's sales order is marked shipped automatically on the order date.
                          `three_pl` ("Shipped by 3PL", source side only): the transfer's sales order is marked shipped
                          on the date the source warehouse's 3PL first reports its copy of the order (same order number)
                          as shipped, read through Trackstar. No auto-ship date is set up front, so
                          `transfer_order_defaults.auto_mark_so_as_shipped` and `auto_ship_on_order_date` are `false`.
                      destination_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                        description: |
                          `worked`: the transfer PO is received by receiving report, the mobile app or WMS inbound receipts.
                          `automated`: the transfer is received automatically on the arrival date.
                      channel:
                        type: object
                        nullable: true
                        description: 'Optional fulfillment channel for the source side, or `null`'
                        properties:
                          id:
                            type: integer
                          label:
                            type: string
                            nullable: true
                      transfer_order_defaults:
                        type: object
                        readOnly: true
                        description: |
                          What a new transfer order between this pair starts with (the transfer-order fields the route
                          pre-fills). If the channel pushes orders to a 3PL, `auto_mark_so_as_shipped` is `false` even
                          for an automated source, because the 3PL ships those transfers.
                        properties:
                          auto_mark_so_as_shipped:
                            type: boolean
                          auto_ship_on_order_date:
                            type: boolean
                          auto_receive_order_on_arrival:
                            type: boolean
                          channel_id:
                            type: integer
                            nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Transfer route not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    patch:
      operationId: updateTransferRoute
      tags:
        - Transfer Orders
      summary: Update a transfer route
      description: |
        Change only the fields sent: `source_mode`, `destination_mode`, `channel_id`.

        The warehouse pair is the route's identity and cannot change: a body with `source_warehouse_id`
        or `destination_warehouse_id` gets `422` ("A route's warehouse pair cannot change. Delete it and
        PUT the new pair."). The 3PL push-channel rule is checked against the route as it will be saved,
        so attaching a 3PL-pushing channel to a route with an automated source is refused too.
      security:
        - BearerAuth: []
      parameters:
        - name: transferRouteId
          in: path
          required: true
          description: Transfer route ID
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                source_mode:
                  type: string
                  enum:
                    - worked
                    - automated
                    - three_pl
                  description: |
                    `three_pl` is accepted only when the route's source warehouse is in an externally
                    managed warehouse group connected through Trackstar.
                destination_mode:
                  type: string
                  enum:
                    - worked
                    - automated
                channel_id:
                  type: integer
                  nullable: true
                  description: 'Existing channel, or `null` to clear it'
      responses:
        '200':
          description: Updated transfer route
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 1
                      source_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 22
                          name:
                            type: string
                            nullable: true
                            example: LA Warehouse
                      destination_warehouse:
                        type: object
                        properties:
                          id:
                            type: integer
                            example: 2
                          name:
                            type: string
                            nullable: true
                            example: Milwaukee Warehouse
                      source_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                          - three_pl
                        description: |
                          `worked`: an FO is generated and picked/packed here or pushed to the 3PL/WMS.
                          `automated`: the transfer's sales order is marked shipped automatically on the order date.
                          `three_pl` ("Shipped by 3PL", source side only): the transfer's sales order is marked shipped
                          on the date the source warehouse's 3PL first reports its copy of the order (same order number)
                          as shipped, read through Trackstar. No auto-ship date is set up front, so
                          `transfer_order_defaults.auto_mark_so_as_shipped` and `auto_ship_on_order_date` are `false`.
                      destination_mode:
                        type: string
                        enum:
                          - worked
                          - automated
                        description: |
                          `worked`: the transfer PO is received by receiving report, the mobile app or WMS inbound receipts.
                          `automated`: the transfer is received automatically on the arrival date.
                      channel:
                        type: object
                        nullable: true
                        description: 'Optional fulfillment channel for the source side, or `null`'
                        properties:
                          id:
                            type: integer
                          label:
                            type: string
                            nullable: true
                      transfer_order_defaults:
                        type: object
                        readOnly: true
                        description: |
                          What a new transfer order between this pair starts with (the transfer-order fields the route
                          pre-fills). If the channel pushes orders to a 3PL, `auto_mark_so_as_shipped` is `false` even
                          for an automated source, because the 3PL ships those transfers.
                        properties:
                          auto_mark_so_as_shipped:
                            type: boolean
                          auto_ship_on_order_date:
                            type: boolean
                          auto_receive_order_on_arrival:
                            type: boolean
                          channel_id:
                            type: integer
                            nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Transfer route not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Invalid mode or channel, a warehouse id was sent, an automated or `three_pl` source on a 3PL-pushing channel, or a `three_pl` source whose warehouse is not connected through Trackstar'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteTransferRoute
      tags:
        - Transfer Orders
      summary: Delete a transfer route
      description: Delete a route. New transfers between the pair then keep the normal transfer-order defaults; existing transfers are unchanged.
      security:
        - BearerAuth: []
      parameters:
        - name: transferRouteId
          in: path
          required: true
          description: Transfer route ID
          schema:
            type: integer
      responses:
        '204':
          description: Deleted
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Transfer route not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /inbound-shipments:
    get:
      operationId: getInboundShipments
      tags:
        - Inbound Shipments
      summary: Inbound shipments
      description: |
        Get a paginated list of inbound shipments with optional filtering. Results are ordered by
        `updated_at` descending — use `updated_at[gt]` for incremental polling.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### DateTime Filters
        - `created_at`: When the inbound shipment was created
        - `updated_at`: When the inbound shipment was last updated
        - `reconciled_at`: When the shipment was reconciled
        - `arrival_date`: Expected or actual arrival date
        - `external_expected_arrival_date`: Arrival date from the external system
        - `external_date_created`: Creation date from the external system
        - `external_date_updated`: Update date from the external system

        ### Integer Filters
        - `id`: Inbound shipment ID
        - `location_id`: Destination warehouse/location ID
        - `from_warehouse_id`: Origin warehouse ID
        - `purchase_order_id`: Linked purchase order ID
        - `purchase_order_shipment_id`: Linked PO shipment ID
        - `transfer_order_id`: Linked transfer order ID
        - `app_integration_account_id`: Integration account ID

        ### String Filters
        - `source`: Integration source (e.g. "flexe", "extensiv")
        - `external_shipment_id`: Shipment ID in the external system
        - `external_po_number`: PO number from the external system
        - `external_po_number_canonical`: Canonical PO number from the external system
        - `external_warehouse_id`: Warehouse ID in the external system
        - `external_warehouse_customer_id`: Customer ID in the external warehouse system
        - `external_supplier_name`: Supplier name from the external system
        - `external_status`: Normalized status (e.g. "open", "in-transit", "received")
        - `external_raw_status`: Raw status string from the external system

        ### Float Filters
        - `total_expected_quantity`: Total expected item quantity
        - `total_received_quantity`: Total received item quantity
        - `total_unit_cost`: Total unit cost

        ## Examples
        ```
        # Poll for recently updated shipments
        ?updated_at[gt]=2025-01-01 00:00:00

        # Filter by external status
        ?external_status[eq]=received

        # Filter by linked purchase order
        ?purchase_order_id[eq]=456

        # Filter by source integration
        ?source[eq]=extensiv
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: arrival_date
          schema:
            type: string
            format: date-time
          description: Filter by arrival date
        - in: query
          name: external_status
          schema:
            type: string
          description: Filter by normalized external status
        - in: query
          name: external_shipment_id
          schema:
            type: string
          description: Filter by external shipment ID
        - in: query
          name: purchase_order_id
          schema:
            type: integer
          description: Filter by linked purchase order ID
        - in: query
          name: source
          schema:
            type: string
          description: Filter by integration source
        - in: query
          name: location_id
          schema:
            type: integer
          description: Filter by destination location ID
        - in: query
          name: reconciled_at
          schema:
            type: string
            format: date-time
          description: 'Filter by when the shipment was reconciled (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: external_expected_arrival_date
          schema:
            type: string
            format: date-time
          description: 'Filter by arrival date from the external system (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: external_date_created
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date from the external system (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: external_date_updated
          schema:
            type: string
            format: date-time
          description: 'Filter by update date from the external system (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: id
          schema:
            type: integer
          description: Filter by inbound shipment ID
        - in: query
          name: from_warehouse_id
          schema:
            type: integer
          description: Filter by origin warehouse ID
        - in: query
          name: purchase_order_shipment_id
          schema:
            type: integer
          description: Filter by linked PO shipment ID
        - in: query
          name: transfer_order_id
          schema:
            type: integer
          description: Filter by linked transfer order ID
        - in: query
          name: app_integration_account_id
          schema:
            type: integer
          description: Filter by integration account ID
        - in: query
          name: external_po_number
          schema:
            type: string
          description: Filter by PO number from the external system
        - in: query
          name: external_po_number_canonical
          schema:
            type: string
          description: Filter by canonical PO number from the external system
        - in: query
          name: external_warehouse_id
          schema:
            type: string
          description: Filter by warehouse ID in the external system
        - in: query
          name: external_warehouse_customer_id
          schema:
            type: string
          description: Filter by customer ID in the external warehouse system
        - in: query
          name: external_supplier_name
          schema:
            type: string
          description: Filter by supplier name from the external system
        - in: query
          name: external_raw_status
          schema:
            type: string
          description: Filter by raw status string from the external system
        - in: query
          name: total_expected_quantity
          schema:
            type: number
          description: Filter by total expected item quantity
        - in: query
          name: total_received_quantity
          schema:
            type: number
          description: Filter by total received item quantity
        - in: query
          name: total_unit_cost
          schema:
            type: number
          description: Filter by total unit cost
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        source:
                          type: string
                          nullable: true
                          description: 'Integration source that created the shipment (e.g. "flexe", "extensiv")'
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                        reconciled_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: When the inbound shipment was reconciled against received inventory
                        arrival_date:
                          type: string
                          format: date-time
                          nullable: true
                          description: Expected or actual arrival date
                        location_id:
                          type: integer
                          description: Destination warehouse/location ID
                        from_warehouse_id:
                          type: integer
                          nullable: true
                          description: Origin warehouse ID (for transfers)
                        purchase_order_id:
                          type: integer
                          nullable: true
                          description: Linked purchase order ID
                        purchase_order_shipment_id:
                          type: integer
                          nullable: true
                          description: Linked supplier PO shipment ID
                        transfer_order_id:
                          type: integer
                          nullable: true
                          description: Linked transfer order ID
                        app_integration_account_id:
                          type: integer
                          nullable: true
                          description: Integration account that sourced this shipment
                        external_shipment_id:
                          type: string
                          nullable: true
                          description: Shipment identifier in the external system
                        external_warehouse_customer_id:
                          type: string
                          nullable: true
                        external_po_number:
                          type: string
                          nullable: true
                        external_po_number_canonical:
                          type: string
                          nullable: true
                        external_status:
                          type: string
                          nullable: true
                          description: 'Normalized status from the external system (e.g. "open", "in-transit", "received")'
                        external_raw_status:
                          type: string
                          nullable: true
                          description: Raw status string as returned by the external system
                        external_supplier_name:
                          type: string
                          nullable: true
                        external_expected_arrival_date:
                          type: string
                          format: date-time
                          nullable: true
                        external_warehouse_id:
                          type: string
                          nullable: true
                        external_tracking_numbers:
                          type: array
                          nullable: true
                          items: {}
                        external_date_created:
                          type: string
                          format: date-time
                          nullable: true
                        external_date_updated:
                          type: string
                          format: date-time
                          nullable: true
                        external_ship_from_address:
                          type: object
                          nullable: true
                          properties:
                            street1:
                              type: string
                              nullable: true
                            street2:
                              type: string
                              nullable: true
                            street3:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                            state:
                              type: string
                              nullable: true
                            postal_code:
                              type: string
                              nullable: true
                            country:
                              type: string
                              nullable: true
                        total_expected_quantity:
                          type: number
                          format: float
                        total_received_quantity:
                          type: number
                          format: float
                        total_unit_cost:
                          type: number
                          format: float
                        external_notes:
                          type: array
                          nullable: true
                          items: {}
                        external_system_url:
                          type: string
                          nullable: true
                        items:
                          type: array
                          description: Line items (present when the relation is loaded)
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              external_item_id:
                                type: string
                                nullable: true
                              external_id:
                                type: string
                                nullable: true
                              external_sku:
                                type: string
                                nullable: true
                              expected_quantity:
                                type: number
                                format: float
                              received_quantity:
                                type: number
                                format: float
                              unit_cost:
                                type: number
                                format: float
                              purchase_order_shipment_item_id:
                                type: integer
                                nullable: true
                              rfq_id:
                                type: integer
                                nullable: true
                                description: Internal product (SKU) ID
                        location:
                          allOf:
                            - type: object
                              properties:
                                id:
                                  type: integer
                                status:
                                  type: string
                                name:
                                  type: string
                                parent_id:
                                  type: integer
                                  nullable: true
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                          nullable: true
                          description: Destination location
                        from_location:
                          allOf:
                            - type: object
                              properties:
                                id:
                                  type: integer
                                status:
                                  type: string
                                name:
                                  type: string
                                parent_id:
                                  type: integer
                                  nullable: true
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                          nullable: true
                          description: Origin location (for transfers)
                        purchase_order:
                          type: object
                          nullable: true
                          description: Linked purchase order summary
                          additionalProperties: true
                          properties:
                            id:
                              type: integer
                            order_numbers:
                              type: array
                              items:
                                type: string
                            order_status:
                              type: string
                              nullable: true
                            receipt_status:
                              type: string
                              nullable: true
                              enum:
                                - awaiting_shipment
                                - partially_received
                                - fully_received
                              description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                        transfer_order:
                          type: object
                          nullable: true
                          description: Linked transfer order summary
                          additionalProperties: true
                          properties:
                            id:
                              type: integer
                            number:
                              type: string
                              nullable: true
                            status:
                              type: string
                              nullable: true
                        purchase_order_shipment:
                          allOf:
                            - type: object
                              properties:
                                id:
                                  type: integer
                                created_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                updated_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                reference_number:
                                  type: string
                                  description: Supplier reference number for this shipment
                                total_shipping_cost:
                                  type: number
                                  format: float
                                shipping_date:
                                  type: string
                                  format: date-time
                                  nullable: true
                                warehouse_id:
                                  type: integer
                                  nullable: true
                                  description: Destination warehouse ID
                                shipment_status_id:
                                  type: integer
                                  nullable: true
                                notes:
                                  type: string
                                  nullable: true
                                  description: Free-text notes on the shipment
                                tracking_number:
                                  type: string
                                  nullable: true
                                  description: Carrier tracking number
                                shipped_by:
                                  type: string
                                  nullable: true
                                  enum:
                                    - Freight
                                    - Supplier
                                  description: Who is responsible for shipping
                                shipment_type:
                                  type: string
                                  nullable: true
                                  enum:
                                    - Air
                                    - Sea
                                    - Road
                                    - Rail
                                    - Express
                                  description: Mode of transport for the shipment
                                estimated_arrival:
                                  type: string
                                  format: date
                                  nullable: true
                                  description: Estimated arrival date
                                is_closed:
                                  type: boolean
                                  description: 'Whether the shipment is marked as closed. Closing has no enforced behavior (it does not gate edits, pushes, or receiving) and is provided for filtering and reporting. It can be set manually, and is also set to `true` automatically when a receiving report brings every shipment line to fully received (the shipment status is moved to its "received"/Arrived mapping at the same time). Automatic closing never reopens a shipment — if received quantity later drops (e.g. a voided receipt), `is_closed` stays `true`.'
                                volume_target_cbm:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Container volume target in cubic meters. Null when unset.
                                sync_status:
                                  type: string
                                  nullable: true
                                  description: 'Integration sync status (e.g. "synced", "unsynced")'
                                last_synced_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                last_synced_status:
                                  description: Raw sync status payload from the integration (shape varies)
                                  nullable: true
                                shipment_status:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                warehouse:
                                  allOf:
                                    - type: object
                                      properties:
                                        id:
                                          type: integer
                                        status:
                                          type: string
                                        name:
                                          type: string
                                        parent_id:
                                          type: integer
                                          nullable: true
                                        created_at:
                                          type: string
                                          format: date-time
                                        updated_at:
                                          type: string
                                          format: date-time
                                  nullable: true
                                shipment_items:
                                  type: array
                                  description: Line items (present when the relation is loaded)
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                      created_at:
                                        type: string
                                        format: date-time
                                        nullable: true
                                      updated_at:
                                        type: string
                                        format: date-time
                                        nullable: true
                                      supplier_purchase_order_shipment_id:
                                        type: integer
                                      supplier_purchase_order_id:
                                        type: integer
                                      supplier_purchase_order_item_id:
                                        type: integer
                                      quantity:
                                        type: number
                                        format: float
                                      unit_of_measure_id:
                                        type: integer
                                      cbm:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Cubic meters (volume) for this line
                                      carton_quantity:
                                        type: integer
                                        nullable: true
                                        description: Number of cartons for this line
                                      carton_dimensions:
                                        type: string
                                        nullable: true
                                        description: Carton dimensions for this line
                                shipment_extra_costs:
                                  type: array
                                  description: Extra costs applied to the shipment (present when the relation is loaded)
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                      created_at:
                                        type: string
                                        format: date-time
                                        nullable: true
                                      updated_at:
                                        type: string
                                        format: date-time
                                        nullable: true
                                      supplier_purchase_order_shipment_id:
                                        type: integer
                                      name:
                                        type: string
                                      quantity:
                                        type: number
                                        format: float
                                      unit_price:
                                        type: number
                                        format: float
                                      line_total:
                                        type: number
                                        format: float
                                      cost_allocation_type:
                                        type: string
                                        nullable: true
                                custom_fields:
                                  type: object
                                  nullable: true
                                  description: 'Custom field values for this shipment as a label => value map, e.g. `{ "Cargo Ready Date": "2026-10-20" }`. Only fields with a stored value appear, so a field defined for shipments but never filled in is absent and the object can be `{}`. Date values are `YYYY-MM-DD`. To list the fields defined for shipments (including unset ones), call `GET /custom-fields?object_type=SHIPMENT`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                  additionalProperties: true
                          nullable: true
                          description: Linked supplier PO shipment
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /inbound-plans:
    get:
      operationId: getInboundPlans
      tags:
        - Inbound Shipments
      summary: Amazon FBA inbound plans not yet shipped
      description: |
        List active Amazon FBA inbound plans (Fulfillment Inbound API 2024-03-20) for one Amazon FBA
        integration account that have no confirmed shipment yet, so they do not appear in
        `GET /inbound-shipments`. A plan is included when it has
        no shipments, or every shipment is still `UNCONFIRMED`. Each item carries its per-SKU quantity.

        Plans are read live from Amazon through the account's Trackstar connection and cached for 15 minutes per
        account; `fetched_at` tells you when the data was read. Amazon throttles these calls, so the endpoint is
        rate limited to 20 requests per minute. When the complete list cannot be read, the API returns `503` with a
        `Retry-After` header — it never returns a partial list.

        Each item's Amazon MSKU is mapped to the Luminous SKU it is linked to on the account (`sku_id` / `sku`);
        both are `null` when the MSKU is not linked.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: app_integration_account_id
          required: true
          schema:
            type: integer
          description: Amazon FBA integration account ID (same value as `app_integration_account_id` on inbound shipments).
      responses:
        '200':
          description: Inbound plans for the account
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      app_integration_account_id:
                        type: integer
                      fetched_at:
                        type: string
                        format: date-time
                        description: When the plans were read from Amazon (earlier than now when served from cache).
                      plans:
                        type: array
                        items:
                          type: object
                          properties:
                            inbound_plan_id:
                              type: string
                            name:
                              type: string
                              nullable: true
                            status:
                              type: string
                              nullable: true
                            created_at:
                              type: string
                              nullable: true
                            last_updated_at:
                              type: string
                              nullable: true
                            items:
                              type: array
                              items:
                                type: object
                                properties:
                                  msku:
                                    type: string
                                    nullable: true
                                    description: Amazon merchant SKU.
                                  fnsku:
                                    type: string
                                    nullable: true
                                  asin:
                                    type: string
                                    nullable: true
                                  quantity:
                                    type: integer
                                  sku_id:
                                    type: integer
                                    nullable: true
                                    description: Luminous product ID the MSKU is linked to on this account; `null` when not linked.
                                  sku:
                                    type: string
                                    nullable: true
                                    description: Luminous internal SKU the MSKU is linked to; `null` when not linked.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: '`app_integration_account_id` is missing, or the account is not an Amazon FBA integration account.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '429':
          description: Rate limit exceeded (20 requests per minute).
        '503':
          description: 'Amazon throttled or failed a call, so the list could not be read completely. Retry after the number of seconds in the `Retry-After` header.'
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/inbound-shipments/{id}':
    get:
      operationId: getInboundShipmentById
      tags:
        - Inbound Shipments
      summary: Get inbound shipment
      description: Get a single inbound shipment by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Inbound shipment ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      source:
                        type: string
                        nullable: true
                        description: 'Integration source that created the shipment (e.g. "flexe", "extensiv")'
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      reconciled_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When the inbound shipment was reconciled against received inventory
                      arrival_date:
                        type: string
                        format: date-time
                        nullable: true
                        description: Expected or actual arrival date
                      location_id:
                        type: integer
                        description: Destination warehouse/location ID
                      from_warehouse_id:
                        type: integer
                        nullable: true
                        description: Origin warehouse ID (for transfers)
                      purchase_order_id:
                        type: integer
                        nullable: true
                        description: Linked purchase order ID
                      purchase_order_shipment_id:
                        type: integer
                        nullable: true
                        description: Linked supplier PO shipment ID
                      transfer_order_id:
                        type: integer
                        nullable: true
                        description: Linked transfer order ID
                      app_integration_account_id:
                        type: integer
                        nullable: true
                        description: Integration account that sourced this shipment
                      external_shipment_id:
                        type: string
                        nullable: true
                        description: Shipment identifier in the external system
                      external_warehouse_customer_id:
                        type: string
                        nullable: true
                      external_po_number:
                        type: string
                        nullable: true
                      external_po_number_canonical:
                        type: string
                        nullable: true
                      external_status:
                        type: string
                        nullable: true
                        description: 'Normalized status from the external system (e.g. "open", "in-transit", "received")'
                      external_raw_status:
                        type: string
                        nullable: true
                        description: Raw status string as returned by the external system
                      external_supplier_name:
                        type: string
                        nullable: true
                      external_expected_arrival_date:
                        type: string
                        format: date-time
                        nullable: true
                      external_warehouse_id:
                        type: string
                        nullable: true
                      external_tracking_numbers:
                        type: array
                        nullable: true
                        items: {}
                      external_date_created:
                        type: string
                        format: date-time
                        nullable: true
                      external_date_updated:
                        type: string
                        format: date-time
                        nullable: true
                      external_ship_from_address:
                        type: object
                        nullable: true
                        properties:
                          street1:
                            type: string
                            nullable: true
                          street2:
                            type: string
                            nullable: true
                          street3:
                            type: string
                            nullable: true
                          city:
                            type: string
                            nullable: true
                          state:
                            type: string
                            nullable: true
                          postal_code:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                      total_expected_quantity:
                        type: number
                        format: float
                      total_received_quantity:
                        type: number
                        format: float
                      total_unit_cost:
                        type: number
                        format: float
                      external_notes:
                        type: array
                        nullable: true
                        items: {}
                      external_system_url:
                        type: string
                        nullable: true
                      items:
                        type: array
                        description: Line items (present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            external_item_id:
                              type: string
                              nullable: true
                            external_id:
                              type: string
                              nullable: true
                            external_sku:
                              type: string
                              nullable: true
                            expected_quantity:
                              type: number
                              format: float
                            received_quantity:
                              type: number
                              format: float
                            unit_cost:
                              type: number
                              format: float
                            purchase_order_shipment_item_id:
                              type: integer
                              nullable: true
                            rfq_id:
                              type: integer
                              nullable: true
                              description: Internal product (SKU) ID
                      location:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                              status:
                                type: string
                              name:
                                type: string
                              parent_id:
                                type: integer
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                        description: Destination location
                      from_location:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                              status:
                                type: string
                              name:
                                type: string
                              parent_id:
                                type: integer
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                        description: Origin location (for transfers)
                      purchase_order:
                        type: object
                        nullable: true
                        description: Linked purchase order summary
                        additionalProperties: true
                        properties:
                          id:
                            type: integer
                          order_numbers:
                            type: array
                            items:
                              type: string
                          order_status:
                            type: string
                            nullable: true
                          receipt_status:
                            type: string
                            nullable: true
                            enum:
                              - awaiting_shipment
                              - partially_received
                              - fully_received
                            description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                          updated_at:
                            type: string
                            format: date-time
                            nullable: true
                      transfer_order:
                        type: object
                        nullable: true
                        description: Linked transfer order summary
                        additionalProperties: true
                        properties:
                          id:
                            type: integer
                          number:
                            type: string
                            nullable: true
                          status:
                            type: string
                            nullable: true
                      purchase_order_shipment:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                              updated_at:
                                type: string
                                format: date-time
                                nullable: true
                              reference_number:
                                type: string
                                description: Supplier reference number for this shipment
                              total_shipping_cost:
                                type: number
                                format: float
                              shipping_date:
                                type: string
                                format: date-time
                                nullable: true
                              warehouse_id:
                                type: integer
                                nullable: true
                                description: Destination warehouse ID
                              shipment_status_id:
                                type: integer
                                nullable: true
                              notes:
                                type: string
                                nullable: true
                                description: Free-text notes on the shipment
                              tracking_number:
                                type: string
                                nullable: true
                                description: Carrier tracking number
                              shipped_by:
                                type: string
                                nullable: true
                                enum:
                                  - Freight
                                  - Supplier
                                description: Who is responsible for shipping
                              shipment_type:
                                type: string
                                nullable: true
                                enum:
                                  - Air
                                  - Sea
                                  - Road
                                  - Rail
                                  - Express
                                description: Mode of transport for the shipment
                              estimated_arrival:
                                type: string
                                format: date
                                nullable: true
                                description: Estimated arrival date
                              is_closed:
                                type: boolean
                                description: 'Whether the shipment is marked as closed. Closing has no enforced behavior (it does not gate edits, pushes, or receiving) and is provided for filtering and reporting. It can be set manually, and is also set to `true` automatically when a receiving report brings every shipment line to fully received (the shipment status is moved to its "received"/Arrived mapping at the same time). Automatic closing never reopens a shipment — if received quantity later drops (e.g. a voided receipt), `is_closed` stays `true`.'
                              volume_target_cbm:
                                type: number
                                format: float
                                nullable: true
                                description: Container volume target in cubic meters. Null when unset.
                              sync_status:
                                type: string
                                nullable: true
                                description: 'Integration sync status (e.g. "synced", "unsynced")'
                              last_synced_at:
                                type: string
                                format: date-time
                                nullable: true
                              last_synced_status:
                                description: Raw sync status payload from the integration (shape varies)
                                nullable: true
                              shipment_status:
                                type: object
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              warehouse:
                                allOf:
                                  - type: object
                                    properties:
                                      id:
                                        type: integer
                                      status:
                                        type: string
                                      name:
                                        type: string
                                      parent_id:
                                        type: integer
                                        nullable: true
                                      created_at:
                                        type: string
                                        format: date-time
                                      updated_at:
                                        type: string
                                        format: date-time
                                nullable: true
                              shipment_items:
                                type: array
                                description: Line items (present when the relation is loaded)
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    created_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    updated_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    supplier_purchase_order_shipment_id:
                                      type: integer
                                    supplier_purchase_order_id:
                                      type: integer
                                    supplier_purchase_order_item_id:
                                      type: integer
                                    quantity:
                                      type: number
                                      format: float
                                    unit_of_measure_id:
                                      type: integer
                                    cbm:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Cubic meters (volume) for this line
                                    carton_quantity:
                                      type: integer
                                      nullable: true
                                      description: Number of cartons for this line
                                    carton_dimensions:
                                      type: string
                                      nullable: true
                                      description: Carton dimensions for this line
                              shipment_extra_costs:
                                type: array
                                description: Extra costs applied to the shipment (present when the relation is loaded)
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    created_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    updated_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    supplier_purchase_order_shipment_id:
                                      type: integer
                                    name:
                                      type: string
                                    quantity:
                                      type: number
                                      format: float
                                    unit_price:
                                      type: number
                                      format: float
                                    line_total:
                                      type: number
                                      format: float
                                    cost_allocation_type:
                                      type: string
                                      nullable: true
                              custom_fields:
                                type: object
                                nullable: true
                                description: 'Custom field values for this shipment as a label => value map, e.g. `{ "Cargo Ready Date": "2026-10-20" }`. Only fields with a stored value appear, so a field defined for shipments but never filled in is absent and the object can be `{}`. Date values are `YYYY-MM-DD`. To list the fields defined for shipments (including unset ones), call `GET /custom-fields?object_type=SHIPMENT`. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties: true
                        nullable: true
                        description: Linked supplier PO shipment
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /defective-reports:
    get:
      operationId: getDefectiveReports
      tags:
        - Defective Reports
      summary: Defective reports
      description: |
        List defective reports, newest `reported_date` first. Returns the same rows as the
        Inventory > Defectives screen for the same filters. Deleted reports are never returned.

        Filters are plain equality / contains matches (the [filter operators](/filters) are not
        supported here):

        - `date`: reports with this `reported_date`; with `date_to`, reports between `date` and `date_to` (inclusive)
        - `defect_type`: `10` Manufacture, `20` Production, `90` Other
        - `factory_id`: reports with a line from this vendor (supplier)
        - `po_number`: reports with a line on this purchase order **id** (not the PO number)
        - `sku`: reports with a line whose SKU contains this text

        The response is always paginated (`per_page` defaults to 20, capped at 100) and uses
        the paginator envelope shown below, with `current_page`/`total` etc. at the top level
        rather than under `meta`.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number
        - in: query
          name: per_page
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
          description: Reports per page; values outside 1–100 are clamped
        - in: query
          name: date
          schema:
            type: string
            format: date
          description: 'Reported date (YYYY-MM-DD), or the start of the range when `date_to` is sent'
        - in: query
          name: date_to
          schema:
            type: string
            format: date
          description: End of the reported-date range (YYYY-MM-DD); only used with `date`
        - in: query
          name: defect_type
          schema:
            type: integer
            enum:
              - 10
              - 20
              - 90
          description: '`10` Manufacture, `20` Production, `90` Other'
        - in: query
          name: factory_id
          schema:
            type: integer
          description: Vendor (supplier) id on any line of the report
        - in: query
          name: po_number
          schema:
            type: integer
          description: Purchase order **id** on any line of the report
        - in: query
          name: sku
          schema:
            type: string
          description: SKU (contains match) on any line of the report
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  current_page:
                    type: integer
                  data:
                    type: array
                    items:
                      type: object
                      description: A defective report from Inventory > Defectives.
                      properties:
                        id:
                          type: integer
                        reported_date:
                          type: string
                          format: date
                          nullable: true
                          example: '2026-11-03'
                        reported_by:
                          type: string
                          nullable: true
                        reported_at:
                          type: string
                          nullable: true
                        defect_type:
                          type: integer
                          enum:
                            - 10
                            - 20
                            - 90
                          description: '`10` Manufacture, `20` Production, `90` Other'
                        total_quantity:
                          type: string
                          description: 'Sum of the line quantities, as a decimal string'
                        total_cost:
                          type: number
                        total_tax:
                          type: number
                        status:
                          type: integer
                          description: Always `1` (active); deleted reports are not returned
                        created_by:
                          type: integer
                        updated_by:
                          type: integer
                        created_at:
                          type: string
                          nullable: true
                        updated_at:
                          type: string
                          nullable: true
                        defective_report_rfq:
                          type: array
                          description: The report's defective lines
                          items:
                            type: object
                            description: |
                              One defective line of a defective report (`defective_report_rfq` on the report). Lines created
                              through `POST /defective-reports` are built from the SKU's latest receiving-report line on the
                              purchase order, so price, unit, vendor and product name come from that receipt.
                            properties:
                              id:
                                type: integer
                              defective_report_id:
                                type: integer
                              purchase_order_id:
                                type: integer
                                description: Purchase order the defective units were received on
                              purchase_order_rfq_id:
                                type: integer
                                description: Purchase order line id
                              quantity:
                                type: string
                                description: 'Defective quantity in `defective_uom_id`, as a decimal string'
                                example: '2.000000'
                              defective_uom_id:
                                type: integer
                                nullable: true
                                description: Unit of measure `quantity` is expressed in
                              base_uom_id:
                                type: integer
                                nullable: true
                                description: The SKU's base unit of measure
                              defective_qty:
                                type: string
                                nullable: true
                                description: '`quantity` converted to the base unit of measure, as a decimal string'
                              unit:
                                type: string
                                nullable: true
                                example: pcs
                              unit_price:
                                type: number
                                description: Unit price of the received line
                              line_total:
                                type: number
                                description: '`quantity` × `unit_price`'
                              remarks:
                                type: string
                                nullable: true
                              factory_id:
                                type: integer
                                description: Vendor (supplier) id of the purchase order
                              factory_name:
                                type: string
                                nullable: true
                                description: Vendor (supplier) name
                              receiving_report_id:
                                type: integer
                                description: Id of the receiving-report **line** the defective line was taken from
                              received_date:
                                type: string
                                format: date
                                nullable: true
                              sku:
                                type: string
                                nullable: true
                              product_name:
                                type: string
                                nullable: true
                              stock_id:
                                type: integer
                                description: Stock row (SKU + warehouse) the quantity was deducted from
                              location_id:
                                type: integer
                                nullable: true
                                description: Location (bin) the quantity was deducted from
                              lot_id:
                                type: integer
                                nullable: true
                                description: 'Lot id, `0` when no lot'
                              created_at:
                                type: string
                                nullable: true
                              updated_at:
                                type: string
                                nullable: true
                              purchase_order_rfq:
                                type: object
                                nullable: true
                                additionalProperties: true
                                description: 'The purchase order line, with its product (`rfq`) and the product''s `unit_of_measures`'
                              factory:
                                type: object
                                nullable: true
                                additionalProperties: true
                                description: The vendor (supplier) record
                              stock:
                                type: object
                                nullable: true
                                additionalProperties: true
                                description: 'The stock row (`warehouse_id`, `qty_onhand`, `qty_available`, ...)'
                              rfq:
                                type: object
                                nullable: true
                                additionalProperties: true
                                description: 'The product matched by `sku`, with `unit_of_measures` and `parent`. List responses only.'
                  first_page_url:
                    type: string
                  from:
                    type: integer
                    nullable: true
                  last_page:
                    type: integer
                  last_page_url:
                    type: string
                  next_page_url:
                    type: string
                    nullable: true
                  path:
                    type: string
                  per_page:
                    type: integer
                  prev_page_url:
                    type: string
                    nullable: true
                  to:
                    type: integer
                    nullable: true
                  total:
                    type: integer
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createDefectiveReport
      tags:
        - Defective Reports
      summary: Create a defective report
      description: |
        Record defective units of one SKU received on a purchase order, the way the
        Inventory > Defectives screen's "add item" picker does. The report gets one line, built
        from the SKU's latest receiving-report line on that purchase order (unit price, unit,
        vendor, product name and received date come from that receipt). There is no update or
        delete over the API.

        **Inventory:** unless `is_affecting_inventory` is `false`, the quantity (converted to the
        SKU's base unit of measure) is deducted from on hand in the warehouse, from `location_id`
        or, when omitted, the warehouse's first picking location, else its default receiving, else
        its default shipping location. Only an existing stock row is deducted from; a warehouse
        with no stock of the SKU is refused rather than creating one.

        **Defaults:** `warehouse_id` defaults to the warehouse the units were received into,
        `defective_uom_id` to the SKU's base unit of measure (a variant without its own units
        uses its parent's), `reported_date` to today.

        **Idempotency:** creating a defective report moves inventory, so this endpoint supports
        the optional `Idempotency-Key` request header. Send the same key when retrying a call that
        timed out and the original stored response is replayed (with an `Idempotent-Replay: true`
        header) instead of deducting twice. Reusing a key with a **different** request body is
        rejected with `409`. Keys are honored for 24 hours.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: |
            Optional idempotency token. A retry with the same key replays the original response
            instead of creating a second report. Reusing the key with a different body returns `409`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - purchase_order_id
                - sku
                - quantity
                - defect_type
              properties:
                purchase_order_id:
                  type: integer
                  minimum: 1
                  description: Purchase order the SKU was received on. Must be active (not deleted) and have a receiving-report line for the SKU.
                sku:
                  type: string
                  description: SKU of the defective units
                quantity:
                  type: number
                  exclusiveMinimum: true
                  minimum: 0
                  description: 'Defective quantity, in `defective_uom_id`'
                defect_type:
                  type: integer
                  enum:
                    - 10
                    - 20
                    - 90
                  description: '`10` Manufacture, `20` Production, `90` Other'
                reported_date:
                  type: string
                  format: date
                  nullable: true
                  description: YYYY-MM-DD; defaults to today
                reported_by:
                  type: string
                  maxLength: 255
                  nullable: true
                defective_uom_id:
                  type: integer
                  nullable: true
                  description: 'A unit of measure of the SKU (or of its parent, for a variant without its own). Defaults to the base unit.'
                warehouse_id:
                  type: integer
                  nullable: true
                  description: Warehouse (top-level location) to deduct from. Defaults to the warehouse the units were received into.
                location_id:
                  type: integer
                  nullable: true
                  description: Location (bin) of that warehouse to deduct from. Defaults as described above.
                lot_id:
                  type: integer
                  nullable: true
                  description: A lot of the SKU
                remarks:
                  type: string
                  nullable: true
                is_affecting_inventory:
                  type: boolean
                  nullable: true
                  default: true
                  description: Set `false` to record the report without deducting on hand
              example:
                purchase_order_id: 1042
                sku: WIDGET-BLUE
                quantity: 3
                defect_type: 10
                reported_date: '2026-11-03'
                reported_by: Emily
                remarks: Cracked housing
      responses:
        '201':
          description: Defective report created
          content:
            application/json:
              schema:
                type: object
                description: A defective report from Inventory > Defectives.
                properties:
                  id:
                    type: integer
                  reported_date:
                    type: string
                    format: date
                    nullable: true
                    example: '2026-11-03'
                  reported_by:
                    type: string
                    nullable: true
                  reported_at:
                    type: string
                    nullable: true
                  defect_type:
                    type: integer
                    enum:
                      - 10
                      - 20
                      - 90
                    description: '`10` Manufacture, `20` Production, `90` Other'
                  total_quantity:
                    type: string
                    description: 'Sum of the line quantities, as a decimal string'
                  total_cost:
                    type: number
                  total_tax:
                    type: number
                  status:
                    type: integer
                    description: Always `1` (active); deleted reports are not returned
                  created_by:
                    type: integer
                  updated_by:
                    type: integer
                  created_at:
                    type: string
                    nullable: true
                  updated_at:
                    type: string
                    nullable: true
                  defective_report_rfq:
                    type: array
                    description: The report's defective lines
                    items:
                      type: object
                      description: |
                        One defective line of a defective report (`defective_report_rfq` on the report). Lines created
                        through `POST /defective-reports` are built from the SKU's latest receiving-report line on the
                        purchase order, so price, unit, vendor and product name come from that receipt.
                      properties:
                        id:
                          type: integer
                        defective_report_id:
                          type: integer
                        purchase_order_id:
                          type: integer
                          description: Purchase order the defective units were received on
                        purchase_order_rfq_id:
                          type: integer
                          description: Purchase order line id
                        quantity:
                          type: string
                          description: 'Defective quantity in `defective_uom_id`, as a decimal string'
                          example: '2.000000'
                        defective_uom_id:
                          type: integer
                          nullable: true
                          description: Unit of measure `quantity` is expressed in
                        base_uom_id:
                          type: integer
                          nullable: true
                          description: The SKU's base unit of measure
                        defective_qty:
                          type: string
                          nullable: true
                          description: '`quantity` converted to the base unit of measure, as a decimal string'
                        unit:
                          type: string
                          nullable: true
                          example: pcs
                        unit_price:
                          type: number
                          description: Unit price of the received line
                        line_total:
                          type: number
                          description: '`quantity` × `unit_price`'
                        remarks:
                          type: string
                          nullable: true
                        factory_id:
                          type: integer
                          description: Vendor (supplier) id of the purchase order
                        factory_name:
                          type: string
                          nullable: true
                          description: Vendor (supplier) name
                        receiving_report_id:
                          type: integer
                          description: Id of the receiving-report **line** the defective line was taken from
                        received_date:
                          type: string
                          format: date
                          nullable: true
                        sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        stock_id:
                          type: integer
                          description: Stock row (SKU + warehouse) the quantity was deducted from
                        location_id:
                          type: integer
                          nullable: true
                          description: Location (bin) the quantity was deducted from
                        lot_id:
                          type: integer
                          nullable: true
                          description: 'Lot id, `0` when no lot'
                        created_at:
                          type: string
                          nullable: true
                        updated_at:
                          type: string
                          nullable: true
                        purchase_order_rfq:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: 'The purchase order line, with its product (`rfq`) and the product''s `unit_of_measures`'
                        factory:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: The vendor (supplier) record
                        stock:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: 'The stock row (`warehouse_id`, `qty_onhand`, `qty_available`, ...)'
                        rfq:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: 'The product matched by `sku`, with `unit_of_measures` and `parent`. List responses only.'
        '400':
          description: |
            Validation failed (missing/invalid field, `defect_type` not 10/20/90, `quantity` not
            above 0, or a `warehouse_id` / `location_id` / `lot_id` / `defective_uom_id` that does
            not exist; `warehouse_id` must be a top-level location). Returns the first error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: '`Idempotency-Key` reused with a different request body'
        '422':
          description: |
            Refused before anything is written. One of:
            - `SKU not found.`
            - `No received line for this SKU on this purchase order.` (also for a deleted purchase order)
            - `location_id is not a location of the warehouse.`
            - `lot_id is not a lot of this SKU.`
            - `defective_uom_id is not a unit of measure of this SKU.`
            - `This SKU is not inventory tracked.`
            - `No stock for this SKU in the warehouse.`
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: No stock for this SKU in the warehouse.
  '/defective-reports/{defectiveReportId}':
    get:
      operationId: getDefectiveReport
      tags:
        - Defective Reports
      summary: Get a defective report
      description: Get one defective report with its lines. Deleted reports return `404`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: defectiveReportId
          required: true
          schema:
            type: integer
          description: Defective report id
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                description: A defective report from Inventory > Defectives.
                properties:
                  id:
                    type: integer
                  reported_date:
                    type: string
                    format: date
                    nullable: true
                    example: '2026-11-03'
                  reported_by:
                    type: string
                    nullable: true
                  reported_at:
                    type: string
                    nullable: true
                  defect_type:
                    type: integer
                    enum:
                      - 10
                      - 20
                      - 90
                    description: '`10` Manufacture, `20` Production, `90` Other'
                  total_quantity:
                    type: string
                    description: 'Sum of the line quantities, as a decimal string'
                  total_cost:
                    type: number
                  total_tax:
                    type: number
                  status:
                    type: integer
                    description: Always `1` (active); deleted reports are not returned
                  created_by:
                    type: integer
                  updated_by:
                    type: integer
                  created_at:
                    type: string
                    nullable: true
                  updated_at:
                    type: string
                    nullable: true
                  defective_report_rfq:
                    type: array
                    description: The report's defective lines
                    items:
                      type: object
                      description: |
                        One defective line of a defective report (`defective_report_rfq` on the report). Lines created
                        through `POST /defective-reports` are built from the SKU's latest receiving-report line on the
                        purchase order, so price, unit, vendor and product name come from that receipt.
                      properties:
                        id:
                          type: integer
                        defective_report_id:
                          type: integer
                        purchase_order_id:
                          type: integer
                          description: Purchase order the defective units were received on
                        purchase_order_rfq_id:
                          type: integer
                          description: Purchase order line id
                        quantity:
                          type: string
                          description: 'Defective quantity in `defective_uom_id`, as a decimal string'
                          example: '2.000000'
                        defective_uom_id:
                          type: integer
                          nullable: true
                          description: Unit of measure `quantity` is expressed in
                        base_uom_id:
                          type: integer
                          nullable: true
                          description: The SKU's base unit of measure
                        defective_qty:
                          type: string
                          nullable: true
                          description: '`quantity` converted to the base unit of measure, as a decimal string'
                        unit:
                          type: string
                          nullable: true
                          example: pcs
                        unit_price:
                          type: number
                          description: Unit price of the received line
                        line_total:
                          type: number
                          description: '`quantity` × `unit_price`'
                        remarks:
                          type: string
                          nullable: true
                        factory_id:
                          type: integer
                          description: Vendor (supplier) id of the purchase order
                        factory_name:
                          type: string
                          nullable: true
                          description: Vendor (supplier) name
                        receiving_report_id:
                          type: integer
                          description: Id of the receiving-report **line** the defective line was taken from
                        received_date:
                          type: string
                          format: date
                          nullable: true
                        sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        stock_id:
                          type: integer
                          description: Stock row (SKU + warehouse) the quantity was deducted from
                        location_id:
                          type: integer
                          nullable: true
                          description: Location (bin) the quantity was deducted from
                        lot_id:
                          type: integer
                          nullable: true
                          description: 'Lot id, `0` when no lot'
                        created_at:
                          type: string
                          nullable: true
                        updated_at:
                          type: string
                          nullable: true
                        purchase_order_rfq:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: 'The purchase order line, with its product (`rfq`) and the product''s `unit_of_measures`'
                        factory:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: The vendor (supplier) record
                        stock:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: 'The stock row (`warehouse_id`, `qty_onhand`, `qty_available`, ...)'
                        rfq:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: 'The product matched by `sku`, with `unit_of_measures` and `parent`. List responses only.'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Defective report not found.
  /receiving-reports:
    get:
      operationId: getReceivingReports
      tags:
        - Receiving Reports
      summary: Receiving reports
      description: |
        Get a paginated list of receiving reports with optional filtering.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### String Filters
        - `tracking_number`: Report tracking number
        - `received_by`: Name of person who received the shipment
        - `shipped_via`: Shipping carrier or method used

        ### DateTime Filters
        - `received_date`: When the shipment was received
        - `created_at`: When the report was created
        - `updated_at`: When the report was last updated

        ### Numeric Filters
        - `total_quantity`: Total quantity of items received
        - `total_cost`: Total cost including tax and shipping
        - `total_tax`: Tax amount
        - `shipping_cost`: Shipping cost

        ## Examples
        ```
        # Find all receiving reports with tracking numbers containing "TRACK"
        ?tracking_number[contains]=TRACK

        # Find reports received by specific person
        ?received_by[eq]=John Doe

        # Find reports shipped via specific carriers
        ?shipped_via[in]=FedEx,UPS

        # Find reports with dates and costs in ranges
        ?received_date[gt]=2024-01-01 00:00:00&total_cost[gte]=1000&shipping_cost[lt]=100

        # Find reports with specific quantity ranges
        ?total_quantity[gte]=150&total_quantity[lte]=250
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: tracking_number
          schema:
            type: string
          description: Filter by tracking number
        - in: query
          name: received_by
          schema:
            type: string
          description: Filter by receiver name
        - in: query
          name: shipped_via
          schema:
            type: string
          description: Filter by shipping carrier
        - in: query
          name: received_date
          schema:
            type: string
            format: date-time
          description: 'Filter by received date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: total_quantity
          schema:
            type: number
            format: float
          description: Filter by total quantity
        - in: query
          name: total_cost
          schema:
            type: number
            format: float
          description: Filter by total cost (including tax and shipping)
        - in: query
          name: total_tax
          schema:
            type: number
            format: float
          description: Filter by tax amount
        - in: query
          name: shipping_cost
          schema:
            type: number
            format: float
          description: Filter by shipping cost
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        status:
                          type: string
                        received_date:
                          type: string
                          format: date-time
                        tracking_number:
                          type: string
                        received_by:
                          type: string
                        received_at:
                          type: string
                          format: date-time
                          nullable: true
                        shipped_via:
                          type: string
                        total_quantity:
                          type: number
                        total_tax:
                          type: number
                        total_cost:
                          type: number
                        shipping_cost:
                          type: number
                        purchase_orders:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the purchase order
                              order_numbers:
                                type: array
                                description: List of purchase order numbers
                                items:
                                  type: string
                              created_by:
                                type: integer
                                nullable: true
                                description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                                example: 12
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the purchase order was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the purchase order was last updated
                              order_status:
                                type: string
                                enum:
                                  - active
                                  - inactive
                                  - deleted
                                description: Status of the purchase order
                              order_date:
                                type: string
                                format: date
                                description: Date when the purchase order was created
                              invoice_date:
                                type: string
                                format: date
                                description: Date when the purchase order was invoiced
                              arrival_due_date:
                                type: string
                                format: date
                                nullable: true
                                description: Expected arrival date for the order
                              requested_ship_date:
                                type: string
                                format: date
                                nullable: true
                                description: Requested shipping date
                              order_type:
                                type: integer
                                description: Type of the order
                              incoterm:
                                type: string
                                description: International Commercial Terms for the order
                              tracking_info:
                                type: string
                                nullable: true
                                description: Tracking information for the order
                              payment_terms:
                                type: string
                                description: Payment terms for the order
                              supplier_id:
                                type: integer
                                description: ID of the supplier
                              item_count:
                                type: integer
                                description: Number of unique items in the order
                              order_quantity:
                                type: integer
                                description: Total quantity of items
                              order_cost:
                                type: number
                                format: float
                                description: Cost of the order before tax and shipping
                              total_tax:
                                type: number
                                format: float
                                description: Total tax amount
                              total_shipping_cost:
                                type: number
                                format: float
                                description: Total shipping cost
                              total_cost:
                                type: number
                                format: float
                                description: Total cost including tax and shipping
                              total_paid:
                                type: number
                                format: float
                                description: Total amount paid
                              total_due:
                                type: number
                                format: float
                                description: Total amount due
                              down_payment:
                                type: number
                                format: float
                                description: Down payment amount
                              receipt_status:
                                type: string
                                nullable: true
                                enum:
                                  - awaiting_shipment
                                  - partially_received
                                  - fully_received
                                description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                              public_note:
                                type: string
                                nullable: true
                                description: Public notes
                              private_note:
                                type: string
                                nullable: true
                                description: Private notes
                              starred:
                                type: boolean
                                description: Whether the order is starred
                              supplier:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  status:
                                    type: integer
                                  name:
                                    type: string
                                  description:
                                    type: string
                                  street_address:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  zip:
                                    type: string
                                  country:
                                    type: string
                                  contact_name:
                                    type: string
                                  contact_email:
                                    type: string
                                  contact_phone:
                                    type: string
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              receiving_report_id:
                                type: integer
                              purchase_order_id:
                                type: integer
                              purchase_order_item_id:
                                type: integer
                              purchase_order_shipment_id:
                                type: integer
                                nullable: true
                              quantity:
                                type: number
                              unit:
                                type: string
                              unit_price:
                                type: number
                              tax:
                                type: number
                              discount_amount:
                                type: number
                              discount_percent:
                                type: number
                              line_total:
                                type: number
                              remarks:
                                type: string
                                nullable: true
                              stock_id:
                                type: integer
                              received_quantity:
                                type: number
                              base_unit_of_measure_id:
                                type: integer
                                nullable: true
                              received_unit_of_measure_id:
                                type: integer
                              location_id:
                                type: integer
                              lot_id:
                                type: integer
                                nullable: true
                        extra_costs:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              receiving_report_id:
                                type: integer
                              name:
                                type: string
                              quantity:
                                type: number
                              unit_price:
                                type: number
                              line_total:
                                type: number
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createReceivingReport
      tags:
        - Receiving Reports
      summary: Create a receiving report
      description: |
        Create a new receiving report, booking the received quantities against the
        referenced purchase order line items.

        **Warehouse assignment:** if the API user is assigned to specific warehouses (set
        per user in the app), every line's `warehouse_id` and `location_id` must be inside
        that assignment; otherwise `403` (`You are not assigned to this warehouse.`).

        **Idempotency:** creating a receiving report has an irreversible side effect —
        it increases received quantities and cannot be un-booked by a retry — so this
        endpoint supports the optional `Idempotency-Key` request header. Send the same
        key when retrying a call that timed out or whose response you never received,
        and the original stored response is replayed (carrying an `Idempotent-Replay:
        true` header) instead of booking the goods a second time. Reusing a key with a
        **different** request body is rejected with `409`. Keys are honored for replay
        for 24 hours. Omitting the header passes straight through with no idempotency
        guard.

        **Draft and cancelled purchase orders:** a purchase order in `Draft` or `Cancelled`
        status can't be received against. If any line item references such a PO, the whole
        request is refused with `400` before anything is written, e.g.
        `"Draft purchase order #123 can't be received. Mark the PO as Active first."`

        **Closed purchase-order lines:** a line that was closed short (see
        `PATCH /purchase-orders/{id}/items/{lineItemId}/closed`) can't be received against. If any
        line item references a closed PO line, the whole request is refused with `400` before
        anything is written, e.g. `"Line SKU-123 is closed and can't be received. Reopen the line
        first."` Reopen the line with `closed: false`, then retry the receipt.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: |
            Optional opt-in idempotency token. When supplied, a retry carrying the same
            key replays the original stored response (with an `Idempotent-Replay: true`
            header) instead of creating a second receiving report. Reusing the same key
            with a different request body returns `409`. Omit it to disable the guard for
            this request.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - received_date
                - items
              properties:
                received_date:
                  type: string
                  format: date
                tracking_number:
                  type: string
                received_by:
                  type: string
                received_at:
                  type: string
                  format: date-time
                shipped_via:
                  type: string
                items:
                  type: array
                  items:
                    type: object
                    required:
                      - purchase_order_id
                      - purchase_order_item_id
                      - quantity
                      - received_unit_of_measure_id
                      - location_id
                      - warehouse_id
                    properties:
                      purchase_order_shipment_id:
                        type: integer
                      purchase_order_id:
                        type: integer
                      purchase_order_item_id:
                        type: integer
                      quantity:
                        type: number
                      unit_price:
                        type: number
                      remarks:
                        type: string
                      received_unit_of_measure_id:
                        type: integer
                      location_id:
                        type: integer
                      lot_id:
                        type: integer
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number for the received item (used when the product has lot tracking enabled).
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
                      production_date:
                        type: string
                        format: date
                        nullable: true
                        description: Lot production date (YYYY-MM-DD).
                      expiry_date:
                        type: string
                        format: date
                        nullable: true
                        description: Lot expiry date (YYYY-MM-DD).
                      manufacturer_code:
                        type: string
                        nullable: true
                        description: Manufacturer code for the lot.
                      warehouse_id:
                        type: integer
                extra_costs:
                  type: array
                  items:
                    type: object
                    required:
                      - name
                      - quantity
                      - unit_price
                    properties:
                      name:
                        type: string
                      quantity:
                        type: number
                      unit_price:
                        type: number
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
                  status:
                    type: string
                  received_date:
                    type: string
                    format: date-time
                  tracking_number:
                    type: string
                  received_by:
                    type: string
                  received_at:
                    type: string
                    format: date-time
                    nullable: true
                  shipped_via:
                    type: string
                  total_quantity:
                    type: number
                  total_tax:
                    type: number
                  total_cost:
                    type: number
                  shipping_cost:
                    type: number
                  purchase_orders:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the purchase order
                        order_numbers:
                          type: array
                          description: List of purchase order numbers
                          items:
                            type: string
                        created_by:
                          type: integer
                          nullable: true
                          description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                          example: 12
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the purchase order was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the purchase order was last updated
                        order_status:
                          type: string
                          enum:
                            - active
                            - inactive
                            - deleted
                          description: Status of the purchase order
                        order_date:
                          type: string
                          format: date
                          description: Date when the purchase order was created
                        invoice_date:
                          type: string
                          format: date
                          description: Date when the purchase order was invoiced
                        arrival_due_date:
                          type: string
                          format: date
                          nullable: true
                          description: Expected arrival date for the order
                        requested_ship_date:
                          type: string
                          format: date
                          nullable: true
                          description: Requested shipping date
                        order_type:
                          type: integer
                          description: Type of the order
                        incoterm:
                          type: string
                          description: International Commercial Terms for the order
                        tracking_info:
                          type: string
                          nullable: true
                          description: Tracking information for the order
                        payment_terms:
                          type: string
                          description: Payment terms for the order
                        supplier_id:
                          type: integer
                          description: ID of the supplier
                        item_count:
                          type: integer
                          description: Number of unique items in the order
                        order_quantity:
                          type: integer
                          description: Total quantity of items
                        order_cost:
                          type: number
                          format: float
                          description: Cost of the order before tax and shipping
                        total_tax:
                          type: number
                          format: float
                          description: Total tax amount
                        total_shipping_cost:
                          type: number
                          format: float
                          description: Total shipping cost
                        total_cost:
                          type: number
                          format: float
                          description: Total cost including tax and shipping
                        total_paid:
                          type: number
                          format: float
                          description: Total amount paid
                        total_due:
                          type: number
                          format: float
                          description: Total amount due
                        down_payment:
                          type: number
                          format: float
                          description: Down payment amount
                        receipt_status:
                          type: string
                          nullable: true
                          enum:
                            - awaiting_shipment
                            - partially_received
                            - fully_received
                          description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                        public_note:
                          type: string
                          nullable: true
                          description: Public notes
                        private_note:
                          type: string
                          nullable: true
                          description: Private notes
                        starred:
                          type: boolean
                          description: Whether the order is starred
                        supplier:
                          type: object
                          properties:
                            id:
                              type: integer
                            status:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                            street_address:
                              type: string
                            city:
                              type: string
                            state:
                              type: string
                            zip:
                              type: string
                            country:
                              type: string
                            contact_name:
                              type: string
                            contact_email:
                              type: string
                            contact_phone:
                              type: string
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                  items:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        receiving_report_id:
                          type: integer
                        purchase_order_id:
                          type: integer
                        purchase_order_item_id:
                          type: integer
                        purchase_order_shipment_id:
                          type: integer
                          nullable: true
                        quantity:
                          type: number
                        unit:
                          type: string
                        unit_price:
                          type: number
                        tax:
                          type: number
                        discount_amount:
                          type: number
                        discount_percent:
                          type: number
                        line_total:
                          type: number
                        remarks:
                          type: string
                          nullable: true
                        stock_id:
                          type: integer
                        received_quantity:
                          type: number
                        base_unit_of_measure_id:
                          type: integer
                          nullable: true
                        received_unit_of_measure_id:
                          type: integer
                        location_id:
                          type: integer
                        lot_id:
                          type: integer
                          nullable: true
                  extra_costs:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        receiving_report_id:
                          type: integer
                        name:
                          type: string
                        quantity:
                          type: number
                        unit_price:
                          type: number
                        line_total:
                          type: number
        '400':
          description: |
            Request refused — for example, a line item references a purchase order in `Draft`
            or `Cancelled` status, or a purchase-order line that was closed short.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: 'Draft purchase order #123 can''t be received. Mark the PO as Active first.'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: |
            Idempotency conflict — the supplied `Idempotency-Key` is still being
            processed by an in-flight request, or has already been used with a
            different request body. The response body carries a machine-readable
            `code` of `idempotency_conflict` alongside the human-readable `message`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Human-readable explanation of the conflict
                  code:
                    type: string
                    enum:
                      - idempotency_conflict
                    description: Machine-readable conflict code
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/receiving-reports/items/{receivingReportItemId}/correct-quantity':
    post:
      operationId: correctReceivingReportItemQuantity
      tags:
        - Receiving Reports
      summary: Correct a posted receiving-report line quantity
      description: |
        Preview or apply a quantity correction for a **posted** receiving-report line, identified by its
        receiving-report *item* id.

        Rather than rewriting the receipt line, this posts an inventory **adjustment** beside the original
        receipt (it does not change the receiving-report line, the purchase-order `received_qty`, or peg
        `quantity_released`). Use `preview=true` first to measure the impact — including any fulfillment orders
        and pegs that may have over-released against the overstated receipt — before applying.

        **Decreases** (`correct_qty` < posted) peel the newest on-hand back off via a negative adjustment and
        require sufficient available on-hand to reverse. **Increases** (`correct_qty` > posted) only add
        on-hand; they do **not** advance PO received quantity, pegs, or receipt cost, so a second receiving
        report is preferred. Applying an increase therefore requires `confirm_shelf_only=true`.

        The accounting period for the current date must be open, and the receiving report must not be voided.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: receivingReportItemId
          required: true
          schema:
            type: integer
          description: Receiving report **item** (line) ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - correct_qty
              properties:
                correct_qty:
                  type: number
                  minimum: 0
                  description: |
                    The corrected quantity for the line, expressed in the same basis (base units) as the
                    line's `received_qty`. Must differ from the currently posted quantity.
                preview:
                  type: boolean
                  default: false
                  description: 'When `true`, measure the correction and its impact only — do not post the adjustment.'
                reason:
                  type: string
                  nullable: true
                  maxLength: 1000
                  description: Optional remarks stored on the adjustment.
                confirm_shelf_only:
                  type: boolean
                  default: false
                  description: |
                    Required (`true`) to **apply** an increase via adjustment, acknowledging that only on-hand
                    is corrected — PO received quantity, pegs, and receipt cost are not advanced. Ignored for
                    decreases.
                unit_cost:
                  type: number
                  nullable: true
                  minimum: 0
                  description: |
                    Override unit cost for the adjustment. Defaults to the receipt line's `unit_price` when
                    omitted. Chiefly relevant to positive (increase) adjustments, which may open a new cost layer.
      responses:
        '200':
          description: |
            Correction preview (`preview=true`) or the posted adjustment result. The `data` object reports the
            computed delta and the peg / fulfillment-order over-release impact; when applied it also includes
            the posted adjustment id and correction linkage.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                    description: Result message (e.g. "Quantity correction preview." or "Quantity correction adjustment posted.").
                  data:
                    type: object
                    properties:
                      receiving_report_id:
                        type: integer
                      receiving_report_item_id:
                        type: integer
                      posted_qty:
                        type: number
                        description: Quantity currently posted on the receipt line.
                      correct_qty:
                        type: number
                      delta:
                        type: number
                        description: '`correct_qty` minus `posted_qty` (negative for a decrease).'
                      direction:
                        type: string
                        enum:
                          - increase
                          - decrease
                      prefer_second_receiving_report:
                        type: boolean
                        description: 'True for increases, where a second receiving report is preferred over an adjustment.'
                      sku_id:
                        type: integer
                      warehouse_id:
                        type: integer
                      location_id:
                        type: integer
                      lot_id:
                        type: integer
                        nullable: true
                      unit_cost:
                        type: number
                        description: Resolved unit cost used for the adjustment.
                      uom_id:
                        type: integer
                        nullable: true
                        description: Base unit-of-measure id (falls back to the received UOM).
                      qty_log_transaction:
                        type: string
                      cost_layer_note:
                        type: string
                        description: Human-readable note on how cost layers are affected.
                      core_note:
                        type: string
                      confidence:
                        type: string
                        enum:
                          - high
                          - medium
                        description: '`medium` when multiple receiving reports exist against the PO, making over-release attribution approximate.'
                      warnings:
                        type: array
                        items:
                          type: string
                      void_and_re_receive_recommended:
                        type: boolean
                        description: 'True when a decrease is large or affects fulfillment orders, suggesting a void-and-re-receive instead.'
                      suspect_fulfillment_orders:
                        type: array
                        description: Fulfillment orders that may have over-released against the overstated receipt (decreases only).
                        items:
                          type: object
                          properties:
                            fulfillment_order_id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                            pushed_at:
                              type: string
                              nullable: true
                            is_pushed:
                              type: boolean
                            sales_order_id:
                              type: integer
                            over_released:
                              type: number
                            peg_ids:
                              type: array
                              items:
                                type: integer
                            can_safely_reverse:
                              type: boolean
                      suspect_pegs:
                        type: array
                        description: PO→FO allocation pegs that appear over-released against the corrected quantity (decreases only).
                        items:
                          type: object
                          properties:
                            peg_id:
                              type: integer
                            sales_order_id:
                              type: integer
                            sales_order_item_id:
                              type: integer
                            quantity_allocated:
                              type: number
                            quantity_released:
                              type: number
                            expected_released:
                              type: number
                            over_released:
                              type: number
                            fulfillment_order_id:
                              type: integer
                              nullable: true
                            can_safely_reverse:
                              type: boolean
                      preview:
                        type: boolean
                        description: Whether this response is a preview (no adjustment posted).
                      applied:
                        type: boolean
                        description: Whether the adjustment was posted.
                      adjustment_id:
                        type: integer
                        description: ID of the posted inventory adjustment. Present only when applied.
                      is_correction:
                        type: boolean
                        description: Present only when applied.
                      corrects_type:
                        type: string
                        description: Correction linkage type (receiving report). Present only when applied.
                      corrects_id:
                        type: integer
                        description: Receiving report id the correction is linked to. Present only when applied.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Cannot correct — e.g. item not found, receiving report voided, no stock/warehouse/location to adjust,
            correct quantity matches the posted quantity, insufficient on-hand to reverse a decrease, an increase
            without `confirm_shelf_only=true`, or the accounting period is closed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/receiving-reports/{id}':
    get:
      operationId: getSingleReceivingReport
      tags:
        - Receiving Reports
      summary: Single receiving report
      description: Get details of a specific receiving report by ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the receiving report to retrieve
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                      received_date:
                        type: string
                        format: date-time
                      tracking_number:
                        type: string
                      received_by:
                        type: string
                      received_at:
                        type: string
                        format: date-time
                        nullable: true
                      shipped_via:
                        type: string
                      total_quantity:
                        type: number
                      total_tax:
                        type: number
                      total_cost:
                        type: number
                      shipping_cost:
                        type: number
                      purchase_orders:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the purchase order
                            order_numbers:
                              type: array
                              description: List of purchase order numbers
                              items:
                                type: string
                            created_by:
                              type: integer
                              nullable: true
                              description: 'ID of the Luminous user who created the purchase order (the app''s **Created By**), or `null` when none was recorded. `POST /purchase-orders` records the user the API token belongs to (for an OAuth token, the user it was issued for); it is not accepted in the request body and `PUT` never changes it. Purchase orders created through the API before this field existed return `null`.'
                              example: 12
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the purchase order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the purchase order was last updated
                            order_status:
                              type: string
                              enum:
                                - active
                                - inactive
                                - deleted
                              description: Status of the purchase order
                            order_date:
                              type: string
                              format: date
                              description: Date when the purchase order was created
                            invoice_date:
                              type: string
                              format: date
                              description: Date when the purchase order was invoiced
                            arrival_due_date:
                              type: string
                              format: date
                              nullable: true
                              description: Expected arrival date for the order
                            requested_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: Requested shipping date
                            order_type:
                              type: integer
                              description: Type of the order
                            incoterm:
                              type: string
                              description: International Commercial Terms for the order
                            tracking_info:
                              type: string
                              nullable: true
                              description: Tracking information for the order
                            payment_terms:
                              type: string
                              description: Payment terms for the order
                            supplier_id:
                              type: integer
                              description: ID of the supplier
                            item_count:
                              type: integer
                              description: Number of unique items in the order
                            order_quantity:
                              type: integer
                              description: Total quantity of items
                            order_cost:
                              type: number
                              format: float
                              description: Cost of the order before tax and shipping
                            total_tax:
                              type: number
                              format: float
                              description: Total tax amount
                            total_shipping_cost:
                              type: number
                              format: float
                              description: Total shipping cost
                            total_cost:
                              type: number
                              format: float
                              description: Total cost including tax and shipping
                            total_paid:
                              type: number
                              format: float
                              description: Total amount paid
                            total_due:
                              type: number
                              format: float
                              description: Total amount due
                            down_payment:
                              type: number
                              format: float
                              description: Down payment amount
                            receipt_status:
                              type: string
                              nullable: true
                              enum:
                                - awaiting_shipment
                                - partially_received
                                - fully_received
                              description: PO-level receipt status rolled up from its lines (same value as the app's Receipt Status column). `awaiting_shipment` — nothing received yet ("Pending Receipt" in the app); `fully_received` — every line not closed short has received at least its ordered quantity (over-receipt counts); `partially_received` — anything else. Voided receipts don't count.
                            public_note:
                              type: string
                              nullable: true
                              description: Public notes
                            private_note:
                              type: string
                              nullable: true
                              description: Private notes
                            starred:
                              type: boolean
                              description: Whether the order is starred
                            supplier:
                              type: object
                              properties:
                                id:
                                  type: integer
                                status:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                street_address:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                zip:
                                  type: string
                                country:
                                  type: string
                                contact_name:
                                  type: string
                                contact_email:
                                  type: string
                                contact_phone:
                                  type: string
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            receiving_report_id:
                              type: integer
                            purchase_order_id:
                              type: integer
                            purchase_order_item_id:
                              type: integer
                            purchase_order_shipment_id:
                              type: integer
                              nullable: true
                            quantity:
                              type: number
                            unit:
                              type: string
                            unit_price:
                              type: number
                            tax:
                              type: number
                            discount_amount:
                              type: number
                            discount_percent:
                              type: number
                            line_total:
                              type: number
                            remarks:
                              type: string
                              nullable: true
                            stock_id:
                              type: integer
                            received_quantity:
                              type: number
                            base_unit_of_measure_id:
                              type: integer
                              nullable: true
                            received_unit_of_measure_id:
                              type: integer
                            location_id:
                              type: integer
                            lot_id:
                              type: integer
                              nullable: true
                      extra_costs:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            receiving_report_id:
                              type: integer
                            name:
                              type: string
                            quantity:
                              type: number
                            unit_price:
                              type: number
                            line_total:
                              type: number
        '404':
          description: Receiving report not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /sales-orders:
    get:
      operationId: getSalesOrders
      tags:
        - Sales Orders
      summary: Sales orders
      description: |
        Get a paginated list of sales orders with optional filtering.

        <Note>
        **Syncing sales order data?** Use [`GET /sales-orders/export`](/api-reference/sales-orders/export-sales-orders)
        instead. The export endpoint uses cursor-based pagination with a fixed time window, making it
        significantly more reliable for incremental sync workflows than polling this list endpoint.
        </Note>

        <Note>
        **Need to re-pull an order's data from its source channel?** Use [`POST /sales-orders/bulk-refresh`](/api-reference/sales-orders/bulk-refresh-sales-orders)
        with body `{ "salesOrderIds": [id] }`. Pass a single ID to refresh one order; up to 100 IDs per request.
        </Note>

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### String Filters
        - `order_number`: Order reference number
        - `order_status`: Order status
        - `tag`: Order tags

        ### Date Filters
        - `order_date`: Date the order was placed
        - `ship_date`: Date the order was shipped

        ### DateTime Filters
        - `created_at`: When the order was created
        - `updated_at`: When the order was last updated

        ### Numeric Filters
        - `total_quantity`: Total number of items
        - `total`: Order total amount
        - `total_shipping`: Shipping cost
        - `total_tax`: Tax amount
        - `total_paid`: Amount paid

        ### Integer Filters
        - `channel_id`: Filter by the sales channel the order was received on

        ### Ship-To Address Filters
        Filter on the order's shipping address (matched against the source shipTo JSON).
        - `ship_to.state`: Ship-to state/province (full name as stored on the order, e.g. `California`)
        - `ship_to.state_code`: Ship-to state/province code, falling back to the state value when no code is stored (e.g. `CA`)

        On large tenants, combine ship-to filters with a date filter (e.g. `created_at`) — the shipping address is not indexed.

        ### Line Item Filters
        - `item.tag`: Filter by sales orders containing line items with a specific tag

        ### Line Item Product Filters
        Product filters allow you to filter by sales orders with line items connected to a specific product or set of products.
        #### String Filters
        - `product.name`: Filter by line item product name
        - `product.description`: Filter by line item product description
        - `product.sku`: Filter by line item product SKU (searches both internal SKU and alternate SKUs)
        - `product.upc`: Filter by line item product UPC/Barcode
        - `product.tag`: Filter by line item product tags
        - `product.category.name`: Filter by line item product category name
        - `product.sub_category.name`: Filter by line item product sub-category name
        - `product.supplier.name`: Filter by line item product supplier name

        #### Integer Filters
        - `product.id`: Filter by line item product ID
        - `product.category.id`: Filter by line item product category ID
        - `product.sub_category.id`: Filter by line item product sub-category ID
        - `product.supplier.id`: Filter by line item product supplier ID

        #### Float Filters
        - `product.retail_price`: Filter by line item product retail price
        - `product.wholesale_price`: Filter by line item product wholesale price

        #### Boolean Filters
        - `product.sellable`: Filter by line item product sellable status
        - `product.discontinued`: Filter by whether the line item product is discontinued

        ## Examples
        ```
        # Find orders over $500 created this year
        ?total[gt]=500.00&created_at[gte]=2024-01-01 00:00:00

        # Find recent urgent orders
        ?tag[eq]=urgent&created_at[gte]=2024-10-25 00:00:00

        # Find orders with specific shipping costs
        ?total_shipping[gte]=10.00&total_shipping[lte]=50.00

        # Find orders containing a specific product SKU
        ?product.sku[eq]=SKU-123

        # Find orders with discontinued products
        ?product.discontinued[eq]=true

        # Find orders with products from a specific supplier
        ?product.supplier.name[contains]=Acme

        # Find a sales order containing a line item with a specific tag
        ?item.tag[eq]=urgent
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: fields
          schema:
            type: string
          description: 'Comma-separated list of fields to include in each returned sales order (field projection). When omitted, the full sales order object is returned. Example: `fields=id,order_number,status`.'
        - in: query
          name: include_product
          schema:
            type: boolean
            default: true
          description: 'When `false`, line items omit the nested `product` object (and the product is not loaded), which makes responses smaller and faster. `product_id` and the other line fields stay.'
        - in: query
          name: company_id
          schema:
            type: integer
          description: Filter by the ID of the company (business account) the order belongs to
        - in: query
          name: customer_id
          schema:
            type: integer
          description: Filter by the order's customer ID
        - in: query
          name: channel_id
          schema:
            type: integer
          description: Filter by the sales channel the order was received on
        - in: query
          name: ship_to.state
          schema:
            type: string
          description: 'Filter by ship-to state/province (full name as stored on the order, e.g. `California`). Matched against the source shipTo JSON; combine with a date filter on large tenants.'
        - in: query
          name: ship_to.state_code
          schema:
            type: string
          description: 'Filter by ship-to state/province code (e.g. `CA`), falling back to the state value when no code is stored on the order.'
        - in: query
          name: order_number
          schema:
            type: string
          description: Filter by order number
        - in: query
          name: order_status
          schema:
            type: string
          description: Filter by order status
        - in: query
          name: order_date
          schema:
            type: string
            format: date
          description: Filter by order date (YYYY-MM-DD)
        - in: query
          name: ship_date
          schema:
            type: string
            format: date
          description: Filter by ship date (YYYY-MM-DD)
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: total_quantity
          schema:
            type: number
          description: Filter by total order quantity
        - in: query
          name: total
          schema:
            type: number
          description: Filter by order total amount
        - in: query
          name: total_shipping
          schema:
            type: number
          description: Filter by shipping amount
        - in: query
          name: total_tax
          schema:
            type: number
          description: Filter by tax amount
        - in: query
          name: total_paid
          schema:
            type: number
          description: Filter by amount paid
        - in: query
          name: requested_shipping_service
          schema:
            type: string
          description: Filter by requested shipping service
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by tags
        - in: query
          name: item.tag
          schema:
            type: string
          description: Filter by sales orders containing line items with specific tags
        - in: query
          name: product.name
          schema:
            type: string
          description: Filter by line item product name
        - in: query
          name: product.description
          schema:
            type: string
          description: Filter by line item product description
        - in: query
          name: product.sku
          schema:
            type: string
          description: Filter by line item product SKU (searches both internal and alternate SKUs)
        - in: query
          name: product.upc
          schema:
            type: string
          description: Filter by line item product UPC/Barcode
        - in: query
          name: product.tag
          schema:
            type: string
          description: Filter by line item product tags
        - in: query
          name: product.category.name
          schema:
            type: string
          description: Filter by line item product category name
        - in: query
          name: product.sub_category.name
          schema:
            type: string
          description: Filter by line item product sub-category name
        - in: query
          name: product.supplier.name
          schema:
            type: string
          description: Filter by line item product supplier name
        - in: query
          name: product.id
          schema:
            type: string
          description: Filter by line item product ID
        - in: query
          name: product.category.id
          schema:
            type: integer
          description: Filter by line item product category ID
        - in: query
          name: product.sub_category.id
          schema:
            type: integer
          description: Filter by line item product sub-category ID
        - in: query
          name: product.supplier.id
          schema:
            type: integer
          description: Filter by line item product supplier ID
        - in: query
          name: product.retail_price
          schema:
            type: number
            format: float
          description: Filter by line item product retail price
        - in: query
          name: product.wholesale_price
          schema:
            type: number
            format: float
          description: Filter by line item product wholesale price
        - in: query
          name: product.sellable
          schema:
            type: boolean
          description: Filter by line item product sellable status
        - in: query
          name: product.discontinued
          schema:
            type: boolean
          description: Filter by whether the line item product is discontinued
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the sales order
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the order was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the order was last updated
                        status:
                          type: string
                          description: Current status of the order
                        order_id:
                          type: string
                          description: External order identifier
                        order_number:
                          type: string
                          description: Order number
                        order_date:
                          type: string
                          format: date
                          description: Date when the order was placed
                        payment_date:
                          type: string
                          format: date
                          description: Date when payment was received
                        ship_by_date:
                          type: string
                          format: date
                          description: Required ship by date
                        age:
                          type: integer
                          description: Age of the order in days
                        order_status:
                          type: string
                          description: Status of the order
                        customer_id:
                          type: string
                          description: Customer identifier
                        customer_username:
                          type: string
                          description: Customer's username
                        customer_email:
                          type: string
                          description: Customer's email address
                        bill_to:
                          type: object
                          description: Billing information
                        ship_to:
                          type: object
                          description: Shipping information
                        requested_shipping_service:
                          type: string
                          nullable: true
                          description: What shipping service to use when shipping this order
                        total:
                          type: number
                          format: float
                          description: Total order amount
                        total_paid:
                          type: number
                          format: float
                          description: Amount paid
                        total_tax:
                          type: number
                          format: float
                          description: Total tax amount
                        total_shipping:
                          type: number
                          format: float
                          description: Total shipping amount
                        customer_notes:
                          type: string
                          description: Notes from the customer
                        internal_notes:
                          type: string
                          description: Internal notes
                        ship_date:
                          type: string
                          format: date
                          description: Date when order was shipped
                        hold_until_date:
                          type: string
                          format: date
                          description: Hold until date
                        earliest_ship_date:
                          type: string
                          format: date
                          nullable: true
                          description: Earliest date the order can be shipped
                        user_id:
                          type: integer
                          description: User ID associated with the order
                        externally_fulfilled:
                          type: boolean
                          description: Whether the order is fulfilled externally
                        externally_fulfilled_by:
                          type: string
                          description: Entity fulfilling the order externally
                        is_posted:
                          type: boolean
                          description: Whether the order is posted
                        posted_by:
                          type: string
                          description: User who posted the order
                        not_sync:
                          type: boolean
                          description: Sync status
                        sales_posted:
                          type: boolean
                          description: Sales posting status
                        split_order:
                          type: boolean
                          description: Whether the order is split
                        skip_inventory:
                          type: boolean
                          description: Whether to skip inventory
                        skip_sales_report:
                          type: boolean
                          description: Whether to skip sales report
                        channel_id:
                          type: integer
                          description: Channel identifier
                        total_order_cost:
                          type: number
                          format: float
                          description: Total cost of order
                        total_order_quantity:
                          type: number
                          format: float
                          description: Total quantity of items
                        order_cost_details:
                          type: object
                          description: Detailed order cost information
                        source:
                          type: string
                          description: Order source
                        shipstation_order_id:
                          type: string
                          description: ShipStation order identifier
                        type:
                          type: string
                          description: Order type
                        parent_id:
                          type: integer
                          description: Parent order ID if applicable
                        shipping_revenue:
                          type: number
                          format: float
                          description: Revenue from shipping
                        product_total:
                          type: number
                          format: float
                          description: Total product amount
                        total_discount:
                          type: number
                          format: float
                          description: Total discount amount
                        picking_status:
                          type: string
                          description: Status of picking process
                        starred_description:
                          type: string
                          description: Description for starred orders
                        customer_po_number:
                          type: string
                          description: Customer PO number
                        company_id:
                          type: integer
                          nullable: true
                          description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                          example: 123
                        company:
                          nullable: true
                          description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the company
                              example: 123456
                            created_at:
                              type: string
                              format: date-time
                              description: When the company was created
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              description: When the company was last updated
                              example: '2023-03-15T14:30:00Z'
                            status:
                              type: string
                              description: Status of the company
                              enum:
                                - active
                                - inactive
                              example: active
                            name:
                              type: string
                              description: Company name
                              example: Acme Corporation
                            type:
                              type: string
                              nullable: true
                              description: Type of business
                              example: Retail
                            phone:
                              type: string
                              nullable: true
                              description: Primary phone number for the company
                              example: 555-123-4567
                            address:
                              type: string
                              nullable: true
                              description: Street address for the company
                              example: 123 Main St
                            address_line_2:
                              type: string
                              nullable: true
                              description: Additional address information
                              example: Suite 500
                            city:
                              type: string
                              nullable: true
                              description: City
                              example: Austin
                            state:
                              type: string
                              nullable: true
                              description: State/province
                              example: TX
                            postal_code:
                              type: string
                              nullable: true
                              description: Postal/ZIP code
                              example: '78701'
                            country:
                              type: string
                              nullable: true
                              description: Country
                              example: USA
                            full_address:
                              type: string
                              nullable: true
                              description: Complete formatted address
                              example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                            shipping_first_name:
                              type: string
                              nullable: true
                              description: First name for shipping contact (legacy field)
                              example: John
                            shipping_last_name:
                              type: string
                              nullable: true
                              description: Last name for shipping contact (legacy field)
                              example: Doe
                            shipping_email:
                              type: string
                              format: email
                              nullable: true
                              description: Email for shipping contact (legacy field)
                              example: shipping@acmecorp.com
                            shipping_phone:
                              type: string
                              nullable: true
                              description: Phone number for shipping contact (legacy field)
                              example: 555-987-6543
                            shipping_address:
                              type: string
                              nullable: true
                              description: Shipping street address (legacy field)
                              example: 456 Warehouse Blvd
                            shipping_city:
                              type: string
                              nullable: true
                              description: Shipping city (legacy field)
                              example: Austin
                            shipping_state:
                              type: string
                              nullable: true
                              description: Shipping state/province (legacy field)
                              example: TX
                            shipping_postal_code:
                              type: string
                              nullable: true
                              description: Shipping postal/ZIP code (legacy field)
                              example: '78745'
                            shipping_country:
                              type: string
                              nullable: true
                              description: Shipping country (legacy field)
                              example: USA
                            shipping_full_address:
                              type: string
                              nullable: true
                              description: Complete formatted shipping address (legacy field)
                              example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                            payment_term:
                              type: string
                              nullable: true
                              description: Payment terms for the company
                              example: Net 30
                            tax_exempt:
                              type: boolean
                              nullable: true
                              description: Whether the company is exempt from taxes
                              example: false
                            tax_rate:
                              type: number
                              format: float
                              nullable: true
                              description: Tax rate applied to the company's orders
                              example: 8.25
                            due_date_days:
                              type: integer
                              nullable: true
                              description: Number of days until payment is due
                              example: 30
                            credit_limit:
                              type: number
                              format: float
                              nullable: true
                              description: Credit limit for the company. `null` means no limit is set.
                              example: 5000
                            header_discount_enabled:
                              type: boolean
                              description: Whether an order-header trade discount is applied by default for this company
                              example: false
                            header_discount_type:
                              type: string
                              nullable: true
                              enum:
                                - PERCENT
                                - FIXED_AMOUNT
                              description: How the header discount is calculated — a percentage of the order or a fixed amount
                              example: PERCENT
                            header_discount_value:
                              type: number
                              format: float
                              nullable: true
                              description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                              example: 5
                            header_discount_effective_from:
                              type: string
                              format: date
                              nullable: true
                              description: Date from which the header discount takes effect (YYYY-MM-DD)
                              example: '2026-01-01'
                            default_currency_code:
                              type: string
                              nullable: true
                              description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                              example: USD
                            price_level:
                              nullable: true
                              description: Price level associated with this company
                              type: object
                              properties:
                                id:
                                  type: number
                                  description: Unique identifier for the price level
                                  example: 123
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the price level was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the price level was last updated
                                  example: '2023-03-15T14:30:00Z'
                                status:
                                  type: string
                                  description: Status of the price level
                                  enum:
                                    - active
                                    - inactive
                                  example: active
                                name:
                                  type: string
                                  description: Name of the price level
                                  example: Wholesale
                                type:
                                  type: string
                                  description: Type of the price level
                                  example: percentage
                                percent_increase:
                                  type: number
                                  format: float
                                  description: Percentage increase (or decrease) for this price level
                                  example: 15.5
                            notes:
                              type: string
                              nullable: true
                              description: Additional notes about the company
                              example: 'Key account, requires special handling'
                            fein:
                              type: string
                              nullable: true
                              description: Federal Employer Identification Number
                              example: 12-3456789
                            tags:
                              type: array
                              nullable: true
                              description: List of tags associated with the company
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the tag
                                  name:
                                    type: string
                                    description: Name of the tag
                                  description:
                                    type: string
                                    nullable: true
                                    description: Description of the tag
                                  icon:
                                    type: string
                                    nullable: true
                                    description: Icon identifier or URL for the tag
                                  color:
                                    type: string
                                    nullable: true
                                    description: Color code for the tag
                                required:
                                  - id
                                  - name
                            default_shipping:
                              nullable: true
                              description: Default shipping address
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the shipping address
                                  example: 789
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was last updated
                                  example: '2023-03-15T14:30:00Z'
                                company_id:
                                  type: integer
                                  description: ID of the company this shipping address belongs to
                                  example: 123456
                                company_name:
                                  type: string
                                  nullable: true
                                  description: Name of the company
                                  example: Acme Corporation
                                address:
                                  type: string
                                  description: Street address
                                  example: 456 Warehouse Blvd
                                address_line_2:
                                  type: string
                                  nullable: true
                                  description: Additional address information
                                  example: Building 2
                                city:
                                  type: string
                                  description: City
                                  example: Austin
                                state:
                                  type: string
                                  description: State/province
                                  example: TX
                                postal_code:
                                  type: string
                                  description: Postal/ZIP code
                                  example: '78745'
                                country:
                                  type: string
                                  description: Country
                                  example: USA
                                full_address:
                                  type: string
                                  description: Complete formatted address
                                  example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                full_name:
                                  type: string
                                  description: Full name of the contact person
                                  example: John Doe
                                first_name:
                                  type: string
                                  nullable: true
                                  description: First name of the contact person
                                  example: John
                                last_name:
                                  type: string
                                  nullable: true
                                  description: Last name of the contact person
                                  example: Doe
                                phone:
                                  type: string
                                  nullable: true
                                  description: Phone number
                                  example: 555-987-6543
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  description: Email address
                                  example: shipping@acmecorp.com
                                is_default:
                                  type: boolean
                                  description: Whether this is the default shipping address
                                  example: true
                              required:
                                - id
                                - company_id
                                - address
                                - city
                                - state
                                - postal_code
                                - country
                            shipping_addresses:
                              type: array
                              nullable: true
                              description: List of shipping addresses for the company
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the shipping address
                                    example: 789
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: When the shipping address was created
                                    example: '2023-03-15T14:30:00Z'
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: When the shipping address was last updated
                                    example: '2023-03-15T14:30:00Z'
                                  company_id:
                                    type: integer
                                    description: ID of the company this shipping address belongs to
                                    example: 123456
                                  company_name:
                                    type: string
                                    nullable: true
                                    description: Name of the company
                                    example: Acme Corporation
                                  address:
                                    type: string
                                    description: Street address
                                    example: 456 Warehouse Blvd
                                  address_line_2:
                                    type: string
                                    nullable: true
                                    description: Additional address information
                                    example: Building 2
                                  city:
                                    type: string
                                    description: City
                                    example: Austin
                                  state:
                                    type: string
                                    description: State/province
                                    example: TX
                                  postal_code:
                                    type: string
                                    description: Postal/ZIP code
                                    example: '78745'
                                  country:
                                    type: string
                                    description: Country
                                    example: USA
                                  full_address:
                                    type: string
                                    description: Complete formatted address
                                    example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                  full_name:
                                    type: string
                                    description: Full name of the contact person
                                    example: John Doe
                                  first_name:
                                    type: string
                                    nullable: true
                                    description: First name of the contact person
                                    example: John
                                  last_name:
                                    type: string
                                    nullable: true
                                    description: Last name of the contact person
                                    example: Doe
                                  phone:
                                    type: string
                                    nullable: true
                                    description: Phone number
                                    example: 555-987-6543
                                  email:
                                    type: string
                                    format: email
                                    nullable: true
                                    description: Email address
                                    example: shipping@acmecorp.com
                                  is_default:
                                    type: boolean
                                    description: Whether this is the default shipping address
                                    example: true
                                required:
                                  - id
                                  - company_id
                                  - address
                                  - city
                                  - state
                                  - postal_code
                                  - country
                            billing_info:
                              type: object
                              nullable: true
                              description: Billing information
                              properties:
                                id:
                                  type: integer
                                  example: 456
                                created_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                first_name:
                                  type: string
                                  nullable: true
                                  example: Jane
                                last_name:
                                  type: string
                                  nullable: true
                                  example: Smith
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  example: accounting@acmecorp.com
                                receiving_bank_name:
                                  type: string
                                  nullable: true
                                  example: First National Bank
                                receiving_bank_address:
                                  type: string
                                  nullable: true
                                  example: '789 Finance Street, Austin, TX 78701'
                            client_type:
                              type: object
                              nullable: true
                              description: Type of client
                              properties:
                                id:
                                  type: integer
                                  example: 123
                                created_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                name:
                                  type: string
                                  example: Retail
                                description:
                                  type: string
                                  nullable: true
                                  example: Retail business client
                            parent_company_id:
                              type: integer
                              nullable: true
                              description: ID of the parent company
                              example: 456
                            invoice_export_template_id:
                              type: integer
                              nullable: true
                              description: ID of the invoice export template
                              example: 789
                            custom_fields:
                              type: object
                              description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              example:
                                Industry: Manufacturing
                                Region: Southwest
                                Annual Revenue: $5M-$10M
                            assigned_sales_reps:
                              type: array
                              description: |
                                Sales rep users assigned to this company (Go Team members). Resolved from the company's
                                `goTeamMember.user` relation. Only present when the relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: User ID of the assigned sales rep
                                    example: 42
                                  email:
                                    type: string
                                    description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                    example: rep@example.com
                                  first_name:
                                    type: string
                                    nullable: true
                                    example: Jane
                                  last_name:
                                    type: string
                                    nullable: true
                                    example: Doe
                            sales_channel:
                              allOf:
                                - type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Sales channel ID.
                                    status:
                                      type: string
                                      description: Sales channel status (e.g. active).
                                    label:
                                      type: string
                                      nullable: true
                                      description: Human-readable channel label.
                                    channel_type:
                                      type: string
                                      nullable: true
                                      description: Channel type (e.g. the integration/platform the channel represents).
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                              nullable: true
                              description: The company's default sales channel. Only present when the relation is loaded.
                          required:
                            - id
                            - name
                            - status
                        custom_fields:
                          type: object
                          description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties:
                            type: string
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the order item
                              line_number:
                                type: integer
                                description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                              created_at:
                                type: string
                                format: date-time
                                description: Creation timestamp
                              updated_at:
                                type: string
                                format: date-time
                                description: Last update timestamp
                              sku:
                                type: string
                                description: Stock keeping unit
                              name:
                                type: string
                                description: Product name
                              image_url:
                                type: string
                                description: URL of product image
                              weight:
                                type: object
                                description: Weight information
                              quantity:
                                type: number
                                format: float
                                description: Ordered quantity
                              unit_price:
                                type: number
                                format: float
                                description: Price per unit
                              tax:
                                type: number
                                format: float
                                description: Tax amount
                              shipping:
                                type: number
                                format: float
                                description: Shipping amount
                              warehouse_location:
                                type: string
                                description: Location in warehouse
                              options:
                                type: object
                                description: Additional options
                              fulfillment_sku:
                                type: string
                                description: SKU used for fulfillment
                              adjustment:
                                type: number
                                format: float
                                description: Price adjustment
                              upc:
                                type: string
                                description: Universal Product Code
                              stock_id:
                                type: integer
                                description: Stock identifier
                              kit_id:
                                type: integer
                                description: Kit identifier if part of a kit
                              non_physical_item:
                                type: boolean
                                description: Whether item is non-physical
                              ignore_item:
                                type: boolean
                                description: Whether to ignore this item
                              is_locally_added:
                                type: boolean
                                description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                              quantity_shipped:
                                type: number
                                format: float
                                description: Quantity shipped
                              quantity_cancelled:
                                type: number
                                format: float
                                description: Quantity cancelled
                              quantity_invoiced:
                                type: number
                                format: float
                                description: Quantity invoiced
                              quantity_ordered:
                                type: number
                                format: float
                                description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                              base_uom_id:
                                type: integer
                                description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                              ordered_uom_id:
                                type: integer
                                description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                              product_id:
                                type: integer
                                description: Product identifier
                              total_returned_base_quantity:
                                type: number
                                format: float
                                description: Total quantity returned
                              parent_id:
                                type: integer
                                description: Parent item ID
                              status:
                                type: string
                                description: Item status
                              discount:
                                type: number
                                format: float
                                description: Discount amount
                              estimated_ship_date:
                                type: string
                                format: date
                                description: Estimated shipping date
                              custom_fields:
                                type: object
                                description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties:
                                  type: string
                              product:
                                type: object
                                description: Product information
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the product
                                  name:
                                    type: string
                                    description: Product name
                                  description:
                                    type: string
                                    nullable: true
                                    description: Product description
                                  retail_price:
                                    type: number
                                    format: float
                                    description: Retail price
                                  wholesale_price:
                                    type: number
                                    format: float
                                    description: Wholesale price
                                  unit_cost:
                                    type: number
                                    format: float
                                    description: Cost per unit
                                  product_weight:
                                    type: number
                                    format: float
                                    description: Weight of the product
                                  product_length:
                                    type: number
                                    format: float
                                    description: Length of the product (in inches)
                                  product_width:
                                    type: number
                                    format: float
                                    description: Width of the product (in inches)
                                  product_height:
                                    type: number
                                    format: float
                                    description: Height of the product (in inches)
                                  sellable:
                                    type: boolean
                                    description: Whether the product can be sold
                                  discontinued:
                                    type: boolean
                                    description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                  image_url:
                                    type: string
                                    nullable: true
                                    description: URL to the product's main image
                                  category:
                                    type: object
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                    description: Product category information
                                  subcategory:
                                    type: object
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                    description: Product subcategory information
                                  custom_fields:
                                    type: object
                                    description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                    additionalProperties:
                                      type: string
                                  variant_attributes:
                                    type: object
                                    nullable: true
                                    description: Available variant attributes
                                  sku:
                                    type: string
                                    description: Internal SKU
                                  alternate_skus:
                                    type: array
                                    description: Alternate SKUs
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                        sku:
                                          type: string
                                  upc:
                                    type: string
                                    description: UPC/Barcode
                                  tags:
                                    type: array
                                    description: Tags associated with the product
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the tag
                                        name:
                                          type: string
                                          description: Name of the tag
                                        description:
                                          type: string
                                          nullable: true
                                          description: Description of the tag
                                        icon:
                                          type: string
                                          nullable: true
                                          description: Icon identifier or URL for the tag
                                        color:
                                          type: string
                                          nullable: true
                                          description: Color code for the tag
                                      required:
                                        - id
                                        - name
                                  supplier:
                                    type: object
                                    nullable: true
                                    description: Supplier information
                                  type:
                                    type: string
                                    enum:
                                      - PRODUCT
                                      - KIT
                                    description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                  kit_items:
                                    type: array
                                    nullable: true
                                    description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the kit item
                                        product_id:
                                          type: integer
                                          description: ID of the product component
                                        quantity:
                                          type: number
                                          format: float
                                          description: Quantity of this component in the kit
                                        uom_id:
                                          type: integer
                                          description: Unit of measure ID for the quantity
                                        base_uom_quantity:
                                          type: number
                                          format: float
                                          description: Quantity converted to base unit of measure
                                        price:
                                          type: number
                                          format: float
                                          description: Price for this kit item
                                        original_price:
                                          type: number
                                          format: float
                                          description: Original price for this kit item
                                        total:
                                          type: number
                                          format: float
                                          description: Calculated total (quantity * price)
                                        product:
                                          type: object
                                          nullable: true
                                          description: Product information for this kit item (when loaded)
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                            sku:
                                              type: string
                                            description:
                                              type: string
                                              nullable: true
                                            retail_price:
                                              type: number
                                              format: float
                                            wholesale_price:
                                              type: number
                                              format: float
                                        unit_of_measure:
                                          type: object
                                          nullable: true
                                          description: Unit of measure information (when loaded)
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                            description:
                                              type: string
                                              nullable: true
                                            base_unit:
                                              type: boolean
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was last updated
                              tags:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    description:
                                      type: string
                                    icon:
                                      type: string
                                    color:
                                      type: string
                                    discount_structure:
                                      type: object
                                    markup_structure:
                                      type: object
                                description: Tags associated with the sales order item
                          description: Line items in the order
                        fulfillment_orders:
                          type: array
                          description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Fulfillment order ID
                              order_number:
                                type: string
                                description: Fulfillment order number
                              order_key:
                                type: string
                                nullable: true
                                description: Fulfillment order key
                              order_status:
                                type: string
                                description: Fulfillment order status
                              sales_order_id:
                                type: integer
                                description: Associated sales order ID
                              warehouse_group_id:
                                type: integer
                                nullable: true
                                description: Warehouse group ID
                              destination_oms_id:
                                type: integer
                                nullable: true
                                description: Destination app integration account ID
                              destination_oms_store_id:
                                type: integer
                                nullable: true
                              fulfillment_channel_id:
                                type: integer
                                nullable: true
                              pushed_at:
                                type: string
                                format: date-time
                                nullable: true
                              packing_slip_printed_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                              error_message:
                                type: string
                                nullable: true
                                description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                              ship_by_date:
                                type: string
                                format: date
                                nullable: true
                                description: Ship by date
                              total:
                                type: number
                                format: float
                                nullable: true
                                description: Order total
                              bill_to:
                                type: object
                                nullable: true
                                description: Billing address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              ship_to:
                                type: object
                                nullable: true
                                description: Shipping address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              invoice_to:
                                type: object
                                nullable: true
                                description: Invoice address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              sales_order:
                                type: object
                                nullable: true
                                description: Nested sales order data
                              picklists:
                                type: array
                                description: Associated picklists
                                items:
                                  type: object
                              fulfillment_order_items:
                                type: array
                                description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      nullable: true
                                      description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                    shipment_id:
                                      type: integer
                                      nullable: true
                                      description: ID of the fulfillment order this line belongs to.
                                    status:
                                      nullable: true
                                      description: Line status.
                                    sales_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                    sku:
                                      type: string
                                      nullable: true
                                    name:
                                      type: string
                                      nullable: true
                                    weight:
                                      nullable: true
                                      description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                    dimensions:
                                      nullable: true
                                      description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                    quantity:
                                      type: number
                                      description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                    unit_price:
                                      type: number
                                      description: Unit price. Always `0` on synthetic component rows.
                                    lot_id:
                                      type: integer
                                      nullable: true
                                    lot_number:
                                      type: string
                                      nullable: true
                                    expiry_date:
                                      type: string
                                      nullable: true
                                      description: Lot expiry date.
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    is_kit_component:
                                      type: boolean
                                      description: True when the row is a component of a kit (stored or synthetic).
                                    parent_fulfillment_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                    kit_sales_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                    is_synthetic:
                                      type: boolean
                                      description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                              total_weight:
                                type: object
                                nullable: true
                                description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                                properties:
                                  total_oz:
                                    type: number
                                    format: float
                                    description: Total weight in ounces
                                  total_lb:
                                    type: number
                                    format: float
                                    description: Total weight in pounds
                                  line_count:
                                    type: integer
                                    description: Number of fulfillment order lines
                                  weighed_line_count:
                                    type: integer
                                    description: Number of lines that had a usable weight and contributed to the total
                                  is_complete:
                                    type: boolean
                                    description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                              tags:
                                type: array
                                description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the tag
                                    name:
                                      type: string
                                      description: Name of the tag
                                    description:
                                      type: string
                                      nullable: true
                                      description: Description of the tag
                                    icon:
                                      type: string
                                      nullable: true
                                      description: Icon identifier or URL for the tag
                                    color:
                                      type: string
                                      nullable: true
                                      description: Color code for the tag
                                  required:
                                    - id
                                    - name
                              purchase_orders:
                                type: array
                                description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    order_status:
                                      type: string
                                      nullable: true
                                      enum:
                                        - active
                                        - deleted
                                        - completed
                              source_reference_identifier:
                                type: string
                                nullable: true
                                description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                              held_for_item_change:
                                type: boolean
                                description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                              created_at:
                                type: string
                                format: date-time
                                description: When the fulfillment order was created
                              updated_at:
                                type: string
                                format: date-time
                                description: When the fulfillment order was last updated
                        tags:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                              icon:
                                type: string
                              color:
                                type: string
                              discount_structure:
                                type: object
                              markup_structure:
                                type: object
                          description: Tags associated with the order
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createSalesOrder
      tags:
        - Sales Orders
      summary: Create a new sales order
      description: |
        Create a new sales order with items, addresses, and optional metadata.

        ## Key Features
        - Create orders with multiple line items
        - Support for both product ID and SKU lookup for items
        - Automatic product name and details population
        - Flexible address handling (only name required)
        - Optional company association - when `company_id` is provided, addresses are auto-populated
        - Optional custom fields and tags at both order and order item level
        - Automatic total calculation from line items plus tax/shipping

        ## Order Number
        `order_number` is optional. Supply your own unique value to keep it, or omit it (or send `null` /
        `""`) and Luminous assigns `LUM-{id}` after the order is saved. Channels configured with an
        order-number prefix assign `{prefix}{n}` from that channel's sequence instead. The assigned
        value is returned as `order_number` in the response.

        ## Product Identification
        For each line item, you must provide either:
        - `product_id`: The internal product ID
        - `sku`: The product SKU (supports both internal SKU and alternate SKUs)

        ## Order Status Values
        Valid order statuses include: `pending`, `shipped`, `fulfilled`, `cancelled`, 
        `awaiting_shipment`, `partially_shipped`, `on_hold`, `backorder`, 
        `partially_refunded`, `committed`, `processing`, `completed`

        ## Total Calculation
        The order total is automatically calculated as:
        `(sum of item quantities × unit prices) + total_tax + total_shipping`

        ## Custom Fields and Tags
        - Custom fields must be predefined in the system before use
        - Both order-level and item-level custom fields/tags are supported

        ## Retries and idempotency
        This endpoint accepts an optional `Idempotency-Key` request header, so a client that retries
        after a network timeout does not create the same sales order twice. Without the header, the request
        behaves as normal.
        - **Same key, same body**: the first response is replayed as-is (status, body, and an
          `Idempotent-Replay: true` response header). Only one sales order is created, however many
          times the request is resent.
        - **Same key, different body**: `409` with `code: idempotency_conflict`. Nothing is created.
        - **Same key, first request still in progress**: `409` until the first request finishes.

        Keys are kept for 24 hours and are scoped to your API token. The stored response is replayed
        whatever its status, including a `422`. After you fix a rejected request, resend it with a
        **new** key; reusing the old key returns the stored failure. Use one key per logical create
        (for example, your source system's order number) and keep it the same across retries.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: |
            Optional idempotency token. A retry with the same key and body replays the original
            stored response (with an `Idempotent-Replay: true` header) instead of creating a second
            sales order. Reusing the key with a different body returns `409`. Omit it to disable the guard.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - channel_id
                - order_date
                - order_status
                - items
              properties:
                channel_id:
                  type: integer
                  description: ID of the channel this order belongs to
                  example: 1
                order_number:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: 'Order number shown on the sales order. Must be unique across all sales orders when supplied. Optional on create: when omitted, null, or an empty string, Luminous assigns `LUM-{id}` (the new order''s Luminous ID) after the order is saved. If the channel is configured with an order-number prefix, the assigned number is `{prefix}{n}` from that channel''s sequence instead. A supplied value is always kept as-is.'
                  example: ORD-2024-001
                order_date:
                  type: string
                  format: date
                  description: Date when the order was placed (YYYY-MM-DD)
                  example: '2024-01-15'
                order_status:
                  type: string
                  maxLength: 255
                  description: Current status of the order
                  enum:
                    - pending
                    - shipped
                    - fulfilled
                    - cancelled
                    - awaiting_shipment
                    - partially_shipped
                    - on_hold
                    - backorder
                    - partially_refunded
                    - committed
                    - processing
                    - completed
                  example: pending
                customer_email:
                  type: string
                  format: email
                  maxLength: 255
                  nullable: true
                  description: Customer's email address
                  example: customer@example.com
                customer_username:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Customer's username
                  example: customer123
                customer_po_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Customer's purchase order number
                  example: PO-2024-5678
                company_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the company (business account) to associate with this sales order.
                    When provided, the system will automatically populate the `bill_to` and `ship_to` 
                    addresses from the company's information. If `company_id` is provided, the 
                    `bill_to` and `ship_to` fields become optional.
                  example: 123
                bill_to:
                  type: object
                  required:
                    - name
                  description: |
                    Billing address information. Required when `company_id` is not provided.
                    When `company_id` is provided, this field is optional and will be populated 
                    from the company's billing address if not specified.
                  properties:
                    name:
                      type: string
                      maxLength: 255
                      description: Full name for billing
                      example: John Doe
                    company:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Company name for billing
                      example: Acme Corporation
                    street1:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Primary street address
                      example: 123 Main Street
                    street2:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: 'Secondary address line (apt, suite, etc.)'
                      example: Suite 100
                    street3:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Third address line
                    city:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: City name
                      example: Anytown
                    state:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: State or province
                      example: CA
                    postal_code:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: ZIP or postal code
                      example: '90210'
                    country:
                      type: string
                      maxLength: 2
                      nullable: true
                      description: 2 character country code
                      example: US
                    phone:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Phone number
                      example: 555-1234
                ship_to:
                  type: object
                  required:
                    - name
                  description: |
                    Shipping address information. Required when `company_id` is not provided.
                    When `company_id` is provided, this field is optional and will be populated 
                    from the company's default shipping address if not specified.
                  properties:
                    name:
                      type: string
                      maxLength: 255
                      description: Full name for shipping
                      example: Jane Smith
                    company:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Company name for shipping
                      example: Delivery Corp
                    street1:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Primary street address
                      example: 456 Oak Avenue
                    street2:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: 'Secondary address line (apt, suite, etc.)'
                      example: Apt 2B
                    street3:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Third address line
                    city:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: City name
                      example: Somewhere
                    state:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: State or province
                      example: NY
                    postal_code:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: ZIP or postal code
                      example: '10001'
                    country:
                      type: string
                      maxLength: 2
                      nullable: true
                      description: 2 character country code
                      example: US
                    phone:
                      type: string
                      maxLength: 255
                      nullable: true
                      description: Phone number
                      example: 555-5678
                ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: Date when the order was or will be shipped (YYYY-MM-DD)
                  example: '2024-01-20'
                hold_until_date:
                  type: string
                  format: date
                  nullable: true
                  description: Date to hold the order until (YYYY-MM-DD)
                  example: '2024-01-18'
                ship_by_date:
                  type: string
                  format: date
                  nullable: true
                  description: Required ship by date (YYYY-MM-DD)
                  example: '2024-01-25'
                earliest_ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: Earliest date the order can be shipped (YYYY-MM-DD)
                  example: '2024-01-18'
                total_tax:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Total tax amount for the order
                  example: 15.75
                total_shipping:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: Total shipping cost for the order
                  example: 12.5
                total_discount:
                  type: number
                  format: float
                  minimum: 0
                  nullable: true
                  description: 'Total discount amount applied to the order. If omitted, any header trade discount configured on the linked company (see `header_discount_enabled`, `header_discount_type`, and `header_discount_value` on the company) is computed and applied automatically. Provide an explicit value to override.'
                  example: 10
                requested_shipping_service:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Requested shipping service or carrier
                  example: FedEx Ground
                customer_notes:
                  type: string
                  nullable: true
                  description: Notes from the customer
                  example: Please handle with care - fragile items
                internal_notes:
                  type: string
                  nullable: true
                  description: Internal notes for order processing
                  example: Rush order - expedite processing
                items:
                  type: array
                  minItems: 1
                  description: Array of line items for the order
                  items:
                    type: object
                    required:
                      - quantity
                      - unit_price
                    properties:
                      product_id:
                        type: integer
                        description: ID of the product (required if sku not provided)
                        example: 123
                      sku:
                        type: string
                        maxLength: 255
                        description: SKU of the product (required if product_id not provided)
                        example: WIDGET-001
                      quantity:
                        type: number
                        format: float
                        minimum: 0.001
                        description: 'Quantity of the item ordered, expressed in the unit given by `uom_id`. When `uom_id` is a non-base unit (e.g. a carton), the quantity is converted to the product''s base unit of measure for storage, picking, and fulfillment (parity with purchase-order create). The converted base-unit value is returned as `quantity_ordered` on the order line.'
                        example: 2.5
                      unit_price:
                        type: number
                        format: float
                        description: Price per unit (can be negative for discounts/refunds)
                        example: 49.99
                      uom_id:
                        type: integer
                        description: 'ID of the unit of measure the line is ordered in. If not provided, the default UOM for the item/account is used. The submitted `quantity` is interpreted in this unit and converted to the product''s base unit using the SKU''s conversion rules; the response returns `ordered_uom_id` (this unit), `base_uom_id` (the base unit), and `quantity_ordered` (the base-unit quantity).'
                        example: 1
                      tags:
                        type: array
                        nullable: true
                        description: Tags to associate with this line item
                        items:
                          type: string
                          maxLength: 255
                          example: fragile
                        example:
                          - fragile
                          - priority
                      custom_fields:
                        type: object
                        nullable: true
                        description: Custom field values for this line item
                        additionalProperties:
                          oneOf:
                            - type: string
                            - type: number
                            - type: boolean
                        example:
                          Lot Number: LOT-12345
                          Expiry Date: '2024-12-31'
                          Quality Check: true
                custom_fields:
                  type: object
                  nullable: true
                  description: Custom field values for the sales order
                  additionalProperties:
                    oneOf:
                      - type: string
                      - type: number
                      - type: boolean
                  example:
                    Customer PO: PO-98765
                    Priority Level: High
                    Package Count: 3
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the sales order
                  items:
                    type: string
                    maxLength: 255
                    example: urgent
                  example:
                    - urgent
                    - vip-customer
                    - rush-order
            examples:
              minimal_order:
                summary: Minimal required fields
                description: A basic order with only required fields
                value:
                  channel_id: 1
                  order_number: ORD-2024-001
                  order_date: '2024-01-15'
                  order_status: pending
                  bill_to:
                    name: John Doe
                  ship_to:
                    name: Jane Smith
                  items:
                    - product_id: 123
                      quantity: 2
                      unit_price: 49.99
              complete_order:
                summary: Complete order with all fields
                description: A comprehensive order demonstrating all available fields
                value:
                  channel_id: 1
                  order_number: ORD-2024-002
                  order_date: '2024-01-15'
                  order_status: pending
                  customer_email: customer@example.com
                  customer_username: johndoe123
                  customer_po_number: PO-2024-5678
                  company_id: 123
                  bill_to:
                    name: John Doe
                    company: Acme Corporation
                    street1: 123 Main Street
                    street2: Suite 100
                    city: Anytown
                    state: CA
                    postal_code: '90210'
                    country: US
                    phone: 555-1234
                  ship_to:
                    name: Jane Smith
                    company: Delivery Corp
                    street1: 456 Oak Avenue
                    street2: Apt 2B
                    city: Somewhere
                    state: NY
                    postal_code: '10001'
                    country: US
                    phone: 555-5678
                  ship_date: '2024-01-20'
                  hold_until_date: '2024-01-18'
                  ship_by_date: '2024-01-25'
                  earliest_ship_date: '2024-01-18'
                  total_tax: 15.75
                  total_shipping: 12.5
                  requested_shipping_service: FedEx Ground
                  customer_notes: Please handle with care - fragile items
                  internal_notes: Rush order - expedite processing
                  items:
                    - product_id: 123
                      quantity: 2
                      unit_price: 49.99
                    - sku: WIDGET-002
                      quantity: 1
                      unit_price: 25
                  custom_fields:
                    Customer PO: PO-98765
                    Priority Level: High
                    Package Count: 3
                  tags:
                    - urgent
                    - vip-customer
                    - rush-order
              sku_based_order:
                summary: Order using SKU lookup
                description: An order where products are identified by SKU instead of product_id
                value:
                  channel_id: 1
                  order_number: ORD-2024-003
                  order_date: '2024-01-15'
                  order_status: pending
                  customer_email: customer@example.com
                  bill_to:
                    name: John Doe
                    street1: 123 Main Street
                    city: Anytown
                    state: CA
                    postal_code: '90210'
                    country: US
                  ship_to:
                    name: Jane Smith
                    street1: 456 Oak Avenue
                    city: Somewhere
                    state: NY
                    postal_code: '10001'
                    country: US
                  total_tax: 8.5
                  total_shipping: 10
                  items:
                    - sku: WIDGET-001
                      quantity: 3
                      unit_price: 29.99
                    - sku: GADGET-ABC
                      quantity: 1
                      unit_price: 15
              order_with_item_metadata:
                summary: Order with item-level tags and custom fields
                description: An order demonstrating item-level custom fields and tags
                value:
                  channel_id: 1
                  order_number: ORD-2024-004
                  order_date: '2024-01-15'
                  order_status: pending
                  customer_email: warehouse@example.com
                  bill_to:
                    name: Warehouse Manager
                    company: Distribution Co
                  ship_to:
                    name: Store Manager
                    company: Retail Store
                    street1: 789 Commerce Blvd
                    city: Commerce City
                    state: TX
                    postal_code: '75001'
                    country: US
                  items:
                    - product_id: 456
                      quantity: 10
                      unit_price: 12.5
                      tags:
                        - bulk-item
                        - fragile
                      custom_fields:
                        Lot Number: LOT-2024-001
                        Expiry Date: '2024-12-31'
                        Quality Check: true
                    - sku: SPECIAL-789
                      quantity: 2
                      unit_price: 75
                      tags:
                        - priority
                        - special-handling
                      custom_fields:
                        Serial Number: SN-789-001
                        Warranty Period: 24
                  tags:
                    - bulk-order
                    - warehouse-transfer
              order_with_company:
                summary: Order with company association
                description: 'An order associated with a company. When company_id is provided, bill_to and ship_to addresses are automatically populated from the company''s information.'
                value:
                  channel_id: 1
                  order_number: ORD-2024-005
                  order_date: '2024-01-15'
                  order_status: pending
                  customer_email: customer@example.com
                  company_id: 123
                  items:
                    - product_id: 123
                      quantity: 2
                      unit_price: 49.99
                    - sku: WIDGET-002
                      quantity: 1
                      unit_price: 25
              negative_price_order:
                summary: Order with discount/refund items
                description: An order containing items with negative unit prices for discounts or refunds
                value:
                  channel_id: 1
                  order_number: ORD-2024-006
                  order_date: '2024-01-15'
                  order_status: pending
                  customer_email: customer@example.com
                  bill_to:
                    name: John Doe
                  ship_to:
                    name: John Doe
                    street1: 123 Main Street
                    city: Anytown
                    state: CA
                    postal_code: '90210'
                    country: US
                  items:
                    - product_id: 123
                      quantity: 1
                      unit_price: 100
                    - product_id: 999
                      quantity: 1
                      unit_price: -15
      responses:
        '201':
          description: Sales order created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the sales order
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the order was last updated
                      status:
                        type: string
                        description: Current status of the order
                      order_id:
                        type: string
                        description: External order identifier
                      order_number:
                        type: string
                        description: Order number
                      order_date:
                        type: string
                        format: date
                        description: Date when the order was placed
                      payment_date:
                        type: string
                        format: date
                        description: Date when payment was received
                      ship_by_date:
                        type: string
                        format: date
                        description: Required ship by date
                      age:
                        type: integer
                        description: Age of the order in days
                      order_status:
                        type: string
                        description: Status of the order
                      customer_id:
                        type: string
                        description: Customer identifier
                      customer_username:
                        type: string
                        description: Customer's username
                      customer_email:
                        type: string
                        description: Customer's email address
                      bill_to:
                        type: object
                        description: Billing information
                      ship_to:
                        type: object
                        description: Shipping information
                      requested_shipping_service:
                        type: string
                        nullable: true
                        description: What shipping service to use when shipping this order
                      total:
                        type: number
                        format: float
                        description: Total order amount
                      total_paid:
                        type: number
                        format: float
                        description: Amount paid
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping:
                        type: number
                        format: float
                        description: Total shipping amount
                      customer_notes:
                        type: string
                        description: Notes from the customer
                      internal_notes:
                        type: string
                        description: Internal notes
                      ship_date:
                        type: string
                        format: date
                        description: Date when order was shipped
                      hold_until_date:
                        type: string
                        format: date
                        description: Hold until date
                      earliest_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Earliest date the order can be shipped
                      user_id:
                        type: integer
                        description: User ID associated with the order
                      externally_fulfilled:
                        type: boolean
                        description: Whether the order is fulfilled externally
                      externally_fulfilled_by:
                        type: string
                        description: Entity fulfilling the order externally
                      is_posted:
                        type: boolean
                        description: Whether the order is posted
                      posted_by:
                        type: string
                        description: User who posted the order
                      not_sync:
                        type: boolean
                        description: Sync status
                      sales_posted:
                        type: boolean
                        description: Sales posting status
                      split_order:
                        type: boolean
                        description: Whether the order is split
                      skip_inventory:
                        type: boolean
                        description: Whether to skip inventory
                      skip_sales_report:
                        type: boolean
                        description: Whether to skip sales report
                      channel_id:
                        type: integer
                        description: Channel identifier
                      total_order_cost:
                        type: number
                        format: float
                        description: Total cost of order
                      total_order_quantity:
                        type: number
                        format: float
                        description: Total quantity of items
                      order_cost_details:
                        type: object
                        description: Detailed order cost information
                      source:
                        type: string
                        description: Order source
                      shipstation_order_id:
                        type: string
                        description: ShipStation order identifier
                      type:
                        type: string
                        description: Order type
                      parent_id:
                        type: integer
                        description: Parent order ID if applicable
                      shipping_revenue:
                        type: number
                        format: float
                        description: Revenue from shipping
                      product_total:
                        type: number
                        format: float
                        description: Total product amount
                      total_discount:
                        type: number
                        format: float
                        description: Total discount amount
                      picking_status:
                        type: string
                        description: Status of picking process
                      starred_description:
                        type: string
                        description: Description for starred orders
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      company_id:
                        type: integer
                        nullable: true
                        description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                        example: 123
                      company:
                        nullable: true
                        description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the company
                            example: 123456
                          created_at:
                            type: string
                            format: date-time
                            description: When the company was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the company was last updated
                            example: '2023-03-15T14:30:00Z'
                          status:
                            type: string
                            description: Status of the company
                            enum:
                              - active
                              - inactive
                            example: active
                          name:
                            type: string
                            description: Company name
                            example: Acme Corporation
                          type:
                            type: string
                            nullable: true
                            description: Type of business
                            example: Retail
                          phone:
                            type: string
                            nullable: true
                            description: Primary phone number for the company
                            example: 555-123-4567
                          address:
                            type: string
                            nullable: true
                            description: Street address for the company
                            example: 123 Main St
                          address_line_2:
                            type: string
                            nullable: true
                            description: Additional address information
                            example: Suite 500
                          city:
                            type: string
                            nullable: true
                            description: City
                            example: Austin
                          state:
                            type: string
                            nullable: true
                            description: State/province
                            example: TX
                          postal_code:
                            type: string
                            nullable: true
                            description: Postal/ZIP code
                            example: '78701'
                          country:
                            type: string
                            nullable: true
                            description: Country
                            example: USA
                          full_address:
                            type: string
                            nullable: true
                            description: Complete formatted address
                            example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                          shipping_first_name:
                            type: string
                            nullable: true
                            description: First name for shipping contact (legacy field)
                            example: John
                          shipping_last_name:
                            type: string
                            nullable: true
                            description: Last name for shipping contact (legacy field)
                            example: Doe
                          shipping_email:
                            type: string
                            format: email
                            nullable: true
                            description: Email for shipping contact (legacy field)
                            example: shipping@acmecorp.com
                          shipping_phone:
                            type: string
                            nullable: true
                            description: Phone number for shipping contact (legacy field)
                            example: 555-987-6543
                          shipping_address:
                            type: string
                            nullable: true
                            description: Shipping street address (legacy field)
                            example: 456 Warehouse Blvd
                          shipping_city:
                            type: string
                            nullable: true
                            description: Shipping city (legacy field)
                            example: Austin
                          shipping_state:
                            type: string
                            nullable: true
                            description: Shipping state/province (legacy field)
                            example: TX
                          shipping_postal_code:
                            type: string
                            nullable: true
                            description: Shipping postal/ZIP code (legacy field)
                            example: '78745'
                          shipping_country:
                            type: string
                            nullable: true
                            description: Shipping country (legacy field)
                            example: USA
                          shipping_full_address:
                            type: string
                            nullable: true
                            description: Complete formatted shipping address (legacy field)
                            example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                          payment_term:
                            type: string
                            nullable: true
                            description: Payment terms for the company
                            example: Net 30
                          tax_exempt:
                            type: boolean
                            nullable: true
                            description: Whether the company is exempt from taxes
                            example: false
                          tax_rate:
                            type: number
                            format: float
                            nullable: true
                            description: Tax rate applied to the company's orders
                            example: 8.25
                          due_date_days:
                            type: integer
                            nullable: true
                            description: Number of days until payment is due
                            example: 30
                          credit_limit:
                            type: number
                            format: float
                            nullable: true
                            description: Credit limit for the company. `null` means no limit is set.
                            example: 5000
                          header_discount_enabled:
                            type: boolean
                            description: Whether an order-header trade discount is applied by default for this company
                            example: false
                          header_discount_type:
                            type: string
                            nullable: true
                            enum:
                              - PERCENT
                              - FIXED_AMOUNT
                            description: How the header discount is calculated — a percentage of the order or a fixed amount
                            example: PERCENT
                          header_discount_value:
                            type: number
                            format: float
                            nullable: true
                            description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                            example: 5
                          header_discount_effective_from:
                            type: string
                            format: date
                            nullable: true
                            description: Date from which the header discount takes effect (YYYY-MM-DD)
                            example: '2026-01-01'
                          default_currency_code:
                            type: string
                            nullable: true
                            description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                            example: USD
                          price_level:
                            nullable: true
                            description: Price level associated with this company
                            type: object
                            properties:
                              id:
                                type: number
                                description: Unique identifier for the price level
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                description: When the price level was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the price level was last updated
                                example: '2023-03-15T14:30:00Z'
                              status:
                                type: string
                                description: Status of the price level
                                enum:
                                  - active
                                  - inactive
                                example: active
                              name:
                                type: string
                                description: Name of the price level
                                example: Wholesale
                              type:
                                type: string
                                description: Type of the price level
                                example: percentage
                              percent_increase:
                                type: number
                                format: float
                                description: Percentage increase (or decrease) for this price level
                                example: 15.5
                          notes:
                            type: string
                            nullable: true
                            description: Additional notes about the company
                            example: 'Key account, requires special handling'
                          fein:
                            type: string
                            nullable: true
                            description: Federal Employer Identification Number
                            example: 12-3456789
                          tags:
                            type: array
                            nullable: true
                            description: List of tags associated with the company
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the tag
                                name:
                                  type: string
                                  description: Name of the tag
                                description:
                                  type: string
                                  nullable: true
                                  description: Description of the tag
                                icon:
                                  type: string
                                  nullable: true
                                  description: Icon identifier or URL for the tag
                                color:
                                  type: string
                                  nullable: true
                                  description: Color code for the tag
                              required:
                                - id
                                - name
                          default_shipping:
                            nullable: true
                            description: Default shipping address
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the shipping address
                                example: 789
                              created_at:
                                type: string
                                format: date-time
                                description: When the shipping address was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the shipping address was last updated
                                example: '2023-03-15T14:30:00Z'
                              company_id:
                                type: integer
                                description: ID of the company this shipping address belongs to
                                example: 123456
                              company_name:
                                type: string
                                nullable: true
                                description: Name of the company
                                example: Acme Corporation
                              address:
                                type: string
                                description: Street address
                                example: 456 Warehouse Blvd
                              address_line_2:
                                type: string
                                nullable: true
                                description: Additional address information
                                example: Building 2
                              city:
                                type: string
                                description: City
                                example: Austin
                              state:
                                type: string
                                description: State/province
                                example: TX
                              postal_code:
                                type: string
                                description: Postal/ZIP code
                                example: '78745'
                              country:
                                type: string
                                description: Country
                                example: USA
                              full_address:
                                type: string
                                description: Complete formatted address
                                example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                              full_name:
                                type: string
                                description: Full name of the contact person
                                example: John Doe
                              first_name:
                                type: string
                                nullable: true
                                description: First name of the contact person
                                example: John
                              last_name:
                                type: string
                                nullable: true
                                description: Last name of the contact person
                                example: Doe
                              phone:
                                type: string
                                nullable: true
                                description: Phone number
                                example: 555-987-6543
                              email:
                                type: string
                                format: email
                                nullable: true
                                description: Email address
                                example: shipping@acmecorp.com
                              is_default:
                                type: boolean
                                description: Whether this is the default shipping address
                                example: true
                            required:
                              - id
                              - company_id
                              - address
                              - city
                              - state
                              - postal_code
                              - country
                          shipping_addresses:
                            type: array
                            nullable: true
                            description: List of shipping addresses for the company
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the shipping address
                                  example: 789
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was last updated
                                  example: '2023-03-15T14:30:00Z'
                                company_id:
                                  type: integer
                                  description: ID of the company this shipping address belongs to
                                  example: 123456
                                company_name:
                                  type: string
                                  nullable: true
                                  description: Name of the company
                                  example: Acme Corporation
                                address:
                                  type: string
                                  description: Street address
                                  example: 456 Warehouse Blvd
                                address_line_2:
                                  type: string
                                  nullable: true
                                  description: Additional address information
                                  example: Building 2
                                city:
                                  type: string
                                  description: City
                                  example: Austin
                                state:
                                  type: string
                                  description: State/province
                                  example: TX
                                postal_code:
                                  type: string
                                  description: Postal/ZIP code
                                  example: '78745'
                                country:
                                  type: string
                                  description: Country
                                  example: USA
                                full_address:
                                  type: string
                                  description: Complete formatted address
                                  example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                full_name:
                                  type: string
                                  description: Full name of the contact person
                                  example: John Doe
                                first_name:
                                  type: string
                                  nullable: true
                                  description: First name of the contact person
                                  example: John
                                last_name:
                                  type: string
                                  nullable: true
                                  description: Last name of the contact person
                                  example: Doe
                                phone:
                                  type: string
                                  nullable: true
                                  description: Phone number
                                  example: 555-987-6543
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  description: Email address
                                  example: shipping@acmecorp.com
                                is_default:
                                  type: boolean
                                  description: Whether this is the default shipping address
                                  example: true
                              required:
                                - id
                                - company_id
                                - address
                                - city
                                - state
                                - postal_code
                                - country
                          billing_info:
                            type: object
                            nullable: true
                            description: Billing information
                            properties:
                              id:
                                type: integer
                                example: 456
                              created_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              first_name:
                                type: string
                                nullable: true
                                example: Jane
                              last_name:
                                type: string
                                nullable: true
                                example: Smith
                              email:
                                type: string
                                format: email
                                nullable: true
                                example: accounting@acmecorp.com
                              receiving_bank_name:
                                type: string
                                nullable: true
                                example: First National Bank
                              receiving_bank_address:
                                type: string
                                nullable: true
                                example: '789 Finance Street, Austin, TX 78701'
                          client_type:
                            type: object
                            nullable: true
                            description: Type of client
                            properties:
                              id:
                                type: integer
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              name:
                                type: string
                                example: Retail
                              description:
                                type: string
                                nullable: true
                                example: Retail business client
                          parent_company_id:
                            type: integer
                            nullable: true
                            description: ID of the parent company
                            example: 456
                          invoice_export_template_id:
                            type: integer
                            nullable: true
                            description: ID of the invoice export template
                            example: 789
                          custom_fields:
                            type: object
                            description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                            example:
                              Industry: Manufacturing
                              Region: Southwest
                              Annual Revenue: $5M-$10M
                          assigned_sales_reps:
                            type: array
                            description: |
                              Sales rep users assigned to this company (Go Team members). Resolved from the company's
                              `goTeamMember.user` relation. Only present when the relation is loaded.
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: User ID of the assigned sales rep
                                  example: 42
                                email:
                                  type: string
                                  description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                  example: rep@example.com
                                first_name:
                                  type: string
                                  nullable: true
                                  example: Jane
                                last_name:
                                  type: string
                                  nullable: true
                                  example: Doe
                          sales_channel:
                            allOf:
                              - type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Sales channel ID.
                                  status:
                                    type: string
                                    description: Sales channel status (e.g. active).
                                  label:
                                    type: string
                                    nullable: true
                                    description: Human-readable channel label.
                                  channel_type:
                                    type: string
                                    nullable: true
                                    description: Channel type (e.g. the integration/platform the channel represents).
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            nullable: true
                            description: The company's default sales channel. Only present when the relation is loaded.
                        required:
                          - id
                          - name
                          - status
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the order item
                            line_number:
                              type: integer
                              description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            sku:
                              type: string
                              description: Stock keeping unit
                            name:
                              type: string
                              description: Product name
                            image_url:
                              type: string
                              description: URL of product image
                            weight:
                              type: object
                              description: Weight information
                            quantity:
                              type: number
                              format: float
                              description: Ordered quantity
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            shipping:
                              type: number
                              format: float
                              description: Shipping amount
                            warehouse_location:
                              type: string
                              description: Location in warehouse
                            options:
                              type: object
                              description: Additional options
                            fulfillment_sku:
                              type: string
                              description: SKU used for fulfillment
                            adjustment:
                              type: number
                              format: float
                              description: Price adjustment
                            upc:
                              type: string
                              description: Universal Product Code
                            stock_id:
                              type: integer
                              description: Stock identifier
                            kit_id:
                              type: integer
                              description: Kit identifier if part of a kit
                            non_physical_item:
                              type: boolean
                              description: Whether item is non-physical
                            ignore_item:
                              type: boolean
                              description: Whether to ignore this item
                            is_locally_added:
                              type: boolean
                              description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                            quantity_shipped:
                              type: number
                              format: float
                              description: Quantity shipped
                            quantity_cancelled:
                              type: number
                              format: float
                              description: Quantity cancelled
                            quantity_invoiced:
                              type: number
                              format: float
                              description: Quantity invoiced
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                            base_uom_id:
                              type: integer
                              description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                            ordered_uom_id:
                              type: integer
                              description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                            product_id:
                              type: integer
                              description: Product identifier
                            total_returned_base_quantity:
                              type: number
                              format: float
                              description: Total quantity returned
                            parent_id:
                              type: integer
                              description: Parent item ID
                            status:
                              type: string
                              description: Item status
                            discount:
                              type: number
                              format: float
                              description: Discount amount
                            estimated_ship_date:
                              type: string
                              format: date
                              description: Estimated shipping date
                            custom_fields:
                              type: object
                              description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties:
                                type: string
                            product:
                              type: object
                              description: Product information
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: number
                                  format: float
                                  description: Weight of the product
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                category:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                  description: Product category information
                                subcategory:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                  description: Product subcategory information
                                custom_fields:
                                  type: object
                                  description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                  additionalProperties:
                                    type: string
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Available variant attributes
                                sku:
                                  type: string
                                  description: Internal SKU
                                alternate_skus:
                                  type: array
                                  description: Alternate SKUs
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                tags:
                                  type: array
                                  description: Tags associated with the product
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the tag
                                      name:
                                        type: string
                                        description: Name of the tag
                                      description:
                                        type: string
                                        nullable: true
                                        description: Description of the tag
                                      icon:
                                        type: string
                                        nullable: true
                                        description: Icon identifier or URL for the tag
                                      color:
                                        type: string
                                        nullable: true
                                        description: Color code for the tag
                                    required:
                                      - id
                                      - name
                                supplier:
                                  type: object
                                  nullable: true
                                  description: Supplier information
                                type:
                                  type: string
                                  enum:
                                    - PRODUCT
                                    - KIT
                                  description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                kit_items:
                                  type: array
                                  nullable: true
                                  description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the kit item
                                      product_id:
                                        type: integer
                                        description: ID of the product component
                                      quantity:
                                        type: number
                                        format: float
                                        description: Quantity of this component in the kit
                                      uom_id:
                                        type: integer
                                        description: Unit of measure ID for the quantity
                                      base_uom_quantity:
                                        type: number
                                        format: float
                                        description: Quantity converted to base unit of measure
                                      price:
                                        type: number
                                        format: float
                                        description: Price for this kit item
                                      original_price:
                                        type: number
                                        format: float
                                        description: Original price for this kit item
                                      total:
                                        type: number
                                        format: float
                                        description: Calculated total (quantity * price)
                                      product:
                                        type: object
                                        nullable: true
                                        description: Product information for this kit item (when loaded)
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          sku:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          retail_price:
                                            type: number
                                            format: float
                                          wholesale_price:
                                            type: number
                                            format: float
                                      unit_of_measure:
                                        type: object
                                        nullable: true
                                        description: Unit of measure information (when loaded)
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          base_unit:
                                            type: boolean
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                            tags:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  description:
                                    type: string
                                  icon:
                                    type: string
                                  color:
                                    type: string
                                  discount_structure:
                                    type: object
                                  markup_structure:
                                    type: object
                              description: Tags associated with the sales order item
                        description: Line items in the order
                      fulfillment_orders:
                        type: array
                        description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Fulfillment order ID
                            order_number:
                              type: string
                              description: Fulfillment order number
                            order_key:
                              type: string
                              nullable: true
                              description: Fulfillment order key
                            order_status:
                              type: string
                              description: Fulfillment order status
                            sales_order_id:
                              type: integer
                              description: Associated sales order ID
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              description: Warehouse group ID
                            destination_oms_id:
                              type: integer
                              nullable: true
                              description: Destination app integration account ID
                            destination_oms_store_id:
                              type: integer
                              nullable: true
                            fulfillment_channel_id:
                              type: integer
                              nullable: true
                            pushed_at:
                              type: string
                              format: date-time
                              nullable: true
                            packing_slip_printed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                            error_message:
                              type: string
                              nullable: true
                              description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                            ship_by_date:
                              type: string
                              format: date
                              nullable: true
                              description: Ship by date
                            total:
                              type: number
                              format: float
                              nullable: true
                              description: Order total
                            bill_to:
                              type: object
                              nullable: true
                              description: Billing address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            ship_to:
                              type: object
                              nullable: true
                              description: Shipping address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            invoice_to:
                              type: object
                              nullable: true
                              description: Invoice address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            sales_order:
                              type: object
                              nullable: true
                              description: Nested sales order data
                            picklists:
                              type: array
                              description: Associated picklists
                              items:
                                type: object
                            fulfillment_order_items:
                              type: array
                              description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    nullable: true
                                    description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                  shipment_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the fulfillment order this line belongs to.
                                  status:
                                    nullable: true
                                    description: Line status.
                                  sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                  sku:
                                    type: string
                                    nullable: true
                                  name:
                                    type: string
                                    nullable: true
                                  weight:
                                    nullable: true
                                    description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                  dimensions:
                                    nullable: true
                                    description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                  quantity:
                                    type: number
                                    description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                  unit_price:
                                    type: number
                                    description: Unit price. Always `0` on synthetic component rows.
                                  lot_id:
                                    type: integer
                                    nullable: true
                                  lot_number:
                                    type: string
                                    nullable: true
                                  expiry_date:
                                    type: string
                                    nullable: true
                                    description: Lot expiry date.
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  is_kit_component:
                                    type: boolean
                                    description: True when the row is a component of a kit (stored or synthetic).
                                  parent_fulfillment_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                  kit_sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                  is_synthetic:
                                    type: boolean
                                    description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                            total_weight:
                              type: object
                              nullable: true
                              description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                              properties:
                                total_oz:
                                  type: number
                                  format: float
                                  description: Total weight in ounces
                                total_lb:
                                  type: number
                                  format: float
                                  description: Total weight in pounds
                                line_count:
                                  type: integer
                                  description: Number of fulfillment order lines
                                weighed_line_count:
                                  type: integer
                                  description: Number of lines that had a usable weight and contributed to the total
                                is_complete:
                                  type: boolean
                                  description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                            tags:
                              type: array
                              description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the tag
                                  name:
                                    type: string
                                    description: Name of the tag
                                  description:
                                    type: string
                                    nullable: true
                                    description: Description of the tag
                                  icon:
                                    type: string
                                    nullable: true
                                    description: Icon identifier or URL for the tag
                                  color:
                                    type: string
                                    nullable: true
                                    description: Color code for the tag
                                required:
                                  - id
                                  - name
                            purchase_orders:
                              type: array
                              description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  order_status:
                                    type: string
                                    nullable: true
                                    enum:
                                      - active
                                      - deleted
                                      - completed
                            source_reference_identifier:
                              type: string
                              nullable: true
                              description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                            held_for_item_change:
                              type: boolean
                              description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                            created_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was last updated
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                            icon:
                              type: string
                            color:
                              type: string
                            discount_structure:
                              type: object
                            markup_structure:
                              type: object
                        description: Tags associated with the order
                      shipments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the shipment
                            sales_order_id:
                              type: integer
                              description: ID of the associated sales order
                            shipped_by_user:
                              description: 'Luminous user who marked the parent sales order shipped, or `null` when not set. Who picked and packed is not stored on the shipment; see `picked_by_user` / `packed_by_user` on picklists.'
                              type: object
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                  nullable: true
                            ship_date:
                              type: string
                              format: date
                              description: Date when the shipment was or will be sent
                            tracking_number:
                              type: string
                              description: Tracking number for the shipment
                            tracking_url:
                              type: string
                              nullable: true
                              description: |
                                Tracking URL for the shipment. This is the stored URL, or a carrier URL built from the
                                tracking number when carrier tracking links are enabled for the tenant.
                            delivery_status:
                              type: string
                              nullable: true
                              enum:
                                - pre_transit
                                - in_transit
                                - out_for_delivery
                                - delivered
                                - exception
                                - null
                              description: |
                                Carrier delivery status from the Luminous label-tracking record that shares this
                                shipment's tracking number (and fulfillment order, when the shipment is bound to one).
                                `available_for_pickup` is reported as `out_for_delivery`; `failure`, `return_to_sender`,
                                `error`, and `cancelled` are reported as `exception`. `null` when Luminous has no
                                label-tracking record for the shipment (for example a tracking number imported from
                                ShipStation) or the carrier status is unknown.
                            delivered_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: |
                                Delivery timestamp from the same label-tracking record as `delivery_status`. `null` when
                                there is no tracking record or the shipment has not been delivered.
                            bol_number:
                              type: string
                              description: Bill of Lading Number for logistics tracking
                              example: BOL-123456789
                            pro_number:
                              type: string
                              description: Progressive Rotating Order Number (common in LTL shipping)
                              example: PRO-987654321
                            partner_reference_number:
                              type: string
                              description: General reference number from/for the shipping partner
                              example: PARTNER-REF-001
                            is_return:
                              type: boolean
                              description: Whether this is a return shipment
                            carrier_code:
                              type: string
                              description: 'Code identifying the carrier (e.g., ups, fedex)'
                            scac:
                              type: string
                              nullable: true
                              description: Standard Carrier Alpha Code (SCAC) for the shipment's carrier; included on outbound EDI 856/810 documents
                            service_code:
                              type: string
                              description: Code identifying the shipping service
                            package_code:
                              type: string
                              description: Code identifying the package type
                            shipment_cost:
                              type: number
                              format: float
                              description: Cost of shipping
                            insurance_cost:
                              type: number
                              format: float
                              description: Cost of insurance
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              description: ID of the warehouse group associated with this shipment (from the linked fulfillment order)
                            status:
                              type: integer
                              description: Status of the shipment
                            ship_to:
                              type: object
                              properties:
                                name:
                                  type: string
                                  description: Recipient name
                                company:
                                  type: string
                                  description: Company name
                                street1:
                                  type: string
                                  description: Primary street address
                                street2:
                                  type: string
                                  description: Secondary street address
                                street3:
                                  type: string
                                  description: Additional street address
                                city:
                                  type: string
                                  description: City
                                state:
                                  type: string
                                  description: State/province
                                postalCode:
                                  type: string
                                  description: Postal/ZIP code
                                country:
                                  type: string
                                  description: Country
                                phone:
                                  type: string
                                  description: Contact phone number
                                residential:
                                  type: boolean
                                  description: Whether this is a residential address
                            weight:
                              type: object
                              required:
                                - value
                                - units
                              properties:
                                value:
                                  type: number
                                  format: float
                                  description: Weight value
                                units:
                                  type: string
                                  enum:
                                    - ounces
                                    - pounds
                                    - grams
                                    - kilograms
                                  description: Unit of weight measurement
                            dimensions:
                              type: object
                              required:
                                - units
                                - length
                                - width
                                - height
                              properties:
                                units:
                                  type: string
                                  enum:
                                    - inches
                                    - centimeters
                                  description: Unit of dimensional measurement
                                length:
                                  type: number
                                  format: float
                                  description: Length of the package
                                width:
                                  type: number
                                  format: float
                                  description: Width of the package
                                height:
                                  type: number
                                  format: float
                                  description: Height of the package
                            items:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the shipment item
                                  shipment_id:
                                    type: integer
                                    description: ID of the parent shipment
                                  product_id:
                                    type: integer
                                    description: ID of the product being shipped
                                  sales_order_item_id:
                                    type: integer
                                    description: 'Luminous sales order line-item ID (the internal item primary key) for the line being shipped. This is the value to pass back as `order_item_id` when creating a shipment for this order. For kit/bundle component lines that share a single upstream channel line, each component is still returned with its own distinct `sales_order_item_id`.'
                                  quantity:
                                    type: number
                                    description: 'Quantity being shipped, expressed in the same unit of measure the associated sales order line was ordered in (the selling UoM, e.g. cartons) rather than internal base units. When the originating order line cannot be resolved, the stored quantity is returned as-is.'
                                  weight:
                                    type: object
                                    required:
                                      - value
                                      - units
                                    properties:
                                      value:
                                        type: number
                                        format: float
                                        description: Weight value
                                      units:
                                        type: string
                                        enum:
                                          - ounces
                                          - pounds
                                          - grams
                                          - kilograms
                                        description: Unit of weight measurement
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Price per unit
                                  lot_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the lot this shipment item was deducted from (CS-10083). `null` when the line has no lot. Populated from the `lot_id` submitted on shipment create; Luminous no longer re-infers a lot by FEFO/FIFO once a lot is named.
                                  lot_number:
                                    type: string
                                    nullable: true
                                    description: 'Lot number stamped on the item, falling back to the referenced lot''s number when only `lot_id` was submitted. `null` when the line has no lot.'
                                  expiry_date:
                                    type: string
                                    format: date
                                    nullable: true
                                    description: 'Expiry date of the lot (`YYYY-MM-DD`), falling back to the referenced lot. `null` when the line has no lot.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                              description: Items included in this shipment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the shipment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the shipment was last updated
                        description: Shipments associated with order
                      attachments:
                        type: array
                        items:
                          type: object
                          description: A file attached to a sales order.
                          properties:
                            id:
                              type: integer
                              description: Attachment ID
                            original_filename:
                              type: string
                              description: The original name of the uploaded file.
                            mime_type:
                              type: string
                              nullable: true
                              description: The file's MIME type (e.g. `application/pdf`).
                            size_bytes:
                              type: integer
                              description: File size in bytes.
                            uploaded_by:
                              type: object
                              nullable: true
                              description: The user who uploaded the file. Null if the uploader is unknown.
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: 'The uploader''s full name, or email address if no name is set.'
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: ISO 8601 timestamp of when the attachment was created.
                        description: 'Files attached to the order. Only present on the detail endpoint (this endpoint), not on the list endpoint.'
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
              examples:
                created_order:
                  summary: Successfully created sales order
                  value:
                    data:
                      id: 12345
                      created_at: '2024-01-15T10:30:00Z'
                      updated_at: '2024-01-15T10:30:00Z'
                      status: Active
                      order_id: '12345'
                      order_number: ORD-2024-001
                      order_date: '2024-01-15'
                      order_status: pending
                      customer_email: customer@example.com
                      customer_username: johndoe123
                      customer_po_number: PO-2024-5678
                      company_id: 123
                      company:
                        id: 123
                        name: Acme Corporation
                        status: active
                        address: 123 Main Street
                        city: Anytown
                        state: CA
                        postal_code: '90210'
                        country: US
                      bill_to:
                        name: John Doe
                        company: Acme Corporation
                        street1: 123 Main Street
                        street2: Suite 100
                        city: Anytown
                        state: CA
                        postal_code: '90210'
                        country: US
                        phone: 555-1234
                      ship_to:
                        name: Jane Smith
                        company: Delivery Corp
                        street1: 456 Oak Avenue
                        city: Somewhere
                        state: NY
                        postal_code: '10001'
                        country: US
                        phone: 555-5678
                      total: 128.23
                      total_paid: 0
                      total_tax: 15.75
                      total_shipping: 12.5
                      product_total: 99.98
                      requested_shipping_service: FedEx Ground
                      customer_notes: Please handle with care - fragile items
                      internal_notes: Rush order - expedite processing
                      ship_date: '2024-01-20'
                      hold_until_date: '2024-01-18'
                      ship_by_date: '2024-01-25'
                      earliest_ship_date: '2024-01-18'
                      externally_fulfilled: false
                      is_posted: false
                      source: external_api
                      total_order_quantity: 3
                      items:
                        - id: 67890
                          line_number: 1
                          sku: WIDGET-001
                          name: Premium Widget
                          quantity: 2
                          unit_price: 49.99
                          upc: '123456789012'
                          product_id: 123
                          tags: []
                          custom_fields: {}
                        - id: 67891
                          line_number: 2
                          sku: WIDGET-002
                          name: Standard Widget
                          quantity: 1
                          unit_price: 25
                          upc: '123456789013'
                          product_id: 124
                          tags: []
                          custom_fields: {}
                      tags:
                        - id: 1
                          name: urgent
                        - id: 2
                          name: vip-customer
                        - id: 3
                          name: rush-order
                      custom_fields:
                        Customer PO: PO-98765
                        Priority Level: High
                        Package Count: 3
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: |
            Idempotency conflict: the `Idempotency-Key` is still being processed by an in-flight
            request, or was already used with a different request body. The body carries
            `code: idempotency_conflict` alongside `message`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Human-readable explanation of the conflict
                  code:
                    type: string
                    enum:
                      - idempotency_conflict
                    description: Machine-readable conflict code
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              examples:
                missing_required_fields:
                  summary: Missing required fields
                  value:
                    message: The given data was invalid.
                    errors:
                      channel_id:
                        - Channel ID is required.
                      order_date:
                        - Order date is required.
                      order_status:
                        - Order status is required.
                      bill_to:
                        - Billing address is required when company_id is not provided.
                      ship_to:
                        - Shipping address is required when company_id is not provided.
                      items:
                        - At least one item is required.
                duplicate_order_number:
                  summary: Duplicate order number
                  value:
                    message: The given data was invalid.
                    errors:
                      order_number:
                        - Order number is already in use.
                invalid_order_status:
                  summary: Invalid order status
                  value:
                    message: The given data was invalid.
                    errors:
                      order_status:
                        - 'Order status must be one of the following valid values: pending, shipped, fulfilled, cancelled, awaiting_shipment, partially_shipped, on_hold, backorder, partially_refunded, committed, processing, completed'
                product_not_found:
                  summary: Product not found
                  value:
                    message: The given data was invalid.
                    errors:
                      items.0.product:
                        - 'Product not found for product_id: 99999'
                invalid_custom_fields:
                  summary: Invalid custom field values
                  value:
                    message: The given data was invalid.
                    errors:
                      custom_fields.Priority Level:
                        - 'Priority Level must be one of: Low, Medium, High'
                      items.0.custom_fields.Item Weight:
                        - Item Weight must be a number
  /sales-orders/export:
    get:
      operationId: exportSalesOrders
      tags:
        - Sales Orders
      summary: Export sales orders (incremental)
      description: |
        Incrementally export active sales orders updated within a given time window, with cursor-based
        pagination. Designed for real-time syncing and data pipelines.

        ## How it works

        Each export run is anchored to a **fixed cutoff time** (set at the start of the first request),
        so pages are stable even if records are updated mid-export.

        **Starting a run** — provide `since` with a UTC datetime. The endpoint returns up to `limit`
        orders updated on or after that time, up to the cutoff.

        **Continuing a run** — use the `next_cursor` value from the previous response. The cursor
        encodes the run's position and is cryptographically signed; do not modify it.

        **Run complete** — when `has_more` is `false`, you have received all orders in the window.
        Store the cutoff time (available in the first response's `meta.cutoff`) as your next `since`
        value to pick up changes on the following sync.

        ## Pagination parameters

        | Parameter | Description |
        |-----------|-------------|
        | `since`   | Start of the time window (UTC). Required when starting a new run. Cannot be combined with `cursor`. |
        | `cursor`  | Continuation token from a previous response. Required when continuing a run. Cannot be combined with `since`. |
        | `limit`   | Max records per page. Default and maximum: 1000. |

        ## Example flow

        ```
        # 1. Start a run from a known point in time
        GET /sales-orders/export?since=2024-01-01T00:00:00Z&limit=1000

        # 2. If has_more is true, continue with the cursor
        GET /sales-orders/export?cursor=<next_cursor from previous response>

        # 3. Repeat until has_more is false
        # 4. Save meta.cutoff as your next since value
        ```

        ## Notes

        - Only active sales orders are returned.
        - Results are ordered by `updated_at` ascending, then by `id` ascending, ensuring a
          stable and consistent traversal order.
        - `since` accepts any parseable datetime string (e.g. `2024-01-01`, `2024-01-01T00:00:00Z`,
          `2024-01-01 00:00:00`). A value without an offset is read as UTC; a value with `Z` or an
          explicit offset (e.g. `2024-01-01T06:00:00-06:00`) is honored.
        - `since` is an **inclusive** lower bound on `updated_at`. Delivery is at-least-once, never
          skipped: orders whose `updated_at` equals `since` are returned again, and a `since` that falls
          in the repeated hour when daylight saving time ends (in the server's timezone) starts from the
          top of that hour, so up to one hour of orders may be re-delivered. Upsert on `order_id`, and
          do not subtract a fixed offset from `since`.
        - Every `created_at` / `updated_at` in the response (order, `items`, `shipments`,
          `fulfillment_orders`) is UTC ISO 8601 with microseconds, e.g. `2026-09-17T19:21:32.000000Z`.
          `order_date` and `ship_date` are returned as stored.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: since
          schema:
            type: string
            format: date-time
            example: '2024-01-01T00:00:00Z'
          description: |
            Inclusive start of the export window (lower bound on `updated_at`). Read as UTC unless the
            value carries `Z` or an explicit offset. Required when starting a new run.
            Cannot be combined with `cursor`.
        - in: query
          name: cursor
          schema:
            type: string
            example: eyJ2IjoxLCJtb2RlIjoiZXhwb3J0In0.abc123
          description: |
            Signed continuation token from a previous export response. Required when continuing a run.
            Cannot be combined with `since`.
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1000
          description: Maximum number of orders to return per page.
      responses:
        '200':
          description: Successful export page
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        order_id:
                          type: integer
                          description: Internal Luminous order ID
                        order_number:
                          type: string
                          description: Order reference number
                        status:
                          type: string
                          description: Luminous internal status label (e.g. Active)
                        order_status:
                          type: string
                          description: ShipStation order status (e.g. awaiting_shipment)
                        total_amount:
                          type: number
                          format: float
                          description: Order total
                        total_tax:
                          type: number
                          format: float
                        total_shipping:
                          type: number
                          format: float
                        total_paid:
                          type: number
                          format: float
                        customer_id:
                          type: integer
                          nullable: true
                        customer_username:
                          type: string
                          nullable: true
                        customer_email:
                          type: string
                          nullable: true
                        order_date:
                          type: string
                          format: date
                        tags:
                          type: array
                          description: Tag names on the order as received from Shopify. Only Shopify-sourced orders carry tags here; orders from other channels or created manually return an empty array.
                          items:
                            type: string
                          example:
                            - wholesale
                            - priority
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              order_item_id:
                                type: integer
                              sku:
                                type: string
                                nullable: true
                              name:
                                type: string
                                nullable: true
                              quantity:
                                type: number
                                format: float
                              price:
                                type: number
                                format: float
                              tax:
                                type: number
                                format: float
                              quantity_ordered:
                                type: number
                                format: float
                              quantity_shipped:
                                type: number
                                format: float
                              quantity_cancelled:
                                type: number
                                format: float
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        shipments:
                          type: array
                          items:
                            type: object
                            properties:
                              shipment_id:
                                type: integer
                              tracking_number:
                                type: string
                                nullable: true
                              tracking_url:
                                type: string
                                nullable: true
                              carrier_code:
                                type: string
                                nullable: true
                              service_code:
                                type: string
                                nullable: true
                              ship_date:
                                type: string
                                format: date
                                nullable: true
                              shipment_cost:
                                type: number
                                format: float
                              status:
                                type: string
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        fulfillment_orders:
                          type: array
                          items:
                            type: object
                            properties:
                              fulfillment_order_id:
                                type: integer
                              order_number:
                                type: string
                                nullable: true
                              status:
                                type: string
                                nullable: true
                              warehouse_group_id:
                                type: integer
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                  next_cursor:
                    type: string
                    nullable: true
                    description: Signed cursor token to fetch the next page. Null when the export is complete.
                    example: eyJ2IjoxLCJtb2RlIjoiZXhwb3J0In0.abc123
                  has_more:
                    type: boolean
                    description: Whether more pages exist in this export run.
                  meta:
                    type: object
                    properties:
                      rows:
                        type: integer
                        description: Number of orders returned in this page.
                      cutoff:
                        type: string
                        format: date-time
                        description: |
                          The fixed upper bound of this export run. Save this as your next `since`
                          value after the run completes.
              examples:
                first_page:
                  summary: First page with more results
                  value:
                    data:
                      - order_id: 1001
                        order_number: ORD-2024-001
                        status: Active
                        order_status: awaiting_shipment
                        total_amount: 128.23
                        total_tax: 15.75
                        total_shipping: 12.5
                        total_paid: 128.23
                        customer_id: 42
                        customer_username: johndoe
                        customer_email: john@example.com
                        order_date: '2024-01-15'
                        tags:
                          - wholesale
                          - priority
                        created_at: '2024-01-15T10:30:00Z'
                        updated_at: '2024-01-15T10:30:00Z'
                        items:
                          - order_item_id: 5001
                            sku: WIDGET-001
                            name: Premium Widget
                            quantity: 2
                            price: 49.99
                            tax: 7.5
                            quantity_ordered: 2
                            quantity_shipped: 0
                            quantity_cancelled: 0
                            created_at: '2024-01-15T10:30:00Z'
                            updated_at: '2024-01-15T10:30:00Z'
                        shipments: []
                        fulfillment_orders:
                          - fulfillment_order_id: 9001
                            order_number: ORD-2024-001-A
                            status: pending
                            warehouse_group_id: 3
                            created_at: '2024-01-15T10:31:00Z'
                            updated_at: '2024-01-15T10:31:00Z'
                    next_cursor: eyJ2IjoxLCJtb2RlIjoiZXhwb3J0In0.abc123
                    has_more: true
                    meta:
                      rows: 1000
                      cutoff: '2024-01-16T00:00:00Z'
                last_page:
                  summary: Final page — export complete
                  value:
                    data:
                      - order_id: 1999
                        order_number: ORD-2024-999
                        status: Active
                        order_status: shipped
                        total_amount: 55
                        total_tax: 5
                        total_shipping: 0
                        total_paid: 55
                        customer_id: null
                        customer_username: null
                        customer_email: jane@example.com
                        order_date: '2024-01-15'
                        tags: []
                        created_at: '2024-01-15T23:50:00Z'
                        updated_at: '2024-01-15T23:55:00Z'
                        items:
                          - order_item_id: 5999
                            sku: GADGET-ABC
                            name: Gadget
                            quantity: 1
                            price: 50
                            tax: 5
                            quantity_ordered: 1
                            quantity_shipped: 1
                            quantity_cancelled: 0
                            created_at: '2024-01-15T23:50:00Z'
                            updated_at: '2024-01-15T23:55:00Z'
                        shipments:
                          - shipment_id: 8001
                            tracking_number: 1Z999AA10123456784
                            tracking_url: 'https://www.ups.com/track?tracknum=1Z999AA10123456784'
                            carrier_code: ups
                            service_code: ups_ground
                            ship_date: '2024-01-16'
                            shipment_cost: 8.5
                            status: shipped
                            created_at: '2024-01-16T09:00:00Z'
                            updated_at: '2024-01-16T09:00:00Z'
                        fulfillment_orders: []
                    next_cursor: null
                    has_more: false
                    meta:
                      rows: 1
                      cutoff: '2024-01-16T00:00:00Z'
        '400':
          description: Invalid cursor
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
              examples:
                invalid_cursor:
                  summary: Tampered or malformed cursor
                  value:
                    message: Invalid cursor signature.
                    error: invalid_cursor
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              examples:
                missing_params:
                  summary: Neither since nor cursor provided
                  value:
                    message: The given data was invalid.
                    errors:
                      since:
                        - The since field is required when cursor is not present.
                both_params:
                  summary: Both since and cursor provided
                  value:
                    message: The given data was invalid.
                    errors:
                      cursor:
                        - Cannot specify both since and cursor.
                invalid_since:
                  summary: Invalid since date
                  value:
                    message: The given data was invalid.
                    errors:
                      since:
                        - 'The since does not match the format Y-m-d H:i:s.'
  /sales-orders/bulk-refresh:
    post:
      operationId: bulkRefreshSalesOrders
      tags:
        - Sales Orders
      summary: Bulk refresh sales orders
      description: |
        Re-pull up to 100 sales orders from their source channels in the background.
        Creates a batch job and returns immediately — orders are refreshed asynchronously.

        This dispatches the same refresh pipeline as the admin `order:refresh` command:
        it re-fetches order data from the originating channel (e.g. Shopify, Amazon) and
        updates the order in Luminous.

        Use the returned `batch_id` to poll batch progress if needed.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - salesOrderIds
              properties:
                salesOrderIds:
                  type: array
                  items:
                    type: integer
                  maxItems: 100
                  description: IDs of the sales orders to refresh. Maximum 100 per request.
      responses:
        '200':
          description: Batch created — jobs are processing in the background
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      batch_id:
                        type: string
                        description: ID of the created batch job
                      total_items:
                        type: integer
                        description: Number of orders queued for refresh
                      failed_items:
                        type: integer
                        description: Number of items that have already failed (usually 0 at creation)
                      not_found_ids:
                        type: array
                        items:
                          type: integer
                        description: IDs from the request that could not be matched to an active order
        '400':
          description: 'No IDs provided, more than 100 IDs provided, or no active orders found'
  '/sales-orders/{id}':
    get:
      operationId: getSalesOrder
      tags:
        - Sales Orders
      summary: Single sales order
      description: |
        Get details of a specific sales order by ID.

        <Note>
        **Need to re-pull this order's data from its source channel?** Use [`POST /sales-orders/bulk-refresh`](/api-reference/sales-orders/bulk-refresh-sales-orders)
        with body `{ "salesOrderIds": [id] }`.
        </Note>
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the sales order to retrieve
        - in: query
          name: include_product
          schema:
            type: boolean
            default: true
          description: 'When `false`, line items omit the nested `product` object (and the product is not loaded), which makes responses smaller and faster. `product_id` and the other line fields stay.'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the sales order
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the order was last updated
                      status:
                        type: string
                        description: Current status of the order
                      order_id:
                        type: string
                        description: External order identifier
                      order_number:
                        type: string
                        description: Order number
                      order_date:
                        type: string
                        format: date
                        description: Date when the order was placed
                      payment_date:
                        type: string
                        format: date
                        description: Date when payment was received
                      ship_by_date:
                        type: string
                        format: date
                        description: Required ship by date
                      age:
                        type: integer
                        description: Age of the order in days
                      order_status:
                        type: string
                        description: Status of the order
                      customer_id:
                        type: string
                        description: Customer identifier
                      customer_username:
                        type: string
                        description: Customer's username
                      customer_email:
                        type: string
                        description: Customer's email address
                      bill_to:
                        type: object
                        description: Billing information
                      ship_to:
                        type: object
                        description: Shipping information
                      requested_shipping_service:
                        type: string
                        nullable: true
                        description: What shipping service to use when shipping this order
                      total:
                        type: number
                        format: float
                        description: Total order amount
                      total_paid:
                        type: number
                        format: float
                        description: Amount paid
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping:
                        type: number
                        format: float
                        description: Total shipping amount
                      customer_notes:
                        type: string
                        description: Notes from the customer
                      internal_notes:
                        type: string
                        description: Internal notes
                      ship_date:
                        type: string
                        format: date
                        description: Date when order was shipped
                      hold_until_date:
                        type: string
                        format: date
                        description: Hold until date
                      earliest_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Earliest date the order can be shipped
                      user_id:
                        type: integer
                        description: User ID associated with the order
                      externally_fulfilled:
                        type: boolean
                        description: Whether the order is fulfilled externally
                      externally_fulfilled_by:
                        type: string
                        description: Entity fulfilling the order externally
                      is_posted:
                        type: boolean
                        description: Whether the order is posted
                      posted_by:
                        type: string
                        description: User who posted the order
                      not_sync:
                        type: boolean
                        description: Sync status
                      sales_posted:
                        type: boolean
                        description: Sales posting status
                      split_order:
                        type: boolean
                        description: Whether the order is split
                      skip_inventory:
                        type: boolean
                        description: Whether to skip inventory
                      skip_sales_report:
                        type: boolean
                        description: Whether to skip sales report
                      channel_id:
                        type: integer
                        description: Channel identifier
                      total_order_cost:
                        type: number
                        format: float
                        description: Total cost of order
                      total_order_quantity:
                        type: number
                        format: float
                        description: Total quantity of items
                      order_cost_details:
                        type: object
                        description: Detailed order cost information
                      source:
                        type: string
                        description: Order source
                      shipstation_order_id:
                        type: string
                        description: ShipStation order identifier
                      type:
                        type: string
                        description: Order type
                      parent_id:
                        type: integer
                        description: Parent order ID if applicable
                      shipping_revenue:
                        type: number
                        format: float
                        description: Revenue from shipping
                      product_total:
                        type: number
                        format: float
                        description: Total product amount
                      total_discount:
                        type: number
                        format: float
                        description: Total discount amount
                      picking_status:
                        type: string
                        description: Status of picking process
                      starred_description:
                        type: string
                        description: Description for starred orders
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      company_id:
                        type: integer
                        nullable: true
                        description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                        example: 123
                      company:
                        nullable: true
                        description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the company
                            example: 123456
                          created_at:
                            type: string
                            format: date-time
                            description: When the company was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the company was last updated
                            example: '2023-03-15T14:30:00Z'
                          status:
                            type: string
                            description: Status of the company
                            enum:
                              - active
                              - inactive
                            example: active
                          name:
                            type: string
                            description: Company name
                            example: Acme Corporation
                          type:
                            type: string
                            nullable: true
                            description: Type of business
                            example: Retail
                          phone:
                            type: string
                            nullable: true
                            description: Primary phone number for the company
                            example: 555-123-4567
                          address:
                            type: string
                            nullable: true
                            description: Street address for the company
                            example: 123 Main St
                          address_line_2:
                            type: string
                            nullable: true
                            description: Additional address information
                            example: Suite 500
                          city:
                            type: string
                            nullable: true
                            description: City
                            example: Austin
                          state:
                            type: string
                            nullable: true
                            description: State/province
                            example: TX
                          postal_code:
                            type: string
                            nullable: true
                            description: Postal/ZIP code
                            example: '78701'
                          country:
                            type: string
                            nullable: true
                            description: Country
                            example: USA
                          full_address:
                            type: string
                            nullable: true
                            description: Complete formatted address
                            example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                          shipping_first_name:
                            type: string
                            nullable: true
                            description: First name for shipping contact (legacy field)
                            example: John
                          shipping_last_name:
                            type: string
                            nullable: true
                            description: Last name for shipping contact (legacy field)
                            example: Doe
                          shipping_email:
                            type: string
                            format: email
                            nullable: true
                            description: Email for shipping contact (legacy field)
                            example: shipping@acmecorp.com
                          shipping_phone:
                            type: string
                            nullable: true
                            description: Phone number for shipping contact (legacy field)
                            example: 555-987-6543
                          shipping_address:
                            type: string
                            nullable: true
                            description: Shipping street address (legacy field)
                            example: 456 Warehouse Blvd
                          shipping_city:
                            type: string
                            nullable: true
                            description: Shipping city (legacy field)
                            example: Austin
                          shipping_state:
                            type: string
                            nullable: true
                            description: Shipping state/province (legacy field)
                            example: TX
                          shipping_postal_code:
                            type: string
                            nullable: true
                            description: Shipping postal/ZIP code (legacy field)
                            example: '78745'
                          shipping_country:
                            type: string
                            nullable: true
                            description: Shipping country (legacy field)
                            example: USA
                          shipping_full_address:
                            type: string
                            nullable: true
                            description: Complete formatted shipping address (legacy field)
                            example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                          payment_term:
                            type: string
                            nullable: true
                            description: Payment terms for the company
                            example: Net 30
                          tax_exempt:
                            type: boolean
                            nullable: true
                            description: Whether the company is exempt from taxes
                            example: false
                          tax_rate:
                            type: number
                            format: float
                            nullable: true
                            description: Tax rate applied to the company's orders
                            example: 8.25
                          due_date_days:
                            type: integer
                            nullable: true
                            description: Number of days until payment is due
                            example: 30
                          credit_limit:
                            type: number
                            format: float
                            nullable: true
                            description: Credit limit for the company. `null` means no limit is set.
                            example: 5000
                          header_discount_enabled:
                            type: boolean
                            description: Whether an order-header trade discount is applied by default for this company
                            example: false
                          header_discount_type:
                            type: string
                            nullable: true
                            enum:
                              - PERCENT
                              - FIXED_AMOUNT
                            description: How the header discount is calculated — a percentage of the order or a fixed amount
                            example: PERCENT
                          header_discount_value:
                            type: number
                            format: float
                            nullable: true
                            description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                            example: 5
                          header_discount_effective_from:
                            type: string
                            format: date
                            nullable: true
                            description: Date from which the header discount takes effect (YYYY-MM-DD)
                            example: '2026-01-01'
                          default_currency_code:
                            type: string
                            nullable: true
                            description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                            example: USD
                          price_level:
                            nullable: true
                            description: Price level associated with this company
                            type: object
                            properties:
                              id:
                                type: number
                                description: Unique identifier for the price level
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                description: When the price level was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the price level was last updated
                                example: '2023-03-15T14:30:00Z'
                              status:
                                type: string
                                description: Status of the price level
                                enum:
                                  - active
                                  - inactive
                                example: active
                              name:
                                type: string
                                description: Name of the price level
                                example: Wholesale
                              type:
                                type: string
                                description: Type of the price level
                                example: percentage
                              percent_increase:
                                type: number
                                format: float
                                description: Percentage increase (or decrease) for this price level
                                example: 15.5
                          notes:
                            type: string
                            nullable: true
                            description: Additional notes about the company
                            example: 'Key account, requires special handling'
                          fein:
                            type: string
                            nullable: true
                            description: Federal Employer Identification Number
                            example: 12-3456789
                          tags:
                            type: array
                            nullable: true
                            description: List of tags associated with the company
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the tag
                                name:
                                  type: string
                                  description: Name of the tag
                                description:
                                  type: string
                                  nullable: true
                                  description: Description of the tag
                                icon:
                                  type: string
                                  nullable: true
                                  description: Icon identifier or URL for the tag
                                color:
                                  type: string
                                  nullable: true
                                  description: Color code for the tag
                              required:
                                - id
                                - name
                          default_shipping:
                            nullable: true
                            description: Default shipping address
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the shipping address
                                example: 789
                              created_at:
                                type: string
                                format: date-time
                                description: When the shipping address was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the shipping address was last updated
                                example: '2023-03-15T14:30:00Z'
                              company_id:
                                type: integer
                                description: ID of the company this shipping address belongs to
                                example: 123456
                              company_name:
                                type: string
                                nullable: true
                                description: Name of the company
                                example: Acme Corporation
                              address:
                                type: string
                                description: Street address
                                example: 456 Warehouse Blvd
                              address_line_2:
                                type: string
                                nullable: true
                                description: Additional address information
                                example: Building 2
                              city:
                                type: string
                                description: City
                                example: Austin
                              state:
                                type: string
                                description: State/province
                                example: TX
                              postal_code:
                                type: string
                                description: Postal/ZIP code
                                example: '78745'
                              country:
                                type: string
                                description: Country
                                example: USA
                              full_address:
                                type: string
                                description: Complete formatted address
                                example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                              full_name:
                                type: string
                                description: Full name of the contact person
                                example: John Doe
                              first_name:
                                type: string
                                nullable: true
                                description: First name of the contact person
                                example: John
                              last_name:
                                type: string
                                nullable: true
                                description: Last name of the contact person
                                example: Doe
                              phone:
                                type: string
                                nullable: true
                                description: Phone number
                                example: 555-987-6543
                              email:
                                type: string
                                format: email
                                nullable: true
                                description: Email address
                                example: shipping@acmecorp.com
                              is_default:
                                type: boolean
                                description: Whether this is the default shipping address
                                example: true
                            required:
                              - id
                              - company_id
                              - address
                              - city
                              - state
                              - postal_code
                              - country
                          shipping_addresses:
                            type: array
                            nullable: true
                            description: List of shipping addresses for the company
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the shipping address
                                  example: 789
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was last updated
                                  example: '2023-03-15T14:30:00Z'
                                company_id:
                                  type: integer
                                  description: ID of the company this shipping address belongs to
                                  example: 123456
                                company_name:
                                  type: string
                                  nullable: true
                                  description: Name of the company
                                  example: Acme Corporation
                                address:
                                  type: string
                                  description: Street address
                                  example: 456 Warehouse Blvd
                                address_line_2:
                                  type: string
                                  nullable: true
                                  description: Additional address information
                                  example: Building 2
                                city:
                                  type: string
                                  description: City
                                  example: Austin
                                state:
                                  type: string
                                  description: State/province
                                  example: TX
                                postal_code:
                                  type: string
                                  description: Postal/ZIP code
                                  example: '78745'
                                country:
                                  type: string
                                  description: Country
                                  example: USA
                                full_address:
                                  type: string
                                  description: Complete formatted address
                                  example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                full_name:
                                  type: string
                                  description: Full name of the contact person
                                  example: John Doe
                                first_name:
                                  type: string
                                  nullable: true
                                  description: First name of the contact person
                                  example: John
                                last_name:
                                  type: string
                                  nullable: true
                                  description: Last name of the contact person
                                  example: Doe
                                phone:
                                  type: string
                                  nullable: true
                                  description: Phone number
                                  example: 555-987-6543
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  description: Email address
                                  example: shipping@acmecorp.com
                                is_default:
                                  type: boolean
                                  description: Whether this is the default shipping address
                                  example: true
                              required:
                                - id
                                - company_id
                                - address
                                - city
                                - state
                                - postal_code
                                - country
                          billing_info:
                            type: object
                            nullable: true
                            description: Billing information
                            properties:
                              id:
                                type: integer
                                example: 456
                              created_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              first_name:
                                type: string
                                nullable: true
                                example: Jane
                              last_name:
                                type: string
                                nullable: true
                                example: Smith
                              email:
                                type: string
                                format: email
                                nullable: true
                                example: accounting@acmecorp.com
                              receiving_bank_name:
                                type: string
                                nullable: true
                                example: First National Bank
                              receiving_bank_address:
                                type: string
                                nullable: true
                                example: '789 Finance Street, Austin, TX 78701'
                          client_type:
                            type: object
                            nullable: true
                            description: Type of client
                            properties:
                              id:
                                type: integer
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              name:
                                type: string
                                example: Retail
                              description:
                                type: string
                                nullable: true
                                example: Retail business client
                          parent_company_id:
                            type: integer
                            nullable: true
                            description: ID of the parent company
                            example: 456
                          invoice_export_template_id:
                            type: integer
                            nullable: true
                            description: ID of the invoice export template
                            example: 789
                          custom_fields:
                            type: object
                            description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                            example:
                              Industry: Manufacturing
                              Region: Southwest
                              Annual Revenue: $5M-$10M
                          assigned_sales_reps:
                            type: array
                            description: |
                              Sales rep users assigned to this company (Go Team members). Resolved from the company's
                              `goTeamMember.user` relation. Only present when the relation is loaded.
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: User ID of the assigned sales rep
                                  example: 42
                                email:
                                  type: string
                                  description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                  example: rep@example.com
                                first_name:
                                  type: string
                                  nullable: true
                                  example: Jane
                                last_name:
                                  type: string
                                  nullable: true
                                  example: Doe
                          sales_channel:
                            allOf:
                              - type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Sales channel ID.
                                  status:
                                    type: string
                                    description: Sales channel status (e.g. active).
                                  label:
                                    type: string
                                    nullable: true
                                    description: Human-readable channel label.
                                  channel_type:
                                    type: string
                                    nullable: true
                                    description: Channel type (e.g. the integration/platform the channel represents).
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            nullable: true
                            description: The company's default sales channel. Only present when the relation is loaded.
                        required:
                          - id
                          - name
                          - status
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the order item
                            line_number:
                              type: integer
                              description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            sku:
                              type: string
                              description: Stock keeping unit
                            name:
                              type: string
                              description: Product name
                            image_url:
                              type: string
                              description: URL of product image
                            weight:
                              type: object
                              description: Weight information
                            quantity:
                              type: number
                              format: float
                              description: Ordered quantity
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            shipping:
                              type: number
                              format: float
                              description: Shipping amount
                            warehouse_location:
                              type: string
                              description: Location in warehouse
                            options:
                              type: object
                              description: Additional options
                            fulfillment_sku:
                              type: string
                              description: SKU used for fulfillment
                            adjustment:
                              type: number
                              format: float
                              description: Price adjustment
                            upc:
                              type: string
                              description: Universal Product Code
                            stock_id:
                              type: integer
                              description: Stock identifier
                            kit_id:
                              type: integer
                              description: Kit identifier if part of a kit
                            non_physical_item:
                              type: boolean
                              description: Whether item is non-physical
                            ignore_item:
                              type: boolean
                              description: Whether to ignore this item
                            is_locally_added:
                              type: boolean
                              description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                            quantity_shipped:
                              type: number
                              format: float
                              description: Quantity shipped
                            quantity_cancelled:
                              type: number
                              format: float
                              description: Quantity cancelled
                            quantity_invoiced:
                              type: number
                              format: float
                              description: Quantity invoiced
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                            base_uom_id:
                              type: integer
                              description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                            ordered_uom_id:
                              type: integer
                              description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                            product_id:
                              type: integer
                              description: Product identifier
                            total_returned_base_quantity:
                              type: number
                              format: float
                              description: Total quantity returned
                            parent_id:
                              type: integer
                              description: Parent item ID
                            status:
                              type: string
                              description: Item status
                            discount:
                              type: number
                              format: float
                              description: Discount amount
                            estimated_ship_date:
                              type: string
                              format: date
                              description: Estimated shipping date
                            custom_fields:
                              type: object
                              description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties:
                                type: string
                            product:
                              type: object
                              description: Product information
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: number
                                  format: float
                                  description: Weight of the product
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                category:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                  description: Product category information
                                subcategory:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                  description: Product subcategory information
                                custom_fields:
                                  type: object
                                  description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                  additionalProperties:
                                    type: string
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Available variant attributes
                                sku:
                                  type: string
                                  description: Internal SKU
                                alternate_skus:
                                  type: array
                                  description: Alternate SKUs
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                tags:
                                  type: array
                                  description: Tags associated with the product
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the tag
                                      name:
                                        type: string
                                        description: Name of the tag
                                      description:
                                        type: string
                                        nullable: true
                                        description: Description of the tag
                                      icon:
                                        type: string
                                        nullable: true
                                        description: Icon identifier or URL for the tag
                                      color:
                                        type: string
                                        nullable: true
                                        description: Color code for the tag
                                    required:
                                      - id
                                      - name
                                supplier:
                                  type: object
                                  nullable: true
                                  description: Supplier information
                                type:
                                  type: string
                                  enum:
                                    - PRODUCT
                                    - KIT
                                  description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                kit_items:
                                  type: array
                                  nullable: true
                                  description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the kit item
                                      product_id:
                                        type: integer
                                        description: ID of the product component
                                      quantity:
                                        type: number
                                        format: float
                                        description: Quantity of this component in the kit
                                      uom_id:
                                        type: integer
                                        description: Unit of measure ID for the quantity
                                      base_uom_quantity:
                                        type: number
                                        format: float
                                        description: Quantity converted to base unit of measure
                                      price:
                                        type: number
                                        format: float
                                        description: Price for this kit item
                                      original_price:
                                        type: number
                                        format: float
                                        description: Original price for this kit item
                                      total:
                                        type: number
                                        format: float
                                        description: Calculated total (quantity * price)
                                      product:
                                        type: object
                                        nullable: true
                                        description: Product information for this kit item (when loaded)
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          sku:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          retail_price:
                                            type: number
                                            format: float
                                          wholesale_price:
                                            type: number
                                            format: float
                                      unit_of_measure:
                                        type: object
                                        nullable: true
                                        description: Unit of measure information (when loaded)
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          base_unit:
                                            type: boolean
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                            tags:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  description:
                                    type: string
                                  icon:
                                    type: string
                                  color:
                                    type: string
                                  discount_structure:
                                    type: object
                                  markup_structure:
                                    type: object
                              description: Tags associated with the sales order item
                        description: Line items in the order
                      fulfillment_orders:
                        type: array
                        description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Fulfillment order ID
                            order_number:
                              type: string
                              description: Fulfillment order number
                            order_key:
                              type: string
                              nullable: true
                              description: Fulfillment order key
                            order_status:
                              type: string
                              description: Fulfillment order status
                            sales_order_id:
                              type: integer
                              description: Associated sales order ID
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              description: Warehouse group ID
                            destination_oms_id:
                              type: integer
                              nullable: true
                              description: Destination app integration account ID
                            destination_oms_store_id:
                              type: integer
                              nullable: true
                            fulfillment_channel_id:
                              type: integer
                              nullable: true
                            pushed_at:
                              type: string
                              format: date-time
                              nullable: true
                            packing_slip_printed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                            error_message:
                              type: string
                              nullable: true
                              description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                            ship_by_date:
                              type: string
                              format: date
                              nullable: true
                              description: Ship by date
                            total:
                              type: number
                              format: float
                              nullable: true
                              description: Order total
                            bill_to:
                              type: object
                              nullable: true
                              description: Billing address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            ship_to:
                              type: object
                              nullable: true
                              description: Shipping address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            invoice_to:
                              type: object
                              nullable: true
                              description: Invoice address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            sales_order:
                              type: object
                              nullable: true
                              description: Nested sales order data
                            picklists:
                              type: array
                              description: Associated picklists
                              items:
                                type: object
                            fulfillment_order_items:
                              type: array
                              description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    nullable: true
                                    description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                  shipment_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the fulfillment order this line belongs to.
                                  status:
                                    nullable: true
                                    description: Line status.
                                  sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                  sku:
                                    type: string
                                    nullable: true
                                  name:
                                    type: string
                                    nullable: true
                                  weight:
                                    nullable: true
                                    description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                  dimensions:
                                    nullable: true
                                    description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                  quantity:
                                    type: number
                                    description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                  unit_price:
                                    type: number
                                    description: Unit price. Always `0` on synthetic component rows.
                                  lot_id:
                                    type: integer
                                    nullable: true
                                  lot_number:
                                    type: string
                                    nullable: true
                                  expiry_date:
                                    type: string
                                    nullable: true
                                    description: Lot expiry date.
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  is_kit_component:
                                    type: boolean
                                    description: True when the row is a component of a kit (stored or synthetic).
                                  parent_fulfillment_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                  kit_sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                  is_synthetic:
                                    type: boolean
                                    description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                            total_weight:
                              type: object
                              nullable: true
                              description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                              properties:
                                total_oz:
                                  type: number
                                  format: float
                                  description: Total weight in ounces
                                total_lb:
                                  type: number
                                  format: float
                                  description: Total weight in pounds
                                line_count:
                                  type: integer
                                  description: Number of fulfillment order lines
                                weighed_line_count:
                                  type: integer
                                  description: Number of lines that had a usable weight and contributed to the total
                                is_complete:
                                  type: boolean
                                  description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                            tags:
                              type: array
                              description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the tag
                                  name:
                                    type: string
                                    description: Name of the tag
                                  description:
                                    type: string
                                    nullable: true
                                    description: Description of the tag
                                  icon:
                                    type: string
                                    nullable: true
                                    description: Icon identifier or URL for the tag
                                  color:
                                    type: string
                                    nullable: true
                                    description: Color code for the tag
                                required:
                                  - id
                                  - name
                            purchase_orders:
                              type: array
                              description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  order_status:
                                    type: string
                                    nullable: true
                                    enum:
                                      - active
                                      - deleted
                                      - completed
                            source_reference_identifier:
                              type: string
                              nullable: true
                              description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                            held_for_item_change:
                              type: boolean
                              description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                            created_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was last updated
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                            icon:
                              type: string
                            color:
                              type: string
                            discount_structure:
                              type: object
                            markup_structure:
                              type: object
                        description: Tags associated with the order
                      shipments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the shipment
                            sales_order_id:
                              type: integer
                              description: ID of the associated sales order
                            shipped_by_user:
                              description: 'Luminous user who marked the parent sales order shipped, or `null` when not set. Who picked and packed is not stored on the shipment; see `picked_by_user` / `packed_by_user` on picklists.'
                              type: object
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                  nullable: true
                            ship_date:
                              type: string
                              format: date
                              description: Date when the shipment was or will be sent
                            tracking_number:
                              type: string
                              description: Tracking number for the shipment
                            tracking_url:
                              type: string
                              nullable: true
                              description: |
                                Tracking URL for the shipment. This is the stored URL, or a carrier URL built from the
                                tracking number when carrier tracking links are enabled for the tenant.
                            delivery_status:
                              type: string
                              nullable: true
                              enum:
                                - pre_transit
                                - in_transit
                                - out_for_delivery
                                - delivered
                                - exception
                                - null
                              description: |
                                Carrier delivery status from the Luminous label-tracking record that shares this
                                shipment's tracking number (and fulfillment order, when the shipment is bound to one).
                                `available_for_pickup` is reported as `out_for_delivery`; `failure`, `return_to_sender`,
                                `error`, and `cancelled` are reported as `exception`. `null` when Luminous has no
                                label-tracking record for the shipment (for example a tracking number imported from
                                ShipStation) or the carrier status is unknown.
                            delivered_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: |
                                Delivery timestamp from the same label-tracking record as `delivery_status`. `null` when
                                there is no tracking record or the shipment has not been delivered.
                            bol_number:
                              type: string
                              description: Bill of Lading Number for logistics tracking
                              example: BOL-123456789
                            pro_number:
                              type: string
                              description: Progressive Rotating Order Number (common in LTL shipping)
                              example: PRO-987654321
                            partner_reference_number:
                              type: string
                              description: General reference number from/for the shipping partner
                              example: PARTNER-REF-001
                            is_return:
                              type: boolean
                              description: Whether this is a return shipment
                            carrier_code:
                              type: string
                              description: 'Code identifying the carrier (e.g., ups, fedex)'
                            scac:
                              type: string
                              nullable: true
                              description: Standard Carrier Alpha Code (SCAC) for the shipment's carrier; included on outbound EDI 856/810 documents
                            service_code:
                              type: string
                              description: Code identifying the shipping service
                            package_code:
                              type: string
                              description: Code identifying the package type
                            shipment_cost:
                              type: number
                              format: float
                              description: Cost of shipping
                            insurance_cost:
                              type: number
                              format: float
                              description: Cost of insurance
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              description: ID of the warehouse group associated with this shipment (from the linked fulfillment order)
                            status:
                              type: integer
                              description: Status of the shipment
                            ship_to:
                              type: object
                              properties:
                                name:
                                  type: string
                                  description: Recipient name
                                company:
                                  type: string
                                  description: Company name
                                street1:
                                  type: string
                                  description: Primary street address
                                street2:
                                  type: string
                                  description: Secondary street address
                                street3:
                                  type: string
                                  description: Additional street address
                                city:
                                  type: string
                                  description: City
                                state:
                                  type: string
                                  description: State/province
                                postalCode:
                                  type: string
                                  description: Postal/ZIP code
                                country:
                                  type: string
                                  description: Country
                                phone:
                                  type: string
                                  description: Contact phone number
                                residential:
                                  type: boolean
                                  description: Whether this is a residential address
                            weight:
                              type: object
                              required:
                                - value
                                - units
                              properties:
                                value:
                                  type: number
                                  format: float
                                  description: Weight value
                                units:
                                  type: string
                                  enum:
                                    - ounces
                                    - pounds
                                    - grams
                                    - kilograms
                                  description: Unit of weight measurement
                            dimensions:
                              type: object
                              required:
                                - units
                                - length
                                - width
                                - height
                              properties:
                                units:
                                  type: string
                                  enum:
                                    - inches
                                    - centimeters
                                  description: Unit of dimensional measurement
                                length:
                                  type: number
                                  format: float
                                  description: Length of the package
                                width:
                                  type: number
                                  format: float
                                  description: Width of the package
                                height:
                                  type: number
                                  format: float
                                  description: Height of the package
                            items:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the shipment item
                                  shipment_id:
                                    type: integer
                                    description: ID of the parent shipment
                                  product_id:
                                    type: integer
                                    description: ID of the product being shipped
                                  sales_order_item_id:
                                    type: integer
                                    description: 'Luminous sales order line-item ID (the internal item primary key) for the line being shipped. This is the value to pass back as `order_item_id` when creating a shipment for this order. For kit/bundle component lines that share a single upstream channel line, each component is still returned with its own distinct `sales_order_item_id`.'
                                  quantity:
                                    type: number
                                    description: 'Quantity being shipped, expressed in the same unit of measure the associated sales order line was ordered in (the selling UoM, e.g. cartons) rather than internal base units. When the originating order line cannot be resolved, the stored quantity is returned as-is.'
                                  weight:
                                    type: object
                                    required:
                                      - value
                                      - units
                                    properties:
                                      value:
                                        type: number
                                        format: float
                                        description: Weight value
                                      units:
                                        type: string
                                        enum:
                                          - ounces
                                          - pounds
                                          - grams
                                          - kilograms
                                        description: Unit of weight measurement
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Price per unit
                                  lot_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the lot this shipment item was deducted from (CS-10083). `null` when the line has no lot. Populated from the `lot_id` submitted on shipment create; Luminous no longer re-infers a lot by FEFO/FIFO once a lot is named.
                                  lot_number:
                                    type: string
                                    nullable: true
                                    description: 'Lot number stamped on the item, falling back to the referenced lot''s number when only `lot_id` was submitted. `null` when the line has no lot.'
                                  expiry_date:
                                    type: string
                                    format: date
                                    nullable: true
                                    description: 'Expiry date of the lot (`YYYY-MM-DD`), falling back to the referenced lot. `null` when the line has no lot.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                              description: Items included in this shipment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the shipment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the shipment was last updated
                        description: Shipments associated with order
                      attachments:
                        type: array
                        items:
                          type: object
                          description: A file attached to a sales order.
                          properties:
                            id:
                              type: integer
                              description: Attachment ID
                            original_filename:
                              type: string
                              description: The original name of the uploaded file.
                            mime_type:
                              type: string
                              nullable: true
                              description: The file's MIME type (e.g. `application/pdf`).
                            size_bytes:
                              type: integer
                              description: File size in bytes.
                            uploaded_by:
                              type: object
                              nullable: true
                              description: The user who uploaded the file. Null if the uploader is unknown.
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: 'The uploader''s full name, or email address if no name is set.'
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: ISO 8601 timestamp of when the attachment was created.
                        description: 'Files attached to the order. Only present on the detail endpoint (this endpoint), not on the list endpoint.'
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
        '404':
          description: Sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    patch:
      operationId: updateSalesOrder
      tags:
        - Sales Orders
      summary: Update a sales order
      description: |
        Partially update an existing sales order. All body fields are optional — only send fields you want to change.

        ## Order Status Values
        Valid order statuses include: `pending`, `shipped`, `fulfilled`, `cancelled`,
        `awaiting_shipment`, `partially_shipped`, `on_hold`, `backorder`

        Status changes are applied through the canonical sales-order update flow, so moving an
        order to `shipped` creates a shipment and fires the related downstream events. Include
        `tracking_number` and `carrier_code` in the same request to stamp them onto that shipment.
        A status that cannot be applied returns `400`.

        ## Fields that are not updated
        Top-level body keys this endpoint does not write (for example read-only fields copied from a
        `GET` response) are ignored, and the `200` response lists them in `ignored_fields` next to `data`.
        If the body is non-empty and **every** key is ignored, the request returns `422` on `fields`
        ("None of the sent fields can be updated on a sales order: ...") instead of a `200` that changed nothing.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the sales order to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Sales order partial update. All fields are optional — only send fields to change.
              properties:
                order_status:
                  type: string
                  nullable: true
                  description: 'Order status. Valid values: pending, shipped, fulfilled, cancelled, awaiting_shipment, partially_shipped, on_hold, backorder. Status changes are routed through the canonical sales-order update flow, so transitioning to `shipped` creates a shipment (and fires the associated downstream events). Provide `tracking_number` and `carrier_code` in the same request to stamp them onto that shipment. A status that cannot be applied returns `400`.'
                customer_email:
                  type: string
                  format: email
                  nullable: true
                  description: Customer email address
                customer_username:
                  type: string
                  nullable: true
                  description: Customer username
                customer_po_number:
                  type: string
                  nullable: true
                  description: Customer purchase order number
                bill_to:
                  type: object
                  nullable: true
                  description: 'Billing address. If provided, `name` is required.'
                  required:
                    - name
                  properties:
                    name:
                      type: string
                      description: Recipient name (required)
                    company:
                      type: string
                      description: Company name
                    street1:
                      type: string
                      description: Address line 1
                    street2:
                      type: string
                      description: Address line 2
                    street3:
                      type: string
                      description: Address line 3
                    city:
                      type: string
                      description: City
                    state:
                      type: string
                      description: State or province
                    postal_code:
                      type: string
                      description: Postal / ZIP code
                    country:
                      type: string
                      maxLength: 2
                      description: Country code (2-character ISO)
                    phone:
                      type: string
                      description: Phone number
                ship_to:
                  type: object
                  nullable: true
                  description: 'Shipping address. If provided, `name` is required.'
                  required:
                    - name
                  properties:
                    name:
                      type: string
                      description: Recipient name (required)
                    company:
                      type: string
                      description: Company name
                    street1:
                      type: string
                      description: Address line 1
                    street2:
                      type: string
                      description: Address line 2
                    street3:
                      type: string
                      description: Address line 3
                    city:
                      type: string
                      description: City
                    state:
                      type: string
                      description: State or province
                    postal_code:
                      type: string
                      description: Postal / ZIP code
                    country:
                      type: string
                      maxLength: 2
                      description: Country code (2-character ISO)
                    phone:
                      type: string
                      description: Phone number
                ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: Ship date
                hold_until_date:
                  type: string
                  format: date
                  nullable: true
                  description: Hold until date
                ship_by_date:
                  type: string
                  format: date
                  nullable: true
                  description: Ship by date
                earliest_ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: Earliest ship date
                requested_shipping_service:
                  type: string
                  nullable: true
                  description: Requested shipping service
                carrier_code:
                  type: string
                  nullable: true
                  description: 'Carrier code. When `order_status` is set to `shipped`, this carrier is applied to the shipment created by the status change.'
                tracking_number:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: 'Tracking number. When `order_status` is set to `shipped`, this tracking number is applied to the shipment created by the status change.'
                service_code:
                  type: string
                  nullable: true
                  description: Service code
                customer_notes:
                  type: string
                  nullable: true
                  description: Customer-facing notes
                internal_notes:
                  type: string
                  nullable: true
                  description: Internal notes
                gift_message:
                  type: string
                  nullable: true
                  description: Gift message
                skip_sales_report:
                  type: boolean
                  description: |
                    Whether the order is left out of sales reporting. Can only be changed on a **posted** order: changing it on an unposted order returns `422` on `skip_sales_report` (set it when confirming the order instead). Sending the value the order already has is accepted and changes nothing, so a body copied from a GET is safe. A change is recorded in the order's history.
                gift:
                  type: boolean
                  description: Whether the order is a gift
                international_options:
                  type: array
                  nullable: true
                  description: International shipping options
                  items:
                    type: object
                custom_fields:
                  type: array
                  nullable: true
                  description: Custom field values
                  items:
                    nullable: true
                tags:
                  type: array
                  nullable: true
                  description: Array of tag strings
                  items:
                    type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the sales order
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the order was last updated
                      status:
                        type: string
                        description: Current status of the order
                      order_id:
                        type: string
                        description: External order identifier
                      order_number:
                        type: string
                        description: Order number
                      order_date:
                        type: string
                        format: date
                        description: Date when the order was placed
                      payment_date:
                        type: string
                        format: date
                        description: Date when payment was received
                      ship_by_date:
                        type: string
                        format: date
                        description: Required ship by date
                      age:
                        type: integer
                        description: Age of the order in days
                      order_status:
                        type: string
                        description: Status of the order
                      customer_id:
                        type: string
                        description: Customer identifier
                      customer_username:
                        type: string
                        description: Customer's username
                      customer_email:
                        type: string
                        description: Customer's email address
                      bill_to:
                        type: object
                        description: Billing information
                      ship_to:
                        type: object
                        description: Shipping information
                      requested_shipping_service:
                        type: string
                        nullable: true
                        description: What shipping service to use when shipping this order
                      total:
                        type: number
                        format: float
                        description: Total order amount
                      total_paid:
                        type: number
                        format: float
                        description: Amount paid
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping:
                        type: number
                        format: float
                        description: Total shipping amount
                      customer_notes:
                        type: string
                        description: Notes from the customer
                      internal_notes:
                        type: string
                        description: Internal notes
                      ship_date:
                        type: string
                        format: date
                        description: Date when order was shipped
                      hold_until_date:
                        type: string
                        format: date
                        description: Hold until date
                      earliest_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Earliest date the order can be shipped
                      user_id:
                        type: integer
                        description: User ID associated with the order
                      externally_fulfilled:
                        type: boolean
                        description: Whether the order is fulfilled externally
                      externally_fulfilled_by:
                        type: string
                        description: Entity fulfilling the order externally
                      is_posted:
                        type: boolean
                        description: Whether the order is posted
                      posted_by:
                        type: string
                        description: User who posted the order
                      not_sync:
                        type: boolean
                        description: Sync status
                      sales_posted:
                        type: boolean
                        description: Sales posting status
                      split_order:
                        type: boolean
                        description: Whether the order is split
                      skip_inventory:
                        type: boolean
                        description: Whether to skip inventory
                      skip_sales_report:
                        type: boolean
                        description: Whether to skip sales report
                      channel_id:
                        type: integer
                        description: Channel identifier
                      total_order_cost:
                        type: number
                        format: float
                        description: Total cost of order
                      total_order_quantity:
                        type: number
                        format: float
                        description: Total quantity of items
                      order_cost_details:
                        type: object
                        description: Detailed order cost information
                      source:
                        type: string
                        description: Order source
                      shipstation_order_id:
                        type: string
                        description: ShipStation order identifier
                      type:
                        type: string
                        description: Order type
                      parent_id:
                        type: integer
                        description: Parent order ID if applicable
                      shipping_revenue:
                        type: number
                        format: float
                        description: Revenue from shipping
                      product_total:
                        type: number
                        format: float
                        description: Total product amount
                      total_discount:
                        type: number
                        format: float
                        description: Total discount amount
                      picking_status:
                        type: string
                        description: Status of picking process
                      starred_description:
                        type: string
                        description: Description for starred orders
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      company_id:
                        type: integer
                        nullable: true
                        description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                        example: 123
                      company:
                        nullable: true
                        description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the company
                            example: 123456
                          created_at:
                            type: string
                            format: date-time
                            description: When the company was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the company was last updated
                            example: '2023-03-15T14:30:00Z'
                          status:
                            type: string
                            description: Status of the company
                            enum:
                              - active
                              - inactive
                            example: active
                          name:
                            type: string
                            description: Company name
                            example: Acme Corporation
                          type:
                            type: string
                            nullable: true
                            description: Type of business
                            example: Retail
                          phone:
                            type: string
                            nullable: true
                            description: Primary phone number for the company
                            example: 555-123-4567
                          address:
                            type: string
                            nullable: true
                            description: Street address for the company
                            example: 123 Main St
                          address_line_2:
                            type: string
                            nullable: true
                            description: Additional address information
                            example: Suite 500
                          city:
                            type: string
                            nullable: true
                            description: City
                            example: Austin
                          state:
                            type: string
                            nullable: true
                            description: State/province
                            example: TX
                          postal_code:
                            type: string
                            nullable: true
                            description: Postal/ZIP code
                            example: '78701'
                          country:
                            type: string
                            nullable: true
                            description: Country
                            example: USA
                          full_address:
                            type: string
                            nullable: true
                            description: Complete formatted address
                            example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                          shipping_first_name:
                            type: string
                            nullable: true
                            description: First name for shipping contact (legacy field)
                            example: John
                          shipping_last_name:
                            type: string
                            nullable: true
                            description: Last name for shipping contact (legacy field)
                            example: Doe
                          shipping_email:
                            type: string
                            format: email
                            nullable: true
                            description: Email for shipping contact (legacy field)
                            example: shipping@acmecorp.com
                          shipping_phone:
                            type: string
                            nullable: true
                            description: Phone number for shipping contact (legacy field)
                            example: 555-987-6543
                          shipping_address:
                            type: string
                            nullable: true
                            description: Shipping street address (legacy field)
                            example: 456 Warehouse Blvd
                          shipping_city:
                            type: string
                            nullable: true
                            description: Shipping city (legacy field)
                            example: Austin
                          shipping_state:
                            type: string
                            nullable: true
                            description: Shipping state/province (legacy field)
                            example: TX
                          shipping_postal_code:
                            type: string
                            nullable: true
                            description: Shipping postal/ZIP code (legacy field)
                            example: '78745'
                          shipping_country:
                            type: string
                            nullable: true
                            description: Shipping country (legacy field)
                            example: USA
                          shipping_full_address:
                            type: string
                            nullable: true
                            description: Complete formatted shipping address (legacy field)
                            example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                          payment_term:
                            type: string
                            nullable: true
                            description: Payment terms for the company
                            example: Net 30
                          tax_exempt:
                            type: boolean
                            nullable: true
                            description: Whether the company is exempt from taxes
                            example: false
                          tax_rate:
                            type: number
                            format: float
                            nullable: true
                            description: Tax rate applied to the company's orders
                            example: 8.25
                          due_date_days:
                            type: integer
                            nullable: true
                            description: Number of days until payment is due
                            example: 30
                          credit_limit:
                            type: number
                            format: float
                            nullable: true
                            description: Credit limit for the company. `null` means no limit is set.
                            example: 5000
                          header_discount_enabled:
                            type: boolean
                            description: Whether an order-header trade discount is applied by default for this company
                            example: false
                          header_discount_type:
                            type: string
                            nullable: true
                            enum:
                              - PERCENT
                              - FIXED_AMOUNT
                            description: How the header discount is calculated — a percentage of the order or a fixed amount
                            example: PERCENT
                          header_discount_value:
                            type: number
                            format: float
                            nullable: true
                            description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                            example: 5
                          header_discount_effective_from:
                            type: string
                            format: date
                            nullable: true
                            description: Date from which the header discount takes effect (YYYY-MM-DD)
                            example: '2026-01-01'
                          default_currency_code:
                            type: string
                            nullable: true
                            description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                            example: USD
                          price_level:
                            nullable: true
                            description: Price level associated with this company
                            type: object
                            properties:
                              id:
                                type: number
                                description: Unique identifier for the price level
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                description: When the price level was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the price level was last updated
                                example: '2023-03-15T14:30:00Z'
                              status:
                                type: string
                                description: Status of the price level
                                enum:
                                  - active
                                  - inactive
                                example: active
                              name:
                                type: string
                                description: Name of the price level
                                example: Wholesale
                              type:
                                type: string
                                description: Type of the price level
                                example: percentage
                              percent_increase:
                                type: number
                                format: float
                                description: Percentage increase (or decrease) for this price level
                                example: 15.5
                          notes:
                            type: string
                            nullable: true
                            description: Additional notes about the company
                            example: 'Key account, requires special handling'
                          fein:
                            type: string
                            nullable: true
                            description: Federal Employer Identification Number
                            example: 12-3456789
                          tags:
                            type: array
                            nullable: true
                            description: List of tags associated with the company
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the tag
                                name:
                                  type: string
                                  description: Name of the tag
                                description:
                                  type: string
                                  nullable: true
                                  description: Description of the tag
                                icon:
                                  type: string
                                  nullable: true
                                  description: Icon identifier or URL for the tag
                                color:
                                  type: string
                                  nullable: true
                                  description: Color code for the tag
                              required:
                                - id
                                - name
                          default_shipping:
                            nullable: true
                            description: Default shipping address
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the shipping address
                                example: 789
                              created_at:
                                type: string
                                format: date-time
                                description: When the shipping address was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the shipping address was last updated
                                example: '2023-03-15T14:30:00Z'
                              company_id:
                                type: integer
                                description: ID of the company this shipping address belongs to
                                example: 123456
                              company_name:
                                type: string
                                nullable: true
                                description: Name of the company
                                example: Acme Corporation
                              address:
                                type: string
                                description: Street address
                                example: 456 Warehouse Blvd
                              address_line_2:
                                type: string
                                nullable: true
                                description: Additional address information
                                example: Building 2
                              city:
                                type: string
                                description: City
                                example: Austin
                              state:
                                type: string
                                description: State/province
                                example: TX
                              postal_code:
                                type: string
                                description: Postal/ZIP code
                                example: '78745'
                              country:
                                type: string
                                description: Country
                                example: USA
                              full_address:
                                type: string
                                description: Complete formatted address
                                example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                              full_name:
                                type: string
                                description: Full name of the contact person
                                example: John Doe
                              first_name:
                                type: string
                                nullable: true
                                description: First name of the contact person
                                example: John
                              last_name:
                                type: string
                                nullable: true
                                description: Last name of the contact person
                                example: Doe
                              phone:
                                type: string
                                nullable: true
                                description: Phone number
                                example: 555-987-6543
                              email:
                                type: string
                                format: email
                                nullable: true
                                description: Email address
                                example: shipping@acmecorp.com
                              is_default:
                                type: boolean
                                description: Whether this is the default shipping address
                                example: true
                            required:
                              - id
                              - company_id
                              - address
                              - city
                              - state
                              - postal_code
                              - country
                          shipping_addresses:
                            type: array
                            nullable: true
                            description: List of shipping addresses for the company
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the shipping address
                                  example: 789
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was last updated
                                  example: '2023-03-15T14:30:00Z'
                                company_id:
                                  type: integer
                                  description: ID of the company this shipping address belongs to
                                  example: 123456
                                company_name:
                                  type: string
                                  nullable: true
                                  description: Name of the company
                                  example: Acme Corporation
                                address:
                                  type: string
                                  description: Street address
                                  example: 456 Warehouse Blvd
                                address_line_2:
                                  type: string
                                  nullable: true
                                  description: Additional address information
                                  example: Building 2
                                city:
                                  type: string
                                  description: City
                                  example: Austin
                                state:
                                  type: string
                                  description: State/province
                                  example: TX
                                postal_code:
                                  type: string
                                  description: Postal/ZIP code
                                  example: '78745'
                                country:
                                  type: string
                                  description: Country
                                  example: USA
                                full_address:
                                  type: string
                                  description: Complete formatted address
                                  example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                full_name:
                                  type: string
                                  description: Full name of the contact person
                                  example: John Doe
                                first_name:
                                  type: string
                                  nullable: true
                                  description: First name of the contact person
                                  example: John
                                last_name:
                                  type: string
                                  nullable: true
                                  description: Last name of the contact person
                                  example: Doe
                                phone:
                                  type: string
                                  nullable: true
                                  description: Phone number
                                  example: 555-987-6543
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  description: Email address
                                  example: shipping@acmecorp.com
                                is_default:
                                  type: boolean
                                  description: Whether this is the default shipping address
                                  example: true
                              required:
                                - id
                                - company_id
                                - address
                                - city
                                - state
                                - postal_code
                                - country
                          billing_info:
                            type: object
                            nullable: true
                            description: Billing information
                            properties:
                              id:
                                type: integer
                                example: 456
                              created_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              first_name:
                                type: string
                                nullable: true
                                example: Jane
                              last_name:
                                type: string
                                nullable: true
                                example: Smith
                              email:
                                type: string
                                format: email
                                nullable: true
                                example: accounting@acmecorp.com
                              receiving_bank_name:
                                type: string
                                nullable: true
                                example: First National Bank
                              receiving_bank_address:
                                type: string
                                nullable: true
                                example: '789 Finance Street, Austin, TX 78701'
                          client_type:
                            type: object
                            nullable: true
                            description: Type of client
                            properties:
                              id:
                                type: integer
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              name:
                                type: string
                                example: Retail
                              description:
                                type: string
                                nullable: true
                                example: Retail business client
                          parent_company_id:
                            type: integer
                            nullable: true
                            description: ID of the parent company
                            example: 456
                          invoice_export_template_id:
                            type: integer
                            nullable: true
                            description: ID of the invoice export template
                            example: 789
                          custom_fields:
                            type: object
                            description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                            example:
                              Industry: Manufacturing
                              Region: Southwest
                              Annual Revenue: $5M-$10M
                          assigned_sales_reps:
                            type: array
                            description: |
                              Sales rep users assigned to this company (Go Team members). Resolved from the company's
                              `goTeamMember.user` relation. Only present when the relation is loaded.
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: User ID of the assigned sales rep
                                  example: 42
                                email:
                                  type: string
                                  description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                  example: rep@example.com
                                first_name:
                                  type: string
                                  nullable: true
                                  example: Jane
                                last_name:
                                  type: string
                                  nullable: true
                                  example: Doe
                          sales_channel:
                            allOf:
                              - type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Sales channel ID.
                                  status:
                                    type: string
                                    description: Sales channel status (e.g. active).
                                  label:
                                    type: string
                                    nullable: true
                                    description: Human-readable channel label.
                                  channel_type:
                                    type: string
                                    nullable: true
                                    description: Channel type (e.g. the integration/platform the channel represents).
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            nullable: true
                            description: The company's default sales channel. Only present when the relation is loaded.
                        required:
                          - id
                          - name
                          - status
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the order item
                            line_number:
                              type: integer
                              description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            sku:
                              type: string
                              description: Stock keeping unit
                            name:
                              type: string
                              description: Product name
                            image_url:
                              type: string
                              description: URL of product image
                            weight:
                              type: object
                              description: Weight information
                            quantity:
                              type: number
                              format: float
                              description: Ordered quantity
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            shipping:
                              type: number
                              format: float
                              description: Shipping amount
                            warehouse_location:
                              type: string
                              description: Location in warehouse
                            options:
                              type: object
                              description: Additional options
                            fulfillment_sku:
                              type: string
                              description: SKU used for fulfillment
                            adjustment:
                              type: number
                              format: float
                              description: Price adjustment
                            upc:
                              type: string
                              description: Universal Product Code
                            stock_id:
                              type: integer
                              description: Stock identifier
                            kit_id:
                              type: integer
                              description: Kit identifier if part of a kit
                            non_physical_item:
                              type: boolean
                              description: Whether item is non-physical
                            ignore_item:
                              type: boolean
                              description: Whether to ignore this item
                            is_locally_added:
                              type: boolean
                              description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                            quantity_shipped:
                              type: number
                              format: float
                              description: Quantity shipped
                            quantity_cancelled:
                              type: number
                              format: float
                              description: Quantity cancelled
                            quantity_invoiced:
                              type: number
                              format: float
                              description: Quantity invoiced
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                            base_uom_id:
                              type: integer
                              description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                            ordered_uom_id:
                              type: integer
                              description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                            product_id:
                              type: integer
                              description: Product identifier
                            total_returned_base_quantity:
                              type: number
                              format: float
                              description: Total quantity returned
                            parent_id:
                              type: integer
                              description: Parent item ID
                            status:
                              type: string
                              description: Item status
                            discount:
                              type: number
                              format: float
                              description: Discount amount
                            estimated_ship_date:
                              type: string
                              format: date
                              description: Estimated shipping date
                            custom_fields:
                              type: object
                              description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties:
                                type: string
                            product:
                              type: object
                              description: Product information
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: number
                                  format: float
                                  description: Weight of the product
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                category:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                  description: Product category information
                                subcategory:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                  description: Product subcategory information
                                custom_fields:
                                  type: object
                                  description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                  additionalProperties:
                                    type: string
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Available variant attributes
                                sku:
                                  type: string
                                  description: Internal SKU
                                alternate_skus:
                                  type: array
                                  description: Alternate SKUs
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                tags:
                                  type: array
                                  description: Tags associated with the product
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the tag
                                      name:
                                        type: string
                                        description: Name of the tag
                                      description:
                                        type: string
                                        nullable: true
                                        description: Description of the tag
                                      icon:
                                        type: string
                                        nullable: true
                                        description: Icon identifier or URL for the tag
                                      color:
                                        type: string
                                        nullable: true
                                        description: Color code for the tag
                                    required:
                                      - id
                                      - name
                                supplier:
                                  type: object
                                  nullable: true
                                  description: Supplier information
                                type:
                                  type: string
                                  enum:
                                    - PRODUCT
                                    - KIT
                                  description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                kit_items:
                                  type: array
                                  nullable: true
                                  description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the kit item
                                      product_id:
                                        type: integer
                                        description: ID of the product component
                                      quantity:
                                        type: number
                                        format: float
                                        description: Quantity of this component in the kit
                                      uom_id:
                                        type: integer
                                        description: Unit of measure ID for the quantity
                                      base_uom_quantity:
                                        type: number
                                        format: float
                                        description: Quantity converted to base unit of measure
                                      price:
                                        type: number
                                        format: float
                                        description: Price for this kit item
                                      original_price:
                                        type: number
                                        format: float
                                        description: Original price for this kit item
                                      total:
                                        type: number
                                        format: float
                                        description: Calculated total (quantity * price)
                                      product:
                                        type: object
                                        nullable: true
                                        description: Product information for this kit item (when loaded)
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          sku:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          retail_price:
                                            type: number
                                            format: float
                                          wholesale_price:
                                            type: number
                                            format: float
                                      unit_of_measure:
                                        type: object
                                        nullable: true
                                        description: Unit of measure information (when loaded)
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          base_unit:
                                            type: boolean
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                            tags:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  description:
                                    type: string
                                  icon:
                                    type: string
                                  color:
                                    type: string
                                  discount_structure:
                                    type: object
                                  markup_structure:
                                    type: object
                              description: Tags associated with the sales order item
                        description: Line items in the order
                      fulfillment_orders:
                        type: array
                        description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Fulfillment order ID
                            order_number:
                              type: string
                              description: Fulfillment order number
                            order_key:
                              type: string
                              nullable: true
                              description: Fulfillment order key
                            order_status:
                              type: string
                              description: Fulfillment order status
                            sales_order_id:
                              type: integer
                              description: Associated sales order ID
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              description: Warehouse group ID
                            destination_oms_id:
                              type: integer
                              nullable: true
                              description: Destination app integration account ID
                            destination_oms_store_id:
                              type: integer
                              nullable: true
                            fulfillment_channel_id:
                              type: integer
                              nullable: true
                            pushed_at:
                              type: string
                              format: date-time
                              nullable: true
                            packing_slip_printed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                            error_message:
                              type: string
                              nullable: true
                              description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                            ship_by_date:
                              type: string
                              format: date
                              nullable: true
                              description: Ship by date
                            total:
                              type: number
                              format: float
                              nullable: true
                              description: Order total
                            bill_to:
                              type: object
                              nullable: true
                              description: Billing address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            ship_to:
                              type: object
                              nullable: true
                              description: Shipping address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            invoice_to:
                              type: object
                              nullable: true
                              description: Invoice address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            sales_order:
                              type: object
                              nullable: true
                              description: Nested sales order data
                            picklists:
                              type: array
                              description: Associated picklists
                              items:
                                type: object
                            fulfillment_order_items:
                              type: array
                              description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    nullable: true
                                    description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                  shipment_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the fulfillment order this line belongs to.
                                  status:
                                    nullable: true
                                    description: Line status.
                                  sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                  sku:
                                    type: string
                                    nullable: true
                                  name:
                                    type: string
                                    nullable: true
                                  weight:
                                    nullable: true
                                    description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                  dimensions:
                                    nullable: true
                                    description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                  quantity:
                                    type: number
                                    description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                  unit_price:
                                    type: number
                                    description: Unit price. Always `0` on synthetic component rows.
                                  lot_id:
                                    type: integer
                                    nullable: true
                                  lot_number:
                                    type: string
                                    nullable: true
                                  expiry_date:
                                    type: string
                                    nullable: true
                                    description: Lot expiry date.
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  is_kit_component:
                                    type: boolean
                                    description: True when the row is a component of a kit (stored or synthetic).
                                  parent_fulfillment_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                  kit_sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                  is_synthetic:
                                    type: boolean
                                    description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                            total_weight:
                              type: object
                              nullable: true
                              description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                              properties:
                                total_oz:
                                  type: number
                                  format: float
                                  description: Total weight in ounces
                                total_lb:
                                  type: number
                                  format: float
                                  description: Total weight in pounds
                                line_count:
                                  type: integer
                                  description: Number of fulfillment order lines
                                weighed_line_count:
                                  type: integer
                                  description: Number of lines that had a usable weight and contributed to the total
                                is_complete:
                                  type: boolean
                                  description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                            tags:
                              type: array
                              description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the tag
                                  name:
                                    type: string
                                    description: Name of the tag
                                  description:
                                    type: string
                                    nullable: true
                                    description: Description of the tag
                                  icon:
                                    type: string
                                    nullable: true
                                    description: Icon identifier or URL for the tag
                                  color:
                                    type: string
                                    nullable: true
                                    description: Color code for the tag
                                required:
                                  - id
                                  - name
                            purchase_orders:
                              type: array
                              description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  order_status:
                                    type: string
                                    nullable: true
                                    enum:
                                      - active
                                      - deleted
                                      - completed
                            source_reference_identifier:
                              type: string
                              nullable: true
                              description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                            held_for_item_change:
                              type: boolean
                              description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                            created_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was last updated
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                            icon:
                              type: string
                            color:
                              type: string
                            discount_structure:
                              type: object
                            markup_structure:
                              type: object
                        description: Tags associated with the order
                      shipments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the shipment
                            sales_order_id:
                              type: integer
                              description: ID of the associated sales order
                            shipped_by_user:
                              description: 'Luminous user who marked the parent sales order shipped, or `null` when not set. Who picked and packed is not stored on the shipment; see `picked_by_user` / `packed_by_user` on picklists.'
                              type: object
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                  nullable: true
                            ship_date:
                              type: string
                              format: date
                              description: Date when the shipment was or will be sent
                            tracking_number:
                              type: string
                              description: Tracking number for the shipment
                            tracking_url:
                              type: string
                              nullable: true
                              description: |
                                Tracking URL for the shipment. This is the stored URL, or a carrier URL built from the
                                tracking number when carrier tracking links are enabled for the tenant.
                            delivery_status:
                              type: string
                              nullable: true
                              enum:
                                - pre_transit
                                - in_transit
                                - out_for_delivery
                                - delivered
                                - exception
                                - null
                              description: |
                                Carrier delivery status from the Luminous label-tracking record that shares this
                                shipment's tracking number (and fulfillment order, when the shipment is bound to one).
                                `available_for_pickup` is reported as `out_for_delivery`; `failure`, `return_to_sender`,
                                `error`, and `cancelled` are reported as `exception`. `null` when Luminous has no
                                label-tracking record for the shipment (for example a tracking number imported from
                                ShipStation) or the carrier status is unknown.
                            delivered_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: |
                                Delivery timestamp from the same label-tracking record as `delivery_status`. `null` when
                                there is no tracking record or the shipment has not been delivered.
                            bol_number:
                              type: string
                              description: Bill of Lading Number for logistics tracking
                              example: BOL-123456789
                            pro_number:
                              type: string
                              description: Progressive Rotating Order Number (common in LTL shipping)
                              example: PRO-987654321
                            partner_reference_number:
                              type: string
                              description: General reference number from/for the shipping partner
                              example: PARTNER-REF-001
                            is_return:
                              type: boolean
                              description: Whether this is a return shipment
                            carrier_code:
                              type: string
                              description: 'Code identifying the carrier (e.g., ups, fedex)'
                            scac:
                              type: string
                              nullable: true
                              description: Standard Carrier Alpha Code (SCAC) for the shipment's carrier; included on outbound EDI 856/810 documents
                            service_code:
                              type: string
                              description: Code identifying the shipping service
                            package_code:
                              type: string
                              description: Code identifying the package type
                            shipment_cost:
                              type: number
                              format: float
                              description: Cost of shipping
                            insurance_cost:
                              type: number
                              format: float
                              description: Cost of insurance
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              description: ID of the warehouse group associated with this shipment (from the linked fulfillment order)
                            status:
                              type: integer
                              description: Status of the shipment
                            ship_to:
                              type: object
                              properties:
                                name:
                                  type: string
                                  description: Recipient name
                                company:
                                  type: string
                                  description: Company name
                                street1:
                                  type: string
                                  description: Primary street address
                                street2:
                                  type: string
                                  description: Secondary street address
                                street3:
                                  type: string
                                  description: Additional street address
                                city:
                                  type: string
                                  description: City
                                state:
                                  type: string
                                  description: State/province
                                postalCode:
                                  type: string
                                  description: Postal/ZIP code
                                country:
                                  type: string
                                  description: Country
                                phone:
                                  type: string
                                  description: Contact phone number
                                residential:
                                  type: boolean
                                  description: Whether this is a residential address
                            weight:
                              type: object
                              required:
                                - value
                                - units
                              properties:
                                value:
                                  type: number
                                  format: float
                                  description: Weight value
                                units:
                                  type: string
                                  enum:
                                    - ounces
                                    - pounds
                                    - grams
                                    - kilograms
                                  description: Unit of weight measurement
                            dimensions:
                              type: object
                              required:
                                - units
                                - length
                                - width
                                - height
                              properties:
                                units:
                                  type: string
                                  enum:
                                    - inches
                                    - centimeters
                                  description: Unit of dimensional measurement
                                length:
                                  type: number
                                  format: float
                                  description: Length of the package
                                width:
                                  type: number
                                  format: float
                                  description: Width of the package
                                height:
                                  type: number
                                  format: float
                                  description: Height of the package
                            items:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the shipment item
                                  shipment_id:
                                    type: integer
                                    description: ID of the parent shipment
                                  product_id:
                                    type: integer
                                    description: ID of the product being shipped
                                  sales_order_item_id:
                                    type: integer
                                    description: 'Luminous sales order line-item ID (the internal item primary key) for the line being shipped. This is the value to pass back as `order_item_id` when creating a shipment for this order. For kit/bundle component lines that share a single upstream channel line, each component is still returned with its own distinct `sales_order_item_id`.'
                                  quantity:
                                    type: number
                                    description: 'Quantity being shipped, expressed in the same unit of measure the associated sales order line was ordered in (the selling UoM, e.g. cartons) rather than internal base units. When the originating order line cannot be resolved, the stored quantity is returned as-is.'
                                  weight:
                                    type: object
                                    required:
                                      - value
                                      - units
                                    properties:
                                      value:
                                        type: number
                                        format: float
                                        description: Weight value
                                      units:
                                        type: string
                                        enum:
                                          - ounces
                                          - pounds
                                          - grams
                                          - kilograms
                                        description: Unit of weight measurement
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Price per unit
                                  lot_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the lot this shipment item was deducted from (CS-10083). `null` when the line has no lot. Populated from the `lot_id` submitted on shipment create; Luminous no longer re-infers a lot by FEFO/FIFO once a lot is named.
                                  lot_number:
                                    type: string
                                    nullable: true
                                    description: 'Lot number stamped on the item, falling back to the referenced lot''s number when only `lot_id` was submitted. `null` when the line has no lot.'
                                  expiry_date:
                                    type: string
                                    format: date
                                    nullable: true
                                    description: 'Expiry date of the lot (`YYYY-MM-DD`), falling back to the referenced lot. `null` when the line has no lot.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                              description: Items included in this shipment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the shipment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the shipment was last updated
                        description: Shipments associated with order
                      attachments:
                        type: array
                        items:
                          type: object
                          description: A file attached to a sales order.
                          properties:
                            id:
                              type: integer
                              description: Attachment ID
                            original_filename:
                              type: string
                              description: The original name of the uploaded file.
                            mime_type:
                              type: string
                              nullable: true
                              description: The file's MIME type (e.g. `application/pdf`).
                            size_bytes:
                              type: integer
                              description: File size in bytes.
                            uploaded_by:
                              type: object
                              nullable: true
                              description: The user who uploaded the file. Null if the uploader is unknown.
                              properties:
                                id:
                                  type: integer
                                  description: User ID
                                name:
                                  type: string
                                  nullable: true
                                  description: 'The uploader''s full name, or email address if no name is set.'
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: ISO 8601 timestamp of when the attachment was created.
                        description: 'Files attached to the order. Only present on the detail endpoint (this endpoint), not on the list endpoint.'
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                  ignored_fields:
                    type: array
                    items:
                      type: string
                    description: Top-level keys from the request body that this endpoint does not write and were ignored. Only present when at least one key was ignored.
                    example:
                      - order_number
                      - created_at
        '400':
          description: Status change could not be applied (e.g. invalid status transition)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, including `skip_sales_report` changed on an unposted order, or a body whose keys are all fields this endpoint does not update (error on `fields`)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/sales-orders/{salesOrderId}/allocation-availability':
    get:
      operationId: getSalesOrderAllocationAvailability
      tags:
        - Sales Orders
      summary: Get purchase-to-order allocation availability
      description: |
        Read what each fulfillable line of a sales order can be sourced from right now — the read surface
        behind the in-app allocation planner, exposed so a caller can see availability **before** calling
        `POST /purchase-orders/{purchaseOrderId}/allocate` (rather than allocating blind and guessing the
        PO line).

        Per line: on-hand by warehouse group and each open incoming purchase-order line — **with its
        `purchase_order_item_id`** (the id you peg against), the container's alternate id, its ETA and how
        much of it is still free to allocate — plus the routing-suggested channel. A **kit** line is flagged
        `is_kit` and carries a `components` array: one entry per component (the same availability shape),
        each carrying its own `sales_item_id`, which is the grain a kit allocation targets.

        ## Allocation workflow

        1. **See what a line can be sourced from** — this endpoint.
        2. *(optional)* find the container PO by its number / alternate id — `GET /purchase-orders`
           filtered on the alternate id (e.g. a container code like `SYD7967`).
        3. **Allocate** — `POST /purchase-orders/{purchaseOrderId}/allocate`.
        4. **Read the pegs back** — `GET /purchase-orders/{id}`; each line's `allocations[].peg_ids`
           lists the peg ids.
        5. **Reverse (unallocate)** — `POST /purchase-orders/reverse-allocation` with a `peg_id`.

        Requires the **purchase-to-order** feature; without it the endpoint returns `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      responses:
        '200':
          description: Allocation availability for the sales order
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      sales_order_id:
                        type: integer
                        example: 3048
                      ship_complete:
                        type: boolean
                        description: Whether the order requires ship-complete fulfillment.
                        example: false
                      lines:
                        type: array
                        items:
                          type: object
                          description: |
                            Purchase-to-order sourcing availability for a single sales-order line. Shows what the line can be
                            sourced from right now: on-hand by warehouse group and each open incoming purchase-order line — with
                            the `purchase_order_item_id` you peg against — plus the routing-suggested channel.
                          properties:
                            sales_order_item_id:
                              type: integer
                              description: The sales-order line item id this availability entry is for.
                              example: 6982
                            rfq_id:
                              type: integer
                              description: The product (RFQ) id of the line.
                              example: 4464
                            sku:
                              type: string
                              nullable: true
                              example: AS-9061-1.5ER-HESPER-THISTLE
                            name:
                              type: string
                              nullable: true
                              example: Cloud Cosy End Chair Right - HESPER - THISTLE
                            line_quantity:
                              type: number
                              description: Ordered quantity on the line.
                              example: 1
                            already_allocated:
                              type: number
                              description: Quantity of the line already pegged against supply.
                              example: 0
                            is_kit:
                              type: boolean
                              description: |
                                When `true`, this line is a kit and its `components` array carries the per-component availability;
                                a kit is allocated at component grain (pass `sales_item_id` per allocation on the allocate call).
                              example: false
                            suggested_channel_id:
                              type: integer
                              nullable: true
                              description: The routing-suggested fulfillment channel id for the line.
                              example: 14
                            preferred_vendor_id:
                              type: integer
                              nullable: true
                              description: 'Preferred supplier id for the product, when one is configured.'
                              example: null
                            preferred_vendor_name:
                              type: string
                              nullable: true
                              example: null
                            warehouse_groups:
                              type: array
                              description: Sourcing availability broken down by warehouse group.
                              items:
                                type: object
                                description: Purchase-to-order sourcing availability within a single warehouse group.
                                properties:
                                  warehouse_group_id:
                                    type: integer
                                    example: 2
                                  warehouse_group_name:
                                    type: string
                                    nullable: true
                                    example: Sydney
                                  channels:
                                    type: array
                                    description: The channels tied to this warehouse group.
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          example: 14
                                        label:
                                          type: string
                                          example: SYD
                                  on_hand_available:
                                    type: number
                                    description: Quantity available to allocate from on-hand stock in this warehouse group.
                                    example: 0
                                  incoming_pos:
                                    type: array
                                    description: 'Open incoming purchase-order lines that can supply this line, in this warehouse group.'
                                    items:
                                      type: object
                                      properties:
                                        purchase_order_id:
                                          type: integer
                                          example: 28
                                        purchase_order_item_id:
                                          type: integer
                                          description: 'The PO line item id to peg against on `POST /purchase-orders/{id}/allocate`.'
                                          example: 731
                                        alternate_id:
                                          type: string
                                          nullable: true
                                          description: The container's alternate id / code (e.g. a container code like `SYD7967`).
                                          example: SYD7967
                                        warehouse_name:
                                          type: string
                                          nullable: true
                                          example: Sydney DC
                                        eta:
                                          type: string
                                          nullable: true
                                          description: Estimated arrival date of the incoming PO line (`YYYY-MM-DD`).
                                          example: '2026-08-21'
                                        available_to_allocate:
                                          type: number
                                          description: Quantity of this incoming PO line still free to allocate.
                                          example: 1
                                  incoming_totals:
                                    type: object
                                    properties:
                                      po_count:
                                        type: integer
                                        description: Number of open incoming PO lines in this warehouse group.
                                        example: 1
                                      free_to_allocate:
                                        type: number
                                        description: Total quantity across `incoming_pos` still free to allocate.
                                        example: 1
                                  has_more_incoming:
                                    type: boolean
                                    description: Whether more incoming PO lines exist beyond those returned in `incoming_pos`.
                                    example: false
                            components:
                              type: array
                              description: |
                                Present only on kit lines (`is_kit: true`). One entry per kit component, each with the same
                                availability shape as a line plus its own `sales_item_id` (the allocation grain).
                              items:
                                type: object
                                description: |
                                  Purchase-to-order sourcing availability for a single kit component. Same shape as a top-level line,
                                  plus its own `sales_item_id` — the grain a kit allocation targets.
                                properties:
                                  sales_item_id:
                                    type: integer
                                    description: |
                                      The peg grain for the component — the `mt_shipstation_sales_items` id that a kit allocation targets.
                                    example: 14961
                                  sales_order_item_id:
                                    type: integer
                                    example: 7001
                                  rfq_id:
                                    type: integer
                                    description: The product (RFQ) id of the component.
                                    example: 1801
                                  sku:
                                    type: string
                                    nullable: true
                                    example: COMP-A
                                  name:
                                    type: string
                                    nullable: true
                                  line_quantity:
                                    type: number
                                    example: 1
                                  already_allocated:
                                    type: number
                                    example: 0
                                  is_kit:
                                    type: boolean
                                    example: false
                                  suggested_channel_id:
                                    type: integer
                                    nullable: true
                                    example: 14
                                  preferred_vendor_id:
                                    type: integer
                                    nullable: true
                                    example: null
                                  preferred_vendor_name:
                                    type: string
                                    nullable: true
                                    example: null
                                  warehouse_groups:
                                    type: array
                                    description: Sourcing availability broken down by warehouse group.
                                    items:
                                      type: object
                                      description: Purchase-to-order sourcing availability within a single warehouse group.
                                      properties:
                                        warehouse_group_id:
                                          type: integer
                                          example: 2
                                        warehouse_group_name:
                                          type: string
                                          nullable: true
                                          example: Sydney
                                        channels:
                                          type: array
                                          description: The channels tied to this warehouse group.
                                          items:
                                            type: object
                                            properties:
                                              id:
                                                type: integer
                                                example: 14
                                              label:
                                                type: string
                                                example: SYD
                                        on_hand_available:
                                          type: number
                                          description: Quantity available to allocate from on-hand stock in this warehouse group.
                                          example: 0
                                        incoming_pos:
                                          type: array
                                          description: 'Open incoming purchase-order lines that can supply this line, in this warehouse group.'
                                          items:
                                            type: object
                                            properties:
                                              purchase_order_id:
                                                type: integer
                                                example: 28
                                              purchase_order_item_id:
                                                type: integer
                                                description: 'The PO line item id to peg against on `POST /purchase-orders/{id}/allocate`.'
                                                example: 731
                                              alternate_id:
                                                type: string
                                                nullable: true
                                                description: The container's alternate id / code (e.g. a container code like `SYD7967`).
                                                example: SYD7967
                                              warehouse_name:
                                                type: string
                                                nullable: true
                                                example: Sydney DC
                                              eta:
                                                type: string
                                                nullable: true
                                                description: Estimated arrival date of the incoming PO line (`YYYY-MM-DD`).
                                                example: '2026-08-21'
                                              available_to_allocate:
                                                type: number
                                                description: Quantity of this incoming PO line still free to allocate.
                                                example: 1
                                        incoming_totals:
                                          type: object
                                          properties:
                                            po_count:
                                              type: integer
                                              description: Number of open incoming PO lines in this warehouse group.
                                              example: 1
                                            free_to_allocate:
                                              type: number
                                              description: Total quantity across `incoming_pos` still free to allocate.
                                              example: 1
                                        has_more_incoming:
                                          type: boolean
                                          description: Whether more incoming PO lines exist beyond those returned in `incoming_pos`.
                                          example: false
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Purchase-to-order is not enabled for this account
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/items/fulfillment-priority-list':
    post:
      operationId: setSalesOrderItemFulfillmentPriorityList
      tags:
        - Sales Orders
      summary: Set sales order lines' fulfillment priority list
      description: |
        Set, change, or clear the line-level fulfillment priority list on named lines of one sales
        order, then re-route those lines the way the Re-route tool does: each affected fulfillment
        order is deleted (unpushed first if it was pushed) and regenerated under the new list.
        Send `dry_run: true` to preview the plan without writing anything.

        - **Targets:** each item gives `fulfillment_priority_list_id` **or**
          `fulfillment_priority_list_name` (case-insensitive), not both. Send
          `"fulfillment_priority_list_id": null` to clear the line's list; the line then falls back
          to the order's list, then the product's, then the default list. Up to 500 items.
          Only lists you manage can be targeted: a deleted list or a hidden system re-route list
          (named `Re-route: <channel>`) is refused with `422` like an unknown one, by id or by name.
        - **Scope:** the order-level list and other lines are not changed, except a line merged with
          a named line on the same fulfillment order line (identical SKU). That line moves with the
          named line and is returned with `merged: true`.
        - **Skipped lines:** a line whose fulfillment order is on an active picklist, has shipped
          (or partly shipped), has been cancelled, or could not be deleted keeps its list and is
          returned as `skipped` (`will_skip` in a dry run) with a `reason`. Unlike the Re-route
          tool, this endpoint never deletes a shipped or cancelled fulfillment order.
        - **Synchronous:** runs in the request for the one sales order. The sales order history
          entry is attributed to the API token and lists each changed line with its old and new
          list ids.
        - **Retries:** after a timeout, don't retry blindly. A retry sees the lines already on the
          new list and does nothing. Read the sales order instead; if it has no fulfillment orders,
          call `POST /sales-orders/{salesOrderId}/auto-generate-fulfillment-orders`.

        Requires the `salesOrders.update` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  minItems: 1
                  maxItems: 500
                  description: Lines to update. Each `sales_order_item_id` may appear only once.
                  items:
                    type: object
                    required:
                      - sales_order_item_id
                    properties:
                      sales_order_item_id:
                        type: integer
                        description: Sales order line item ID (must belong to this sales order).
                      fulfillment_priority_list_id:
                        type: integer
                        nullable: true
                        description: |
                          Target fulfillment priority list ID. Send `null` explicitly to clear the
                          line's list. Do not send together with `fulfillment_priority_list_name`.
                      fulfillment_priority_list_name:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Target fulfillment priority list name (case-insensitive).
                dry_run:
                  type: boolean
                  default: false
                  description: 'When `true`, return the plan and write nothing.'
                notes:
                  type: string
                  maxLength: 2000
                  nullable: true
                  description: Optional note recorded with the change.
            example:
              items:
                - sales_order_item_id: 123
                  fulfillment_priority_list_name: Freight
                - sales_order_item_id: 124
                  fulfillment_priority_list_id: 3
                - sales_order_item_id: 125
                  fulfillment_priority_list_id: null
              dry_run: true
              notes: Freight-sized lines
      responses:
        '200':
          description: |
            Dry-run plan or apply result. A dry run returns `lines`, `will_unpush_fo_ids`, and
            `preview`. An apply returns `lines` and `result`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      dry_run:
                        type: boolean
                      lines:
                        type: array
                        items:
                          type: object
                          properties:
                            sales_order_item_id:
                              type: integer
                            from_fulfillment_priority_list_id:
                              type: integer
                              nullable: true
                              description: Line's list before the change (`null` = none).
                            to_fulfillment_priority_list_id:
                              type: integer
                              nullable: true
                              description: Line's target list (`null` = cleared).
                            merged:
                              type: boolean
                              description: True when the line was not named but moves with a named line merged with it on a fulfillment order line.
                            status:
                              type: string
                              enum:
                                - will_change
                                - will_skip
                                - unchanged
                                - changed
                                - skipped
                              description: |
                                Dry run: `will_change`, `will_skip`, or `unchanged`.
                                Apply: `changed`, `skipped`, or `unchanged`.
                            reason:
                              type: string
                              description: Present on `will_skip` / `skipped` lines.
                              example: Its fulfillment order has an active picklist.
                      will_unpush_fo_ids:
                        type: array
                        description: Dry run only. Pushed fulfillment orders that would be unpushed and deleted.
                        items:
                          type: integer
                      preview:
                        type: object
                        description: Dry run only. The Re-route preview.
                        properties:
                          as_of:
                            type: string
                            description: Inventory snapshot timestamp the preview was computed at.
                          summary:
                            type: object
                            properties:
                              fo_count:
                                type: integer
                              so_count:
                                type: integer
                              items_changed:
                                type: integer
                          per_so:
                            type: array
                            items:
                              type: object
                              properties:
                                sales_order_id:
                                  type: integer
                                would_split_into:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      warehouse_group_id:
                                        type: integer
                                        nullable: true
                                      fulfillment_priority_list_id:
                                        type: integer
                                      sales_order_item_ids:
                                        type: array
                                        items:
                                          type: integer
                                deleted_fo_ids:
                                  type: array
                                  items:
                                    type: integer
                                skipped_fo_ids:
                                  type: array
                                  description: 'Fulfillment orders on a picklist, left untouched.'
                                  items:
                                    type: integer
                                unroutable_item_ids:
                                  type: array
                                  description: Lines whose target list has no stock.
                                  items:
                                    type: integer
                                blocked_reasons:
                                  type: array
                                  items:
                                    type: string
                      result:
                        type: object
                        description: Apply only. The Re-route result for this sales order.
                        properties:
                          sales_order_id:
                            type: integer
                          status:
                            type: string
                            enum:
                              - success
                              - skipped
                              - failed
                          items_updated:
                            type: integer
                          deleted_fo_ids:
                            type: array
                            items:
                              type: integer
                          regenerated_fo_ids:
                            type: array
                            items:
                              type: integer
                          skipped_fo_ids:
                            type: array
                            items:
                              type: integer
                          errors:
                            type: array
                            items:
                              type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation failed (a line is not on this sales order, a list is unknown, deleted, or a
            system re-route list, an
            item names no list, or names both an id and a name), or the apply failed
            (`result.status` is `failed`, for example fulfillment orders were deleted but none were
            regenerated). A failed apply returns the same `data` body as a `200`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/items/{salesOrderItemId}/remap-preview':
    get:
      operationId: previewSalesOrderItemRemap
      tags:
        - Sales Orders
      summary: Preview a sales-order item remap
      description: |
        Dry-run a remap of a single posted line item to a different product. Reports
        whether the remap is allowed, whether a `force` flag is required, and what
        will happen to the fulfillment order — **without mutating anything**.

        Purgatory mapping only covers pre-posting orders, so this (and the
        [remap](/api-reference/sales-orders/remap-a-sales-order-item) endpoint) are
        the posted-order counterpart: they let you correct an incorrect product
        mapping on an already-posted order and re-post that one line.

        Always returns `200` — even when the remap is blocked — so the caller can
        read `blocked_reason`. Shipped/cancelled/refunded orders and
        already-shipped or invoiced line items are hard-blocked; a line item split
        across multiple fulfillment orders is also blocked (the split block is
        scoped to the target item, not the whole order); a pushed fulfillment
        order sets `requires_force`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
        - in: path
          name: salesOrderItemId
          required: true
          schema:
            type: integer
          description: Sales order line-item ID (must belong to the sales order)
        - in: query
          name: product_id
          required: true
          schema:
            type: integer
            minimum: 1
          description: ID of the product to remap the line item to
        - in: query
          name: force
          required: false
          schema:
            type: boolean
            default: false
          description: |
            Evaluate the plan as if `force` were passed — i.e. treat a pushed
            fulfillment order as something that will be unpushed, deleted, and
            recreated rather than a block.
      responses:
        '200':
          description: Remap plan (the remap may still be blocked — check `allowed`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Result of analysing a posted-order line-item remap. Returned by the
                      `remap-preview` endpoint and by the `remap` endpoint when `dry_run` is true.
                      Lets a caller decide whether to proceed before mutating — whether the remap is
                      allowed, whether a `force` flag is required, and what will happen to the
                      fulfillment order.
                    properties:
                      allowed:
                        type: boolean
                        description: Whether the remap can proceed as requested.
                      blocked_reason:
                        type: string
                        nullable: true
                        description: |
                          Human-readable reason the remap is blocked. Populated only when `allowed`
                          is `false`. Hard blocks include invoiced, shipped, split, or cancelled
                          orders.
                      requires_force:
                        type: boolean
                        description: |
                          `true` when the only thing standing in the way is a pushed fulfillment
                          order and the caller did not pass `force`. Re-submit with `force=true` to
                          unpush, delete, and recreate the fulfillment order.
                      fulfillment_order_exists:
                        type: boolean
                        description: Whether the sales order currently has a fulfillment order.
                      fulfillment_order_id:
                        type: integer
                        nullable: true
                        description: 'ID of the existing fulfillment order, when one exists.'
                      fo_is_pushed:
                        type: boolean
                        description: Whether the existing fulfillment order has been pushed to a source/3PL.
                      fo_action:
                        type: string
                        enum:
                          - none
                          - delete_and_recreate
                        description: |
                          What will happen to the fulfillment order on commit. `none` when no
                          fulfillment order exists; `delete_and_recreate` when an existing one will
                          be deleted and regenerated for the new product.
                      will_delete_fulfillment_order:
                        type: boolean
                        description: Convenience flag — `true` when `fo_action` is `delete_and_recreate`.
                      will_recreate_fulfillment_order:
                        type: boolean
                        description: Whether a new fulfillment order will be generated after the remap.
                      will_delete_invoice:
                        type: boolean
                        description: |
                          `true` when an invoice is linked to the fulfillment order. This is a hard
                          block — invoices are never auto-voided, so the remap is rejected.
                      old_product_id:
                        type: integer
                        description: ID of the product the line item is currently mapped to.
                      new_product_id:
                        type: integer
                        description: ID of the product the line item will be remapped to.
                      warnings:
                        type: array
                        items:
                          type: string
                        description: Non-blocking warnings about the planned remap.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Sales order or line item not found, or item does not belong to the order'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/items/{salesOrderItemId}/remap':
    patch:
      operationId: remapSalesOrderItem
      tags:
        - Sales Orders
      summary: Remap a sales-order item
      description: |
        Remap a single posted line item to a different product and re-post the
        order's sales items. Use this to correct an incorrect product mapping on an
        already-posted sales order (purgatory mapping only covers pre-posting
        orders).

        The service evaluates a guardrail matrix before acting:

        - If a fulfillment order exists, it is deleted and recreated for the new
          product.
        - A **pushed** fulfillment order is blocked unless `force` is `true`, in
          which case it is unpushed, deleted, and recreated.
        - Shipped, cancelled, and refunded orders are **hard-blocked**, as are
          line items that have already shipped or been invoiced — invoices are
          never auto-voided.
        - The split-fulfillment block is scoped to the **target line item**: a
          remap is blocked only when that item itself spans multiple fulfillment
          orders, not merely because the order as a whole is split.

        Pass `dry_run=true` to get the same plan as the
        [preview](/api-reference/sales-orders/preview-a-sales-order-item-remap)
        endpoint without mutating. When a guardrail blocks the remap at commit time
        the endpoint returns `422` with a `message`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
        - in: path
          name: salesOrderItemId
          required: true
          schema:
            type: integer
          description: Sales order line-item ID (must belong to the sales order)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - product_id
              properties:
                product_id:
                  type: integer
                  minimum: 1
                  description: ID of the product to remap the line item to
                add_as_alternate_sku:
                  type: boolean
                  default: false
                  description: |
                    When `true`, record the line's original SKU as an alternate SKU
                    on the new product so future orders auto-map to it.
                force:
                  type: boolean
                  default: false
                  description: |
                    Proceed even when the fulfillment order is pushed — unpushes,
                    deletes, and recreates it. Without this, a pushed fulfillment
                    order blocks the remap.
                dry_run:
                  type: boolean
                  default: false
                  description: |
                    Evaluate only and return the remap plan; mutate nothing. The
                    response is the same plan shape as the `remap-preview` endpoint.
      responses:
        '200':
          description: |
            When `dry_run` is `false`, the remapped line item. When `dry_run` is
            `true`, the remap plan.
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    title: Remapped line item
                    properties:
                      data:
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the order item
                          line_number:
                            type: integer
                            description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                          created_at:
                            type: string
                            format: date-time
                            description: Creation timestamp
                          updated_at:
                            type: string
                            format: date-time
                            description: Last update timestamp
                          sku:
                            type: string
                            description: Stock keeping unit
                          name:
                            type: string
                            description: Product name
                          image_url:
                            type: string
                            description: URL of product image
                          weight:
                            type: object
                            description: Weight information
                          quantity:
                            type: number
                            format: float
                            description: Ordered quantity
                          unit_price:
                            type: number
                            format: float
                            description: Price per unit
                          tax:
                            type: number
                            format: float
                            description: Tax amount
                          shipping:
                            type: number
                            format: float
                            description: Shipping amount
                          warehouse_location:
                            type: string
                            description: Location in warehouse
                          options:
                            type: object
                            description: Additional options
                          fulfillment_sku:
                            type: string
                            description: SKU used for fulfillment
                          adjustment:
                            type: number
                            format: float
                            description: Price adjustment
                          upc:
                            type: string
                            description: Universal Product Code
                          stock_id:
                            type: integer
                            description: Stock identifier
                          kit_id:
                            type: integer
                            description: Kit identifier if part of a kit
                          non_physical_item:
                            type: boolean
                            description: Whether item is non-physical
                          ignore_item:
                            type: boolean
                            description: Whether to ignore this item
                          is_locally_added:
                            type: boolean
                            description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                          quantity_shipped:
                            type: number
                            format: float
                            description: Quantity shipped
                          quantity_cancelled:
                            type: number
                            format: float
                            description: Quantity cancelled
                          quantity_invoiced:
                            type: number
                            format: float
                            description: Quantity invoiced
                          quantity_ordered:
                            type: number
                            format: float
                            description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                          base_uom_id:
                            type: integer
                            description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                          ordered_uom_id:
                            type: integer
                            description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                          product_id:
                            type: integer
                            description: Product identifier
                          total_returned_base_quantity:
                            type: number
                            format: float
                            description: Total quantity returned
                          parent_id:
                            type: integer
                            description: Parent item ID
                          status:
                            type: string
                            description: Item status
                          discount:
                            type: number
                            format: float
                            description: Discount amount
                          estimated_ship_date:
                            type: string
                            format: date
                            description: Estimated shipping date
                          custom_fields:
                            type: object
                            description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                            additionalProperties:
                              type: string
                          product:
                            type: object
                            description: Product information
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the product
                              name:
                                type: string
                                description: Product name
                              description:
                                type: string
                                nullable: true
                                description: Product description
                              retail_price:
                                type: number
                                format: float
                                description: Retail price
                              wholesale_price:
                                type: number
                                format: float
                                description: Wholesale price
                              unit_cost:
                                type: number
                                format: float
                                description: Cost per unit
                              product_weight:
                                type: number
                                format: float
                                description: Weight of the product
                              product_length:
                                type: number
                                format: float
                                description: Length of the product (in inches)
                              product_width:
                                type: number
                                format: float
                                description: Width of the product (in inches)
                              product_height:
                                type: number
                                format: float
                                description: Height of the product (in inches)
                              sellable:
                                type: boolean
                                description: Whether the product can be sold
                              discontinued:
                                type: boolean
                                description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                              image_url:
                                type: string
                                nullable: true
                                description: URL to the product's main image
                              category:
                                type: object
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                description: Product category information
                              subcategory:
                                type: object
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                description: Product subcategory information
                              custom_fields:
                                type: object
                                description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties:
                                  type: string
                              variant_attributes:
                                type: object
                                nullable: true
                                description: Available variant attributes
                              sku:
                                type: string
                                description: Internal SKU
                              alternate_skus:
                                type: array
                                description: Alternate SKUs
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    sku:
                                      type: string
                              upc:
                                type: string
                                description: UPC/Barcode
                              tags:
                                type: array
                                description: Tags associated with the product
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the tag
                                    name:
                                      type: string
                                      description: Name of the tag
                                    description:
                                      type: string
                                      nullable: true
                                      description: Description of the tag
                                    icon:
                                      type: string
                                      nullable: true
                                      description: Icon identifier or URL for the tag
                                    color:
                                      type: string
                                      nullable: true
                                      description: Color code for the tag
                                  required:
                                    - id
                                    - name
                              supplier:
                                type: object
                                nullable: true
                                description: Supplier information
                              type:
                                type: string
                                enum:
                                  - PRODUCT
                                  - KIT
                                description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                              kit_items:
                                type: array
                                nullable: true
                                description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the kit item
                                    product_id:
                                      type: integer
                                      description: ID of the product component
                                    quantity:
                                      type: number
                                      format: float
                                      description: Quantity of this component in the kit
                                    uom_id:
                                      type: integer
                                      description: Unit of measure ID for the quantity
                                    base_uom_quantity:
                                      type: number
                                      format: float
                                      description: Quantity converted to base unit of measure
                                    price:
                                      type: number
                                      format: float
                                      description: Price for this kit item
                                    original_price:
                                      type: number
                                      format: float
                                      description: Original price for this kit item
                                    total:
                                      type: number
                                      format: float
                                      description: Calculated total (quantity * price)
                                    product:
                                      type: object
                                      nullable: true
                                      description: Product information for this kit item (when loaded)
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        sku:
                                          type: string
                                        description:
                                          type: string
                                          nullable: true
                                        retail_price:
                                          type: number
                                          format: float
                                        wholesale_price:
                                          type: number
                                          format: float
                                    unit_of_measure:
                                      type: object
                                      nullable: true
                                      description: Unit of measure information (when loaded)
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        description:
                                          type: string
                                          nullable: true
                                        base_unit:
                                          type: boolean
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the product was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the product was last updated
                          tags:
                            type: array
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                icon:
                                  type: string
                                color:
                                  type: string
                                discount_structure:
                                  type: object
                                markup_structure:
                                  type: object
                            description: Tags associated with the sales order item
                  - type: object
                    title: Remap plan (dry run)
                    properties:
                      data:
                        type: object
                        description: |
                          Result of analysing a posted-order line-item remap. Returned by the
                          `remap-preview` endpoint and by the `remap` endpoint when `dry_run` is true.
                          Lets a caller decide whether to proceed before mutating — whether the remap is
                          allowed, whether a `force` flag is required, and what will happen to the
                          fulfillment order.
                        properties:
                          allowed:
                            type: boolean
                            description: Whether the remap can proceed as requested.
                          blocked_reason:
                            type: string
                            nullable: true
                            description: |
                              Human-readable reason the remap is blocked. Populated only when `allowed`
                              is `false`. Hard blocks include invoiced, shipped, split, or cancelled
                              orders.
                          requires_force:
                            type: boolean
                            description: |
                              `true` when the only thing standing in the way is a pushed fulfillment
                              order and the caller did not pass `force`. Re-submit with `force=true` to
                              unpush, delete, and recreate the fulfillment order.
                          fulfillment_order_exists:
                            type: boolean
                            description: Whether the sales order currently has a fulfillment order.
                          fulfillment_order_id:
                            type: integer
                            nullable: true
                            description: 'ID of the existing fulfillment order, when one exists.'
                          fo_is_pushed:
                            type: boolean
                            description: Whether the existing fulfillment order has been pushed to a source/3PL.
                          fo_action:
                            type: string
                            enum:
                              - none
                              - delete_and_recreate
                            description: |
                              What will happen to the fulfillment order on commit. `none` when no
                              fulfillment order exists; `delete_and_recreate` when an existing one will
                              be deleted and regenerated for the new product.
                          will_delete_fulfillment_order:
                            type: boolean
                            description: Convenience flag — `true` when `fo_action` is `delete_and_recreate`.
                          will_recreate_fulfillment_order:
                            type: boolean
                            description: Whether a new fulfillment order will be generated after the remap.
                          will_delete_invoice:
                            type: boolean
                            description: |
                              `true` when an invoice is linked to the fulfillment order. This is a hard
                              block — invoices are never auto-voided, so the remap is rejected.
                          old_product_id:
                            type: integer
                            description: ID of the product the line item is currently mapped to.
                          new_product_id:
                            type: integer
                            description: ID of the product the line item will be remapped to.
                          warnings:
                            type: array
                            items:
                              type: string
                            description: Non-blocking warnings about the planned remap.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Sales order or line item not found, or item does not belong to the order'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Remap blocked by a guardrail, or validation error'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/push-fulfillment':
    post:
      operationId: pushSalesOrderFulfillment
      tags:
        - Sales Orders
      summary: Push fulfillment to order source
      description: |
        Push fulfillment/tracking for all shipments on a sales order to its source channel
        (e.g. Shopify). Mirrors the admin "push order fulfillment" action and runs the same
        OMS integration flow that fires automatically when shipments are created — useful for
        retrying a sync that previously failed or for orders whose source did not auto-receive
        fulfillment notifications.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      responses:
        '200':
          description: Fulfillment pushed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: true
                      message:
                        type: string
                        example: Order fulfillment pushed successfully.
        '400':
          description: 'Push failed (source rejected, missing integration, or other service error). Body includes the error message and any extra context returned by the integration.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Human-readable failure reason
                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/simulate-fulfillment':
    post:
      operationId: simulateSalesOrderFulfillment
      tags:
        - Sales Orders
      summary: Simulate fulfillment for a sales order
      description: |
        Dry-run fulfillment-order generation for a single sales order. Read-only — no
        database writes and no inventory allocation take place. Use this to preview which
        fulfillment orders *would* be generated, and whether stock shortages would occur,
        before committing with
        `POST /sales-orders/{salesOrderId}/auto-generate-fulfillment-orders`.

        This is single-order sugar for `POST /fulfillment-orders/simulate` and returns the
        same response shape.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                skip_status_check:
                  type: boolean
                  default: true
                  description: |
                    When true (default), skip the sales order status gate so orders in any
                    active state can be simulated.
      responses:
        '200':
          description: Simulation completed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: Result of a dry-run fulfillment-order simulation.
                    properties:
                      results:
                        type: array
                        description: One entry per simulated sales order.
                        items:
                          type: object
                          properties:
                            sales_order_id:
                              type: integer
                              example: 12345
                            order_number:
                              type: string
                              nullable: true
                              example: SO-1001
                            channel_id:
                              type: integer
                              nullable: true
                            channel_name:
                              type: string
                              nullable: true
                            status:
                              type: string
                              description: |
                                Outcome for this order:
                                - `SUCCESS` — one or more fulfillment orders would be generated
                                - `NO_STOCK` — nothing could be generated due to insufficient stock
                                - `ERROR` — the order was not found, is inactive, or an error occurred
                              enum:
                                - SUCCESS
                                - NO_STOCK
                                - ERROR
                            message:
                              type: string
                              example: 1 Fulfillment Order(s) would be generated.
                            simulated:
                              type: boolean
                              example: true
                            simulated_fulfillment_orders:
                              type: array
                              description: The fulfillment orders that would be created (not persisted).
                              items:
                                type: object
                                additionalProperties: true
                            has_shortages:
                              type: boolean
                            shortage_items:
                              type: array
                              items:
                                type: object
                                additionalProperties: true
                            detailed_decisions:
                              type: array
                              description: Per-line routing / allocation decisions made during the simulation.
                              items:
                                type: object
                                additionalProperties: true
                      summary:
                        type: object
                        properties:
                          total_orders_simulated:
                            type: integer
                            example: 1
                          orders_with_fos:
                            type: integer
                            description: Count of orders with status `SUCCESS`.
                            example: 1
                          orders_without_stock:
                            type: integer
                            description: Count of orders with status `NO_STOCK`.
                            example: 0
                          orders_with_errors:
                            type: integer
                            description: Count of orders with status `ERROR`.
                            example: 0
                          total_simulated_fulfillment_orders:
                            type: integer
                            description: Total fulfillment orders that would be generated across all orders.
                            example: 1
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/auto-generate-fulfillment-orders':
    post:
      operationId: autoGenerateFulfillmentOrders
      tags:
        - Sales Orders
      summary: Auto-generate fulfillment orders (synchronous)
      description: |
        Generate fulfillment orders for a single sales order **synchronously** and return
        the outcome inline. Contrast with `POST /sales-orders/{salesOrderId}/refresh`, which
        dispatches an asynchronous order-refresh job.

        Use this when you need the fulfillment orders created and their IDs back in the same
        request (e.g. an automation that immediately pushes them).

        If the order's Shopify integration is set to create fulfillment orders from Shopify,
        this endpoint builds them from the order's Shopify fulfillment orders instead of
        Smart Fulfillment. When that creates nothing (for example, Shopify has not routed the
        order yet, or its lines are already on fulfillment orders), the response is `422` with
        a `message` that starts `No fulfillment orders generated:` and gives the reason.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                skip_status_check:
                  type: boolean
                  default: true
                  description: 'When true (default), skip the sales order status gate.'
                fulfillment_order_status:
                  type: string
                  nullable: true
                  description: |
                    Optional initial status to assign to the generated fulfillment orders.
                    Omit to use the default.
                  enum:
                    - pending
                    - planned
                    - awaiting_shipment
                    - shipped
      responses:
        '200':
          description: Fulfillment orders generated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      sales_order_id:
                        type: integer
                        example: 12345
                      order_number:
                        type: string
                        nullable: true
                        example: SO-1001
                      status:
                        type: string
                        enum:
                          - SUCCESS
                          - NO_STOCK
                          - ERROR
                        example: SUCCESS
                      message:
                        type: string
                        example: 2 Fulfillment Order(s) Generated.
                      count:
                        type: integer
                        description: Number of fulfillment orders generated.
                        example: 2
                      fulfillment_order_ids:
                        type: array
                        description: IDs of the generated fulfillment orders (present when available).
                        items:
                          type: integer
                        example:
                          - 5001
                          - 5002
                      has_shortages:
                        type: boolean
                        description: Present when some items could not be fully fulfilled.
                      shortage_items:
                        type: array
                        items:
                          type: object
                          additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Generation failed (e.g. no fulfillment orders could be generated due to
            insufficient stock, the order is invalid, or, for an order whose Shopify integration
            creates fulfillment orders from Shopify, there was nothing new to build from Shopify).
            The `data.status` field is `ERROR`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      sales_order_id:
                        type: integer
                      status:
                        type: string
                        example: ERROR
                      message:
                        type: string
  '/sales-orders/{salesOrderId}/fulfillment-orders':
    post:
      operationId: createSalesOrderFulfillmentOrder
      tags:
        - Sales Orders
      summary: Create a fulfillment order (no stock checks)
      description: |
        Create **one** fulfillment order for a sales order's open quantity, without stock or
        threshold checks and without warehouse splits. Contrast with
        `POST /sales-orders/{salesOrderId}/auto-generate-fulfillment-orders`, which always runs
        Smart Fulfillment (stock thresholds and warehouse splits).

        - **Fulfillment channel:** `fulfillment_channel_id` sets the fulfillment order's
          fulfillment channel and its destination integration account and store (from that
          channel's push-orders mapping). When omitted, the first fulfillment channel on the
          order's fulfillment priority list is used: the sales order's list, then the first
          line's list (line, then product). With no list there, an order whose own sales
          channel fulfills its orders end-to-end uses that sales channel; otherwise the
          account's default list is used. Stock is not
          checked. The request returns **422** when no fulfillment channel can be resolved, so
          it never creates a fulfillment order that cannot be pushed.
        - **Warehouse group:** `warehouse_group_id` defaults to the sales order channel's
          ship-from warehouse group, and can also come from the fulfillment channel.
        - **Lines:** omit `lines` to fulfill every line's open quantity
          (`quantity - quantity_fulfilled`). Send `lines` to fulfill specific lines and quantities.
        - **Duplicates:** if the sales order already has a matching fulfillment order with the
          same line quantities, that order is returned instead of creating a duplicate. An
          existing order with smaller quantities does not count as a match.
        - **Push:** by default this endpoint does not push the fulfillment order; when
          `destination_oms_store_set` is `true`, you can push it with
          `POST /fulfillment-orders/{fulfillmentOrderId}/push`. Send `push_to_oms: true` to push
          right after creating it; the result is returned in `push`. A failed push still returns
          `201` with `push.success: false`.
        - **Non-physical lines:** non-physical and non-inventory lines are never put on a
          fulfillment order. When `lines` is omitted they are left out; naming one in `lines`
          returns **422** (`Order item #... (SKU) is non-physical or non-inventory and is not
          fulfilled.`).
        - **Unmapped lines:** a physical, non-ignored line that is not mapped to a product is
          left off the fulfillment order. The other lines are still fulfilled, and the response
          has a top-level `message` naming the lines that were left off. If every selected line
          is unmapped, the request returns **422** (`Cannot create fulfillment order: ... is not
          mapped to a product. ...`) and no fulfillment order is created. When the order is
          pushed, unmapped lines are handled as described under
          `POST /fulfillment-orders/{fulfillmentOrderId}/push`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                fulfillment_channel_id:
                  type: integer
                  nullable: true
                  description: |
                    Fulfillment channel to fulfill through (must exist). Sets the destination
                    integration account and store from that channel's push-orders mapping. Omit to
                    use the first fulfillment channel on the order's fulfillment priority list
                    (sales order, then first line/product), then the order's own sales channel
                    when it fulfills end-to-end, then the account's default list.
                push_to_oms:
                  type: boolean
                  default: false
                  description: Push the fulfillment order to its fulfillment channel right after creating it.
                warehouse_group_id:
                  type: integer
                  nullable: true
                  description: |
                    Warehouse group to fulfill from. Defaults to the sales order channel's
                    ship-from warehouse group, or the fulfillment channel's.
                fulfillment_order_status:
                  type: string
                  nullable: true
                  enum:
                    - pending
                    - planned
                    - awaiting_shipment
                    - shipped
                  description: Optional initial status for the fulfillment order. Omit to use the default.
                lines:
                  type: array
                  description: |
                    Lines and quantities to fulfill. Omit to fulfill the open quantity on every line.
                  items:
                    type: object
                    required:
                      - sales_order_item_id
                      - quantity
                    properties:
                      sales_order_item_id:
                        type: integer
                        description: Sales order line item ID (must belong to this sales order)
                      quantity:
                        type: number
                        exclusiveMinimum: true
                        minimum: 0
                        description: Quantity to fulfill. Cannot exceed the line's open quantity.
            examples:
              all_open_quantity:
                summary: Fulfill all open quantity through the priority list's first fulfillment channel
                value: {}
              channel_and_push:
                summary: Fulfill through a chosen fulfillment channel and push right away
                value:
                  fulfillment_channel_id: 12
                  push_to_oms: true
              specific_lines:
                summary: Fulfill specific lines from a chosen warehouse group
                value:
                  warehouse_group_id: 4
                  fulfillment_order_status: awaiting_shipment
                  lines:
                    - sales_order_item_id: 98765
                      quantity: 2
      responses:
        '201':
          description: Fulfillment order created (or the matching existing one returned)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      fulfillment_order_id:
                        type: integer
                        example: 5001
                      fulfillment_order_ids:
                        type: array
                        description: Always a single-element array containing `fulfillment_order_id`.
                        items:
                          type: integer
                        example:
                          - 5001
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                        description: Fulfillment channel on the fulfillment order.
                        example: 12
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination integration account the fulfillment order will push to.
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                        description: Destination store on that integration account.
                      destination_oms_store_set:
                        type: boolean
                        description: |
                          `true` only when both `destination_oms_id` and `destination_oms_store_id`
                          are set, so `POST /fulfillment-orders/{fulfillmentOrderId}/push` can run.
                      push:
                        type: object
                        description: Push result. Present only when `push_to_oms` was `true`.
                        properties:
                          success:
                            type: boolean
                          message:
                            type: string
                          data:
                            type: object
                            additionalProperties: true
                            description: 'Extra push details, when the push returns any.'
                  message:
                    type: string
                    description: |
                      Present only when one or more physical sales order lines with no product mapping
                      were left off the fulfillment order. Names those lines (by SKU, or by name when there is no SKU) so you can map them.
                    example: Fulfillment order created. ABC-123 not mapped to a product and left off — map before fulfilling.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Sales order not found.
        '422':
          description: |
            Validation or creation failed, for example: `fulfillment_channel_id` does not exist,
            no fulfillment channel could be resolved, no open quantity remains on the sales order, a line is not on this sales order, a line is
            non-physical or non-inventory, a
            quantity exceeds the line's open quantity, or every selected line is not mapped to a product.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: No open quantity remains on this sales order.
  '/sales-orders/{salesOrderId}/refresh':
    post:
      operationId: refreshSalesOrder
      tags:
        - Sales Orders
      summary: Refresh a sales order
      description: |
        Dispatch a background refresh for a single active sales order — the same pipeline
        used by the admin `order:refresh` Artisan command. The job pulls shipping updates,
        recalculates quantities, deletes unpushed fulfillment orders, and auto-generates
        new ones.

        The endpoint validates and queues the work, then returns immediately; the refresh
        itself runs asynchronously on the `order-refresh` queue.

        Only active sales orders (`status > 0`) can be refreshed. Requests targeting
        completed, cancelled, or deleted orders return `404`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                reset_skip_inventory:
                  type: boolean
                  default: false
                  description: |
                    When `true`, the order's `skip_inventory` flag is set to `false` before
                    the refresh runs, so fulfillment-order creation can take place.
                delete_all_shipments:
                  type: boolean
                  default: false
                  description: |
                    When `true`, the refresh job deletes all existing shipments (including
                    pushed ones) before regenerating fulfillment orders. Use with care.
      responses:
        '200':
          description: Refresh job dispatched
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: true
                      message:
                        type: string
                        example: Order refresh job dispatched. Processing runs asynchronously on the order-refresh queue.
                      sales_order_id:
                        type: integer
                        example: 12345
                      order_number:
                        type: string
                        example: SO-1001
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found or is not active
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /sales-order-shipments:
    get:
      operationId: getAllSalesOrderShipments
      tags:
        - Sales Orders
      summary: List sales order shipments
      description: |
        Get a paginated list of sales order shipments across all sales orders. Use it to fetch
        recent shipments in a few paged calls instead of calling
        `GET /sales-orders/{salesOrderId}/shipments` once per order.

        Results are ordered by `ship_date` descending, then by `id` descending.

        **Default window:** if you don't send a `ship_date` filter, only shipments with a
        ship date in the **last 48 hours** (UTC) are returned. To read further back, pass an
        explicit `ship_date` filter (e.g. `ship_date[gte]=2026-01-01 00:00:00`).

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### DateTime Filters
        - `ship_date`: Date the shipment shipped (UTC). Overrides the 48-hour default window
        - `created_at`: When the shipment was created
        - `updated_at`: When the shipment was last updated
        - `delivered_at`: Carrier delivery timestamp (see `delivered_at` on the shipment). A shipment
          with no label-tracking record does not match a positive `delivered_at` filter

        ### Integer Filters
        - `id`: Shipment ID
        - `sales_order_id`: Parent sales order ID
        - `channel_id`: Sales channel of the parent sales order (supports `eq`, `ne`, `in`, `nin`, etc.)

        ### String Filters
        - `tracking_number`: Carrier tracking number

        ## Examples
        ```
        # Shipments from the last 48 hours (default window)
        GET /sales-order-shipments

        # Shipments on or after a date for one channel
        ?ship_date[gte]=2026-10-01 00:00:00&channel_id[eq]=12

        # Look up a shipment by tracking number
        ?tracking_number[eq]=1Z999AA10123456784
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the shipment
                        sales_order_id:
                          type: integer
                          description: ID of the associated sales order
                        shipped_by_user:
                          description: 'Luminous user who marked the parent sales order shipped, or `null` when not set. Who picked and packed is not stored on the shipment; see `picked_by_user` / `packed_by_user` on picklists.'
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                        ship_date:
                          type: string
                          format: date
                          description: Date when the shipment was or will be sent
                        tracking_number:
                          type: string
                          description: Tracking number for the shipment
                        tracking_url:
                          type: string
                          nullable: true
                          description: |
                            Tracking URL for the shipment. This is the stored URL, or a carrier URL built from the
                            tracking number when carrier tracking links are enabled for the tenant.
                        delivery_status:
                          type: string
                          nullable: true
                          enum:
                            - pre_transit
                            - in_transit
                            - out_for_delivery
                            - delivered
                            - exception
                            - null
                          description: |
                            Carrier delivery status from the Luminous label-tracking record that shares this
                            shipment's tracking number (and fulfillment order, when the shipment is bound to one).
                            `available_for_pickup` is reported as `out_for_delivery`; `failure`, `return_to_sender`,
                            `error`, and `cancelled` are reported as `exception`. `null` when Luminous has no
                            label-tracking record for the shipment (for example a tracking number imported from
                            ShipStation) or the carrier status is unknown.
                        delivered_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: |
                            Delivery timestamp from the same label-tracking record as `delivery_status`. `null` when
                            there is no tracking record or the shipment has not been delivered.
                        bol_number:
                          type: string
                          description: Bill of Lading Number for logistics tracking
                          example: BOL-123456789
                        pro_number:
                          type: string
                          description: Progressive Rotating Order Number (common in LTL shipping)
                          example: PRO-987654321
                        partner_reference_number:
                          type: string
                          description: General reference number from/for the shipping partner
                          example: PARTNER-REF-001
                        is_return:
                          type: boolean
                          description: Whether this is a return shipment
                        carrier_code:
                          type: string
                          description: 'Code identifying the carrier (e.g., ups, fedex)'
                        scac:
                          type: string
                          nullable: true
                          description: Standard Carrier Alpha Code (SCAC) for the shipment's carrier; included on outbound EDI 856/810 documents
                        service_code:
                          type: string
                          description: Code identifying the shipping service
                        package_code:
                          type: string
                          description: Code identifying the package type
                        shipment_cost:
                          type: number
                          format: float
                          description: Cost of shipping
                        insurance_cost:
                          type: number
                          format: float
                          description: Cost of insurance
                        warehouse_group_id:
                          type: integer
                          nullable: true
                          description: ID of the warehouse group associated with this shipment (from the linked fulfillment order)
                        status:
                          type: integer
                          description: Status of the shipment
                        ship_to:
                          type: object
                          properties:
                            name:
                              type: string
                              description: Recipient name
                            company:
                              type: string
                              description: Company name
                            street1:
                              type: string
                              description: Primary street address
                            street2:
                              type: string
                              description: Secondary street address
                            street3:
                              type: string
                              description: Additional street address
                            city:
                              type: string
                              description: City
                            state:
                              type: string
                              description: State/province
                            postalCode:
                              type: string
                              description: Postal/ZIP code
                            country:
                              type: string
                              description: Country
                            phone:
                              type: string
                              description: Contact phone number
                            residential:
                              type: boolean
                              description: Whether this is a residential address
                        weight:
                          type: object
                          required:
                            - value
                            - units
                          properties:
                            value:
                              type: number
                              format: float
                              description: Weight value
                            units:
                              type: string
                              enum:
                                - ounces
                                - pounds
                                - grams
                                - kilograms
                              description: Unit of weight measurement
                        dimensions:
                          type: object
                          required:
                            - units
                            - length
                            - width
                            - height
                          properties:
                            units:
                              type: string
                              enum:
                                - inches
                                - centimeters
                              description: Unit of dimensional measurement
                            length:
                              type: number
                              format: float
                              description: Length of the package
                            width:
                              type: number
                              format: float
                              description: Width of the package
                            height:
                              type: number
                              format: float
                              description: Height of the package
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the shipment item
                              shipment_id:
                                type: integer
                                description: ID of the parent shipment
                              product_id:
                                type: integer
                                description: ID of the product being shipped
                              sales_order_item_id:
                                type: integer
                                description: 'Luminous sales order line-item ID (the internal item primary key) for the line being shipped. This is the value to pass back as `order_item_id` when creating a shipment for this order. For kit/bundle component lines that share a single upstream channel line, each component is still returned with its own distinct `sales_order_item_id`.'
                              quantity:
                                type: number
                                description: 'Quantity being shipped, expressed in the same unit of measure the associated sales order line was ordered in (the selling UoM, e.g. cartons) rather than internal base units. When the originating order line cannot be resolved, the stored quantity is returned as-is.'
                              weight:
                                type: object
                                required:
                                  - value
                                  - units
                                properties:
                                  value:
                                    type: number
                                    format: float
                                    description: Weight value
                                  units:
                                    type: string
                                    enum:
                                      - ounces
                                      - pounds
                                      - grams
                                      - kilograms
                                    description: Unit of weight measurement
                              unit_price:
                                type: number
                                format: float
                                description: Price per unit
                              lot_id:
                                type: integer
                                nullable: true
                                description: ID of the lot this shipment item was deducted from (CS-10083). `null` when the line has no lot. Populated from the `lot_id` submitted on shipment create; Luminous no longer re-infers a lot by FEFO/FIFO once a lot is named.
                              lot_number:
                                type: string
                                nullable: true
                                description: 'Lot number stamped on the item, falling back to the referenced lot''s number when only `lot_id` was submitted. `null` when the line has no lot.'
                              expiry_date:
                                type: string
                                format: date
                                nullable: true
                                description: 'Expiry date of the lot (`YYYY-MM-DD`), falling back to the referenced lot. `null` when the line has no lot.'
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was last updated
                          description: Items included in this shipment
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the shipment was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the shipment was last updated
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/shipments':
    get:
      operationId: getSalesOrderShipments
      tags:
        - Sales Orders
      summary: Get shipments for a sales order
      description: |
        Retrieve a paginated list of shipments associated with a specific sales order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: ID of the sales order
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the shipment
                        sales_order_id:
                          type: integer
                          description: ID of the associated sales order
                        shipped_by_user:
                          description: 'Luminous user who marked the parent sales order shipped, or `null` when not set. Who picked and packed is not stored on the shipment; see `picked_by_user` / `packed_by_user` on picklists.'
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                        ship_date:
                          type: string
                          format: date
                          description: Date when the shipment was or will be sent
                        tracking_number:
                          type: string
                          description: Tracking number for the shipment
                        tracking_url:
                          type: string
                          nullable: true
                          description: |
                            Tracking URL for the shipment. This is the stored URL, or a carrier URL built from the
                            tracking number when carrier tracking links are enabled for the tenant.
                        delivery_status:
                          type: string
                          nullable: true
                          enum:
                            - pre_transit
                            - in_transit
                            - out_for_delivery
                            - delivered
                            - exception
                            - null
                          description: |
                            Carrier delivery status from the Luminous label-tracking record that shares this
                            shipment's tracking number (and fulfillment order, when the shipment is bound to one).
                            `available_for_pickup` is reported as `out_for_delivery`; `failure`, `return_to_sender`,
                            `error`, and `cancelled` are reported as `exception`. `null` when Luminous has no
                            label-tracking record for the shipment (for example a tracking number imported from
                            ShipStation) or the carrier status is unknown.
                        delivered_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: |
                            Delivery timestamp from the same label-tracking record as `delivery_status`. `null` when
                            there is no tracking record or the shipment has not been delivered.
                        bol_number:
                          type: string
                          description: Bill of Lading Number for logistics tracking
                          example: BOL-123456789
                        pro_number:
                          type: string
                          description: Progressive Rotating Order Number (common in LTL shipping)
                          example: PRO-987654321
                        partner_reference_number:
                          type: string
                          description: General reference number from/for the shipping partner
                          example: PARTNER-REF-001
                        is_return:
                          type: boolean
                          description: Whether this is a return shipment
                        carrier_code:
                          type: string
                          description: 'Code identifying the carrier (e.g., ups, fedex)'
                        scac:
                          type: string
                          nullable: true
                          description: Standard Carrier Alpha Code (SCAC) for the shipment's carrier; included on outbound EDI 856/810 documents
                        service_code:
                          type: string
                          description: Code identifying the shipping service
                        package_code:
                          type: string
                          description: Code identifying the package type
                        shipment_cost:
                          type: number
                          format: float
                          description: Cost of shipping
                        insurance_cost:
                          type: number
                          format: float
                          description: Cost of insurance
                        warehouse_group_id:
                          type: integer
                          nullable: true
                          description: ID of the warehouse group associated with this shipment (from the linked fulfillment order)
                        status:
                          type: integer
                          description: Status of the shipment
                        ship_to:
                          type: object
                          properties:
                            name:
                              type: string
                              description: Recipient name
                            company:
                              type: string
                              description: Company name
                            street1:
                              type: string
                              description: Primary street address
                            street2:
                              type: string
                              description: Secondary street address
                            street3:
                              type: string
                              description: Additional street address
                            city:
                              type: string
                              description: City
                            state:
                              type: string
                              description: State/province
                            postalCode:
                              type: string
                              description: Postal/ZIP code
                            country:
                              type: string
                              description: Country
                            phone:
                              type: string
                              description: Contact phone number
                            residential:
                              type: boolean
                              description: Whether this is a residential address
                        weight:
                          type: object
                          required:
                            - value
                            - units
                          properties:
                            value:
                              type: number
                              format: float
                              description: Weight value
                            units:
                              type: string
                              enum:
                                - ounces
                                - pounds
                                - grams
                                - kilograms
                              description: Unit of weight measurement
                        dimensions:
                          type: object
                          required:
                            - units
                            - length
                            - width
                            - height
                          properties:
                            units:
                              type: string
                              enum:
                                - inches
                                - centimeters
                              description: Unit of dimensional measurement
                            length:
                              type: number
                              format: float
                              description: Length of the package
                            width:
                              type: number
                              format: float
                              description: Width of the package
                            height:
                              type: number
                              format: float
                              description: Height of the package
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the shipment item
                              shipment_id:
                                type: integer
                                description: ID of the parent shipment
                              product_id:
                                type: integer
                                description: ID of the product being shipped
                              sales_order_item_id:
                                type: integer
                                description: 'Luminous sales order line-item ID (the internal item primary key) for the line being shipped. This is the value to pass back as `order_item_id` when creating a shipment for this order. For kit/bundle component lines that share a single upstream channel line, each component is still returned with its own distinct `sales_order_item_id`.'
                              quantity:
                                type: number
                                description: 'Quantity being shipped, expressed in the same unit of measure the associated sales order line was ordered in (the selling UoM, e.g. cartons) rather than internal base units. When the originating order line cannot be resolved, the stored quantity is returned as-is.'
                              weight:
                                type: object
                                required:
                                  - value
                                  - units
                                properties:
                                  value:
                                    type: number
                                    format: float
                                    description: Weight value
                                  units:
                                    type: string
                                    enum:
                                      - ounces
                                      - pounds
                                      - grams
                                      - kilograms
                                    description: Unit of weight measurement
                              unit_price:
                                type: number
                                format: float
                                description: Price per unit
                              lot_id:
                                type: integer
                                nullable: true
                                description: ID of the lot this shipment item was deducted from (CS-10083). `null` when the line has no lot. Populated from the `lot_id` submitted on shipment create; Luminous no longer re-infers a lot by FEFO/FIFO once a lot is named.
                              lot_number:
                                type: string
                                nullable: true
                                description: 'Lot number stamped on the item, falling back to the referenced lot''s number when only `lot_id` was submitted. `null` when the line has no lot.'
                              expiry_date:
                                type: string
                                format: date
                                nullable: true
                                description: 'Expiry date of the lot (`YYYY-MM-DD`), falling back to the referenced lot. `null` when the line has no lot.'
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was last updated
                          description: Items included in this shipment
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the shipment was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the shipment was last updated
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createSalesOrderShipment
      tags:
        - Sales Orders
      summary: Create a new shipment for a sales order
      description: |
        Create a new shipment record for a specific sales order. Once the shipment is added,
        the sales order status will automatically be updated to either `shipped` or `partially_shipped`.
        Also, any shipment costs will be added to the sales order total.

        Pass an optional `fulfillment_order_id` to link the shipment to a specific fulfillment order belonging to this
        sales order. To create a shipment scoped directly to a fulfillment order without referencing the sales order,
        use `POST /fulfillment-orders/{id}/shipments` instead.

        NOTE: At this time, inventory adjustments will not be made automatically.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: ID of the sales order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ship_date
                - tracking_number
                - carrier_code
                - warehouse_id
                - ship_to
                - items
              properties:
                ship_date:
                  type: string
                  format: date
                  description: Date when the shipment will be sent (YYYY-MM-DD)
                tracking_number:
                  type: string
                  description: Tracking number for the shipment
                bol_number:
                  type: string
                  description: Bill of Lading Number for logistics tracking
                  example: BOL-123456789
                pro_number:
                  type: string
                  description: Progressive Rotating Order Number (common in LTL shipping)
                  example: PRO-987654321
                partner_reference_number:
                  type: string
                  description: General reference number from/for the shipping partner
                  example: PARTNER-REF-001
                trailer_number:
                  type: string
                  nullable: true
                  description: Trailer number for the shipment (common in LTL/FTL freight); saved on the shipment
                  example: TRL-456789
                is_return:
                  type: boolean
                  description: Whether this is a return shipment
                carrier_code:
                  type: string
                  description: Code identifying the carrier
                  example: fedex
                service_code:
                  type: string
                  description: Code identifying the shipping service
                  example: ups_ground
                shipment_cost:
                  type: number
                  format: float
                  description: Cost of shipping
                insurance_cost:
                  type: number
                  format: float
                  description: Cost of insurance
                package_code:
                  type: string
                  description: Code identifying the package type
                  example: flat_rate_envelope
                warehouse_id:
                  type: integer
                  description: ID of the warehouse shipping from
                fulfillment_order_id:
                  type: integer
                  nullable: true
                  description: |
                    Optional ID of a fulfillment order belonging to this sales order. When provided, the shipment is linked to the
                    fulfillment order (populating the fulfillment-order/shipment pivot and the legacy `sales_order_shipment_id` FK).
                    The fulfillment order must belong to the sales order in the path.
                ship_to:
                  type: object
                  required:
                    - name
                    - street1
                    - city
                    - state
                    - postalCode
                    - country
                    - residential
                  properties:
                    name:
                      type: string
                      description: Recipient name
                    company:
                      type: string
                      description: Company name
                    street1:
                      type: string
                      description: Primary street address
                    street2:
                      type: string
                      description: Secondary street address
                    street3:
                      type: string
                      description: Additional street address
                    city:
                      type: string
                      description: City
                    state:
                      type: string
                      description: State/province
                    postalCode:
                      type: string
                      description: Postal/ZIP code
                    country:
                      type: string
                      description: Country
                    phone:
                      type: string
                      description: Contact phone number
                    residential:
                      type: boolean
                      description: Whether this is a residential address
                weight:
                  type: object
                  required:
                    - value
                    - units
                  properties:
                    value:
                      type: number
                      format: float
                      description: Weight value
                    units:
                      type: string
                      enum:
                        - ounces
                        - pounds
                        - grams
                        - kilograms
                      description: Unit of weight measurement
                dimensions:
                  type: object
                  required:
                    - units
                    - length
                    - width
                    - height
                  properties:
                    units:
                      type: string
                      enum:
                        - inches
                        - centimeters
                      description: Unit of dimensional measurement
                    length:
                      type: number
                      format: float
                      description: Length of the package
                    width:
                      type: number
                      format: float
                      description: Width of the package
                    height:
                      type: number
                      format: float
                      description: Height of the package
                items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - product_id
                      - order_item_id
                      - quantity
                      - unit_price
                    properties:
                      product_id:
                        type: integer
                        description: ID of the product being shipped
                      order_item_id:
                        type: integer
                        description: Luminous sales order line-item ID. Use the `sales_order_item_id` returned on the shipment/fulfillment-order read endpoints; for kit/bundle component lines pass the component's own `sales_order_item_id`.
                      weight:
                        type: object
                        required:
                          - value
                          - units
                        properties:
                          value:
                            type: number
                            format: float
                            description: Weight value
                          units:
                            type: string
                            enum:
                              - ounces
                              - pounds
                              - grams
                              - kilograms
                            description: Unit of weight measurement
                      quantity:
                        type: integer
                        minimum: 1
                        description: Quantity to ship
                      unit_price:
                        type: number
                        format: float
                        minimum: 0
                        description: Price per unit
                      lot_id:
                        type: integer
                        nullable: true
                        description: 'ID of the lot to deduct this line from (CS-10083). Required when the product is lot-tracked (`product.lot_tracking`); optional and ignored otherwise. Must be a lot on the same product, staged in this order''s picklist WIP bin with enough quantity. When the fulfillment order has no picklist of its own, the WIP bin of a sales-order picklist already holding the shipped quantity is used instead; with neither, the lot must be on hand in the shipping warehouse. Send two items with the same `order_item_id` and different `lot_id` to split one line across lots. When omitted, Luminous falls back to its FEFO/FIFO lot-deduction strategy. Lot problems return `422` keyed `items.N.lot_id`.'
                  description: Items to be included in this shipment
      responses:
        '201':
          description: Shipment created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Unique identifier for the shipment
                  sales_order_id:
                    type: integer
                    description: ID of the associated sales order
                  shipped_by_user:
                    description: 'Luminous user who marked the parent sales order shipped, or `null` when not set. Who picked and packed is not stored on the shipment; see `picked_by_user` / `packed_by_user` on picklists.'
                    type: object
                    nullable: true
                    properties:
                      id:
                        type: integer
                      name:
                        type: string
                        nullable: true
                  ship_date:
                    type: string
                    format: date
                    description: Date when the shipment was or will be sent
                  tracking_number:
                    type: string
                    description: Tracking number for the shipment
                  tracking_url:
                    type: string
                    nullable: true
                    description: |
                      Tracking URL for the shipment. This is the stored URL, or a carrier URL built from the
                      tracking number when carrier tracking links are enabled for the tenant.
                  delivery_status:
                    type: string
                    nullable: true
                    enum:
                      - pre_transit
                      - in_transit
                      - out_for_delivery
                      - delivered
                      - exception
                      - null
                    description: |
                      Carrier delivery status from the Luminous label-tracking record that shares this
                      shipment's tracking number (and fulfillment order, when the shipment is bound to one).
                      `available_for_pickup` is reported as `out_for_delivery`; `failure`, `return_to_sender`,
                      `error`, and `cancelled` are reported as `exception`. `null` when Luminous has no
                      label-tracking record for the shipment (for example a tracking number imported from
                      ShipStation) or the carrier status is unknown.
                  delivered_at:
                    type: string
                    format: date-time
                    nullable: true
                    description: |
                      Delivery timestamp from the same label-tracking record as `delivery_status`. `null` when
                      there is no tracking record or the shipment has not been delivered.
                  bol_number:
                    type: string
                    description: Bill of Lading Number for logistics tracking
                    example: BOL-123456789
                  pro_number:
                    type: string
                    description: Progressive Rotating Order Number (common in LTL shipping)
                    example: PRO-987654321
                  partner_reference_number:
                    type: string
                    description: General reference number from/for the shipping partner
                    example: PARTNER-REF-001
                  is_return:
                    type: boolean
                    description: Whether this is a return shipment
                  carrier_code:
                    type: string
                    description: 'Code identifying the carrier (e.g., ups, fedex)'
                  scac:
                    type: string
                    nullable: true
                    description: Standard Carrier Alpha Code (SCAC) for the shipment's carrier; included on outbound EDI 856/810 documents
                  service_code:
                    type: string
                    description: Code identifying the shipping service
                  package_code:
                    type: string
                    description: Code identifying the package type
                  shipment_cost:
                    type: number
                    format: float
                    description: Cost of shipping
                  insurance_cost:
                    type: number
                    format: float
                    description: Cost of insurance
                  warehouse_group_id:
                    type: integer
                    nullable: true
                    description: ID of the warehouse group associated with this shipment (from the linked fulfillment order)
                  status:
                    type: integer
                    description: Status of the shipment
                  ship_to:
                    type: object
                    properties:
                      name:
                        type: string
                        description: Recipient name
                      company:
                        type: string
                        description: Company name
                      street1:
                        type: string
                        description: Primary street address
                      street2:
                        type: string
                        description: Secondary street address
                      street3:
                        type: string
                        description: Additional street address
                      city:
                        type: string
                        description: City
                      state:
                        type: string
                        description: State/province
                      postalCode:
                        type: string
                        description: Postal/ZIP code
                      country:
                        type: string
                        description: Country
                      phone:
                        type: string
                        description: Contact phone number
                      residential:
                        type: boolean
                        description: Whether this is a residential address
                  weight:
                    type: object
                    required:
                      - value
                      - units
                    properties:
                      value:
                        type: number
                        format: float
                        description: Weight value
                      units:
                        type: string
                        enum:
                          - ounces
                          - pounds
                          - grams
                          - kilograms
                        description: Unit of weight measurement
                  dimensions:
                    type: object
                    required:
                      - units
                      - length
                      - width
                      - height
                    properties:
                      units:
                        type: string
                        enum:
                          - inches
                          - centimeters
                        description: Unit of dimensional measurement
                      length:
                        type: number
                        format: float
                        description: Length of the package
                      width:
                        type: number
                        format: float
                        description: Width of the package
                      height:
                        type: number
                        format: float
                        description: Height of the package
                  items:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the shipment item
                        shipment_id:
                          type: integer
                          description: ID of the parent shipment
                        product_id:
                          type: integer
                          description: ID of the product being shipped
                        sales_order_item_id:
                          type: integer
                          description: 'Luminous sales order line-item ID (the internal item primary key) for the line being shipped. This is the value to pass back as `order_item_id` when creating a shipment for this order. For kit/bundle component lines that share a single upstream channel line, each component is still returned with its own distinct `sales_order_item_id`.'
                        quantity:
                          type: number
                          description: 'Quantity being shipped, expressed in the same unit of measure the associated sales order line was ordered in (the selling UoM, e.g. cartons) rather than internal base units. When the originating order line cannot be resolved, the stored quantity is returned as-is.'
                        weight:
                          type: object
                          required:
                            - value
                            - units
                          properties:
                            value:
                              type: number
                              format: float
                              description: Weight value
                            units:
                              type: string
                              enum:
                                - ounces
                                - pounds
                                - grams
                                - kilograms
                              description: Unit of weight measurement
                        unit_price:
                          type: number
                          format: float
                          description: Price per unit
                        lot_id:
                          type: integer
                          nullable: true
                          description: ID of the lot this shipment item was deducted from (CS-10083). `null` when the line has no lot. Populated from the `lot_id` submitted on shipment create; Luminous no longer re-infers a lot by FEFO/FIFO once a lot is named.
                        lot_number:
                          type: string
                          nullable: true
                          description: 'Lot number stamped on the item, falling back to the referenced lot''s number when only `lot_id` was submitted. `null` when the line has no lot.'
                        expiry_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Expiry date of the lot (`YYYY-MM-DD`), falling back to the referenced lot. `null` when the line has no lot.'
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the item was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the item was last updated
                    description: Items included in this shipment
                  created_at:
                    type: string
                    format: date-time
                    description: Timestamp when the shipment was created
                  updated_at:
                    type: string
                    format: date-time
                    description: Timestamp when the shipment was last updated
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/shipments/{shipmentId}/force-push-source-fulfillment':
    post:
      operationId: forcePushShipmentSourceFulfillment
      tags:
        - Sales Orders
      summary: Force-push shipment fulfillment to order source
      description: |
        Push fulfillment for a shipment to the source OMS, explicitly choosing which sales order lines to fulfill
        (rather than relying on SKU matching). Use this when shipment lines do not match SKUs cleanly — e.g. for
        custom kits or rebranded items. After the push, `shipment_item_fulfillments` are synced and shipped
        quantities on the order items are recomputed from actual SIF totals.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
        - in: path
          name: shipmentId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sales_order_item_ids
              properties:
                sales_order_item_ids:
                  type: array
                  minItems: 1
                  items:
                    type: integer
                  description: IDs of sales order line items (must belong to this sales order) to push fulfillment for.
                tracking_number:
                  type: string
                  nullable: true
                  maxLength: 255
                carrier:
                  type: string
                  nullable: true
                  maxLength: 255
      responses:
        '200':
          description: Pushed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      fulfillment_id:
                        type: string
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Push failed (validation, source rejected, or shipment did not belong to the sales order)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: false
                      message:
                        type: string
  '/sales-orders/{salesOrderId}/shipments/{shipmentId}/packages':
    post:
      operationId: createSalesOrderShipmentPackages
      tags:
        - Sales Orders
      summary: Create shipment packages
      description: |
        Create detailed package and item tracking for a sales order shipment.

        This endpoint allows you to create hierarchical package structures with:
        - Multiple packages per shipment
        - Child packages (packages within packages)  
        - Detailed item tracking within each package
        - Package dimensions, weights, and tracking information
        - Item-level details including lot numbers, serial numbers, and expiration dates

        ## Use Cases
        - Track individual packages within a shipment
        - Manage nested packaging (e.g., items in boxes, boxes in pallets)
        - Record detailed inventory information for compliance
        - Provide granular tracking for complex shipments

        ## Package Hierarchy
        Packages can contain:
        - **Items**: Individual products with quantities and details
        - **Child Packages**: Nested packages that can themselves contain items or more child packages

        This allows for complex packaging scenarios like:
        - Individual items packed in small boxes, then grouped in larger shipping boxes
        - Palletized shipments with multiple layers of packaging
        - Mixed shipments with different packaging types
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: ID of the sales order
        - in: path
          name: shipmentId
          required: true
          schema:
            type: integer
          description: ID of the shipment to add packages to
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - packages
              properties:
                packages:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    properties:
                      sscc:
                        type: string
                        description: Serial Shipping Container Code - unique identifier for the package
                        example: 00123456789012345678
                      tracking:
                        type: string
                        description: Tracking number for the package
                        example: PKG-001
                      package_quantity:
                        type: integer
                        minimum: 1
                        description: Number of identical packages
                        example: 1
                      package_type:
                        type: string
                        description: 'Type of package (e.g., box, pallet, envelope, inner_box)'
                        example: box
                      packing_type:
                        type: string
                        description: 'Packing method used (e.g., standard, protective, fragile)'
                        example: standard
                      length_in:
                        type: number
                        format: float
                        minimum: 0
                        description: Package length in inches
                        example: 12
                      width_in:
                        type: number
                        format: float
                        minimum: 0
                        description: Package width in inches
                        example: 8
                      height_in:
                        type: number
                        format: float
                        minimum: 0
                        description: Package height in inches
                        example: 6
                      weight_lb:
                        type: number
                        format: float
                        minimum: 0
                        description: Package weight in pounds
                        example: 5
                      contained_items:
                        type: array
                        items:
                          type: object
                          required:
                            - order_item_id
                            - quantity
                          properties:
                            order_item_id:
                              type: integer
                              description: ID of the sales order line item being packaged
                              example: 1001
                            line_item_key:
                              type: string
                              description: Unique key for the line item within the package
                              example: line-1
                            sku:
                              type: string
                              description: Product SKU
                              example: WIDGET-001
                            internal_sku:
                              type: string
                              description: Internal product SKU
                              example: WIDGET-001
                            upc:
                              type: string
                              description: Universal Product Code
                              example: '123456789012'
                            quantity:
                              type: integer
                              minimum: 1
                              description: Quantity of the item being packaged
                              example: 5
                            description:
                              type: string
                              description: Description of the item
                              example: Premium Widget
                            lot_id:
                              type: integer
                              nullable: true
                              description: 'ID of the lot this carton line was packed from (CS-10083). Checked against the product on the line (resolved from `order_item_id`, then `internal_sku`, then `sku`) and persisted. Required when that product is lot-tracked and no resolvable `lot_number` was sent. A bare `lot_number` is resolved to a lot id when it names exactly one lot on the product, so EDI/Trackstar callers gain joinable lot identity without changing their payloads. When the shipment items already carry `lot_id`, carton lots and quantities must match those allocations. Lot problems return `422` keyed `packages.N.contained_items.M.lot_id` (or `.lot_number` for an ambiguous or unresolvable lot number).'
                              example: 546
                            lot_number:
                              type: string
                              description: Lot number for tracking and traceability
                              example: LOT-2024-001
                            serial_number:
                              type: string
                              description: Serial number for individual item tracking
                              example: SN-001
                            expiration_date:
                              type: string
                              format: date
                              description: 'Lot expiration date. Accepts `YYYY-MM-DD` date strings or ISO 8601 datetime strings (e.g. `2024-12-31T07:00:00.000000Z`) — the date portion is extracted and stored as `YYYY-MM-DD` either way.'
                              example: '2024-12-31'
                            weight_lb:
                              type: number
                              format: float
                              minimum: 0
                              description: Total weight of the items in pounds
                              example: 2.5
                        description: Items contained directly in this package
                      child_packages:
                        type: array
                        items:
                          type: object
                          properties:
                            sscc:
                              type: string
                              description: Serial Shipping Container Code - unique identifier for the package
                            tracking:
                              type: string
                              description: Tracking number for the package
                            package_quantity:
                              type: integer
                              minimum: 1
                              description: Number of identical packages
                            package_type:
                              type: string
                              description: 'Type of package (e.g., box, pallet, envelope, inner_box)'
                            packing_type:
                              type: string
                              description: 'Packing method used (e.g., standard, protective, fragile)'
                            length_in:
                              type: number
                              format: float
                              minimum: 0
                              description: Package length in inches
                            width_in:
                              type: number
                              format: float
                              minimum: 0
                              description: Package width in inches
                            height_in:
                              type: number
                              format: float
                              minimum: 0
                              description: Package height in inches
                            weight_lb:
                              type: number
                              format: float
                              minimum: 0
                              description: Package weight in pounds
                            contained_items:
                              type: array
                              items:
                                type: object
                                required:
                                  - order_item_id
                                  - quantity
                                properties:
                                  order_item_id:
                                    type: integer
                                    description: ID of the sales order line item being packaged
                                    example: 1001
                                  line_item_key:
                                    type: string
                                    description: Unique key for the line item within the package
                                    example: line-1
                                  sku:
                                    type: string
                                    description: Product SKU
                                    example: WIDGET-001
                                  internal_sku:
                                    type: string
                                    description: Internal product SKU
                                    example: WIDGET-001
                                  upc:
                                    type: string
                                    description: Universal Product Code
                                    example: '123456789012'
                                  quantity:
                                    type: integer
                                    minimum: 1
                                    description: Quantity of the item being packaged
                                    example: 5
                                  description:
                                    type: string
                                    description: Description of the item
                                    example: Premium Widget
                                  lot_id:
                                    type: integer
                                    nullable: true
                                    description: 'ID of the lot this carton line was packed from (CS-10083). Checked against the product on the line (resolved from `order_item_id`, then `internal_sku`, then `sku`) and persisted. Required when that product is lot-tracked and no resolvable `lot_number` was sent. A bare `lot_number` is resolved to a lot id when it names exactly one lot on the product, so EDI/Trackstar callers gain joinable lot identity without changing their payloads. When the shipment items already carry `lot_id`, carton lots and quantities must match those allocations. Lot problems return `422` keyed `packages.N.contained_items.M.lot_id` (or `.lot_number` for an ambiguous or unresolvable lot number).'
                                    example: 546
                                  lot_number:
                                    type: string
                                    description: Lot number for tracking and traceability
                                    example: LOT-2024-001
                                  serial_number:
                                    type: string
                                    description: Serial number for individual item tracking
                                    example: SN-001
                                  expiration_date:
                                    type: string
                                    format: date
                                    description: 'Lot expiration date. Accepts `YYYY-MM-DD` date strings or ISO 8601 datetime strings (e.g. `2024-12-31T07:00:00.000000Z`) — the date portion is extracted and stored as `YYYY-MM-DD` either way.'
                                    example: '2024-12-31'
                                  weight_lb:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Total weight of the items in pounds
                                    example: 2.5
                              description: Items contained directly in this package
                            child_packages:
                              type: array
                              items:
                                type: object
                                description: Recursively nested child packages (supports unlimited depth)
                              description: Child packages nested within this package
                        description: Child packages nested within this package (supports unlimited nesting)
                  description: Array of packages to create for the shipment
                bol_number:
                  type: string
                  nullable: true
                  description: Bill of Lading Number for logistics tracking; saved on the shipment
                  example: BOL-123456789
                pro_number:
                  type: string
                  nullable: true
                  description: Progressive Rotating Order Number (common in LTL shipping); saved on the shipment
                  example: PRO-987654321
                partner_reference_number:
                  type: string
                  nullable: true
                  description: General reference number from/for the shipping partner; saved on the shipment
                  example: PARTNER-REF-001
                trailer_number:
                  type: string
                  nullable: true
                  description: Trailer number for the shipment (common in LTL/FTL freight); saved on the shipment
                  example: TRL-456789
                scac:
                  type: string
                  nullable: true
                  maxLength: 10
                  description: Standard Carrier Alpha Code (SCAC) for the shipment's carrier; saved on the shipment and included on outbound EDI 856/810 documents
            examples:
              simple_package:
                summary: Simple package with items
                description: A basic package containing multiple items
                value:
                  packages:
                    - sscc: 00123456789012345678
                      tracking: PKG-001
                      package_quantity: 1
                      package_type: box
                      packing_type: standard
                      length_in: 12
                      width_in: 8
                      height_in: 6
                      weight_lb: 5
                      contained_items:
                        - order_item_id: 1001
                          line_item_key: line-1
                          sku: WIDGET-001
                          internal_sku: WIDGET-001
                          upc: '123456789012'
                          quantity: 5
                          description: Premium Widget
                          lot_number: LOT-2024-001
                          serial_number: SN-001
                          expiration_date: '2024-12-31'
                          weight_lb: 1
                        - order_item_id: 1002
                          line_item_key: line-2
                          sku: GADGET-002
                          internal_sku: GADGET-002
                          quantity: 3
                          description: Electronic Gadget
                          weight_lb: 0.5
              nested_packages:
                summary: Nested packages with multiple levels
                description: Complex package structure with child packages and items at multiple levels
                value:
                  packages:
                    - sscc: 00123456789012345678
                      tracking: PALLET-001
                      package_quantity: 1
                      package_type: pallet
                      packing_type: standard
                      length_in: 48
                      width_in: 40
                      height_in: 60
                      weight_lb: 150
                      contained_items:
                        - order_item_id: 1001
                          line_item_key: pallet-item-1
                          sku: BULK-ITEM-001
                          internal_sku: BULK-ITEM-001
                          quantity: 100
                          description: Bulk packaged items
                          weight_lb: 50
                      child_packages:
                        - sscc: 00123456789012345679
                          tracking: BOX-001
                          package_quantity: 2
                          package_type: box
                          packing_type: standard
                          length_in: 18
                          width_in: 12
                          height_in: 10
                          weight_lb: 25
                          contained_items:
                            - order_item_id: 1002
                              line_item_key: box-item-1
                              sku: WIDGET-SMALL
                              internal_sku: WIDGET-SMALL
                              upc: '987654321098'
                              quantity: 10
                              description: Small Widgets
                              lot_number: LOT-2024-002
                              weight_lb: 2
                          child_packages:
                            - sscc: 00123456789012345680
                              tracking: INNER-001
                              package_quantity: 5
                              package_type: inner_box
                              packing_type: protective
                              length_in: 6
                              width_in: 4
                              height_in: 3
                              weight_lb: 2.5
                              contained_items:
                                - order_item_id: 1003
                                  line_item_key: inner-item-1
                                  sku: FRAGILE-001
                                  internal_sku: FRAGILE-001
                                  quantity: 2
                                  description: Fragile Electronic Component
                                  serial_number: FRAG-001-002
                                  expiration_date: '2026-06-30'
                                  weight_lb: 0.1
              multiple_packages:
                summary: Multiple independent packages
                description: Multiple separate packages in the same shipment
                value:
                  packages:
                    - sscc: 00123456789012345678
                      tracking: PKG-A001
                      package_quantity: 1
                      package_type: box
                      packing_type: standard
                      length_in: 10
                      width_in: 8
                      height_in: 6
                      weight_lb: 3
                      contained_items:
                        - order_item_id: 1001
                          sku: ITEM-A
                          quantity: 5
                          description: Product A
                    - sscc: 00123456789012345679
                      tracking: PKG-B001
                      package_quantity: 1
                      package_type: envelope
                      packing_type: standard
                      length_in: 12
                      width_in: 9
                      height_in: 1
                      weight_lb: 0.5
                      contained_items:
                        - order_item_id: 1002
                          sku: ITEM-B
                          quantity: 1
                          description: Product B - Documents
      responses:
        '201':
          description: Packages created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the package
                          example: 1
                        sscc:
                          type: string
                          description: Serial Shipping Container Code - unique identifier for the package
                          example: 00123456789012345678
                        tracking:
                          type: string
                          description: Tracking number for the package
                          example: PKG-001
                        package_quantity:
                          type: integer
                          description: Number of identical packages
                          example: 1
                        package_type:
                          type: string
                          description: 'Type of package (e.g., box, pallet, envelope, inner_box)'
                          example: box
                        packing_type:
                          type: string
                          description: 'Packing method used (e.g., standard, protective, fragile)'
                          example: standard
                        length_in:
                          type: number
                          format: float
                          description: Package length in inches
                          example: 12
                        width_in:
                          type: number
                          format: float
                          description: Package width in inches
                          example: 8
                        height_in:
                          type: number
                          format: float
                          description: Package height in inches
                          example: 6
                        weight_lb:
                          type: number
                          format: float
                          description: Package weight in pounds
                          example: 5
                        parent_package_id:
                          type: integer
                          nullable: true
                          description: ID of the parent package if this is a child package
                          example: null
                        shipment_id:
                          type: integer
                          description: ID of the shipment this package belongs to
                          example: 123
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the package was created
                          example: '2024-01-15T10:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the package was last updated
                          example: '2024-01-15T10:30:00Z'
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the package item
                                example: 1
                              package_id:
                                type: integer
                                description: ID of the package containing this item
                                example: 1
                              order_item_id:
                                type: integer
                                description: ID of the sales order line item being packaged
                                example: 1001
                              line_item_key:
                                type: string
                                description: Unique key for the line item within the package
                                example: line-1
                              sku:
                                type: string
                                description: Product SKU
                                example: WIDGET-001
                              internal_sku:
                                type: string
                                description: Internal product SKU
                                example: WIDGET-001
                              upc:
                                type: string
                                description: Universal Product Code
                                example: '123456789012'
                              quantity:
                                type: integer
                                description: Quantity of the item being packaged
                                example: 5
                              description:
                                type: string
                                description: Description of the item
                                example: Premium Widget
                              lot_id:
                                type: integer
                                nullable: true
                                description: ID of the lot this carton line was packed from (CS-10083). `null` for historical/EDI carton lines that carry only a free-text `lot_number`.
                                example: 546
                              lot_number:
                                type: string
                                nullable: true
                                description: Lot number for tracking and traceability. Falls back to the referenced lot's number when only `lot_id` was submitted.
                                example: LOT-2024-001
                              serial_number:
                                type: string
                                nullable: true
                                description: Serial number for individual item tracking
                                example: SN-001
                              expiration_date:
                                type: string
                                format: date
                                nullable: true
                                description: Expiration date in YYYY-MM-DD format. Unchanged for existing consumers.
                                example: '2024-12-31'
                              expiry_date:
                                type: string
                                format: date
                                nullable: true
                                description: Additive lot expiry date (`YYYY-MM-DD`) that mirrors the shipment-item payload (CS-10083). Falls back to the referenced lot when only `lot_id` was submitted.
                                example: '2027-01-15'
                              weight_lb:
                                type: number
                                format: float
                                nullable: true
                                description: Total weight of the items in pounds
                                example: 2.5
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was created
                                example: '2024-01-15T10:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was last updated
                                example: '2024-01-15T10:30:00Z'
                          description: Items contained directly in this package
                        child_packages:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the package
                              sscc:
                                type: string
                                description: Serial Shipping Container Code - unique identifier for the package
                              tracking:
                                type: string
                                description: Tracking number for the package
                              package_quantity:
                                type: integer
                                description: Number of identical packages
                              package_type:
                                type: string
                                description: 'Type of package (e.g., box, pallet, envelope, inner_box)'
                              packing_type:
                                type: string
                                description: 'Packing method used (e.g., standard, protective, fragile)'
                              length_in:
                                type: number
                                format: float
                                description: Package length in inches
                              width_in:
                                type: number
                                format: float
                                description: Package width in inches
                              height_in:
                                type: number
                                format: float
                                description: Package height in inches
                              weight_lb:
                                type: number
                                format: float
                                description: Package weight in pounds
                              parent_package_id:
                                type: integer
                                description: ID of the parent package
                              shipment_id:
                                type: integer
                                description: ID of the shipment this package belongs to
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the package was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the package was last updated
                              items:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the package item
                                      example: 1
                                    package_id:
                                      type: integer
                                      description: ID of the package containing this item
                                      example: 1
                                    order_item_id:
                                      type: integer
                                      description: ID of the sales order line item being packaged
                                      example: 1001
                                    line_item_key:
                                      type: string
                                      description: Unique key for the line item within the package
                                      example: line-1
                                    sku:
                                      type: string
                                      description: Product SKU
                                      example: WIDGET-001
                                    internal_sku:
                                      type: string
                                      description: Internal product SKU
                                      example: WIDGET-001
                                    upc:
                                      type: string
                                      description: Universal Product Code
                                      example: '123456789012'
                                    quantity:
                                      type: integer
                                      description: Quantity of the item being packaged
                                      example: 5
                                    description:
                                      type: string
                                      description: Description of the item
                                      example: Premium Widget
                                    lot_id:
                                      type: integer
                                      nullable: true
                                      description: ID of the lot this carton line was packed from (CS-10083). `null` for historical/EDI carton lines that carry only a free-text `lot_number`.
                                      example: 546
                                    lot_number:
                                      type: string
                                      nullable: true
                                      description: Lot number for tracking and traceability. Falls back to the referenced lot's number when only `lot_id` was submitted.
                                      example: LOT-2024-001
                                    serial_number:
                                      type: string
                                      nullable: true
                                      description: Serial number for individual item tracking
                                      example: SN-001
                                    expiration_date:
                                      type: string
                                      format: date
                                      nullable: true
                                      description: Expiration date in YYYY-MM-DD format. Unchanged for existing consumers.
                                      example: '2024-12-31'
                                    expiry_date:
                                      type: string
                                      format: date
                                      nullable: true
                                      description: Additive lot expiry date (`YYYY-MM-DD`) that mirrors the shipment-item payload (CS-10083). Falls back to the referenced lot when only `lot_id` was submitted.
                                      example: '2027-01-15'
                                    weight_lb:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total weight of the items in pounds
                                      example: 2.5
                                    created_at:
                                      type: string
                                      format: date-time
                                      description: Timestamp when the item was created
                                      example: '2024-01-15T10:30:00Z'
                                    updated_at:
                                      type: string
                                      format: date-time
                                      description: Timestamp when the item was last updated
                                      example: '2024-01-15T10:30:00Z'
                                description: Items contained directly in this package
                              child_packages:
                                type: array
                                items:
                                  type: object
                                  description: Recursively nested child packages
                                description: Child packages nested within this package
                          description: Child packages nested within this package
              examples:
                simple_response:
                  summary: Simple package response
                  value:
                    data:
                      - id: 1
                        sscc: 00123456789012345678
                        tracking: PKG-001
                        package_quantity: 1
                        package_type: box
                        packing_type: standard
                        length_in: 12
                        width_in: 8
                        height_in: 6
                        weight_lb: 5
                        parent_package_id: null
                        shipment_id: 123
                        created_at: '2024-01-15T10:30:00Z'
                        updated_at: '2024-01-15T10:30:00Z'
                        items:
                          - id: 1
                            order_item_id: 1001
                            line_item_key: line-1
                            sku: WIDGET-001
                            internal_sku: WIDGET-001
                            upc: '123456789012'
                            quantity: 5
                            description: Premium Widget
                            lot_number: LOT-2024-001
                            serial_number: SN-001
                            expiration_date: '2024-12-31'
                            weight_lb: 1
                            created_at: '2024-01-15T10:30:00Z'
                            updated_at: '2024-01-15T10:30:00Z'
                        child_packages: []
                nested_response:
                  summary: Nested packages response
                  value:
                    data:
                      - id: 1
                        sscc: 00123456789012345678
                        tracking: PALLET-001
                        package_quantity: 1
                        package_type: pallet
                        packing_type: standard
                        length_in: 48
                        width_in: 40
                        height_in: 60
                        weight_lb: 150
                        parent_package_id: null
                        shipment_id: 123
                        created_at: '2024-01-15T10:30:00Z'
                        updated_at: '2024-01-15T10:30:00Z'
                        items:
                          - id: 1
                            order_item_id: 1001
                            sku: BULK-ITEM-001
                            quantity: 100
                            description: Bulk packaged items
                            weight_lb: 50
                        child_packages:
                          - id: 2
                            sscc: 00123456789012345679
                            tracking: BOX-001
                            package_quantity: 2
                            package_type: box
                            parent_package_id: 1
                            items:
                              - id: 2
                                order_item_id: 1002
                                sku: WIDGET-SMALL
                                quantity: 10
                                description: Small Widgets
                            child_packages:
                              - id: 3
                                sscc: 00123456789012345680
                                tracking: INNER-001
                                package_type: inner_box
                                parent_package_id: 2
                                items:
                                  - id: 3
                                    order_item_id: 1003
                                    sku: FRAGILE-001
                                    quantity: 2
                                    description: Fragile Electronic Component
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              examples:
                invalid_shipment:
                  summary: Invalid shipment ID
                  value:
                    message: Shipment not found or does not belong to this sales order
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order or shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
              examples:
                validation_errors:
                  summary: Validation error examples
                  value:
                    message: The given data was invalid.
                    errors:
                      packages.0.sscc:
                        - The sscc field must be a string.
                      packages.0.package_quantity:
                        - The package quantity must be at least 1.
                      packages.0.length_in:
                        - The length in must be at least 0.
                      packages.0.contained_items.0.quantity:
                        - The quantity must be at least 1.
                      packages.0.contained_items.0.order_item_id:
                        - The selected order item id is invalid.
                      packages.0.contained_items.0.expiration_date:
                        - The expiration date does not match the format Y-m-d.
  '/sales-orders/{salesOrderId}/attachments':
    get:
      operationId: listSalesOrderAttachments
      tags:
        - Sales Orders
      summary: List sales order attachments
      description: |
        List all files attached to a sales order. Returns a bare array (not paginated).

        Requires the `salesOrders.read` permission on the API token's owner.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      responses:
        '200':
          description: List of attachments
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  description: A file attached to a sales order.
                  properties:
                    id:
                      type: integer
                      description: Attachment ID
                    original_filename:
                      type: string
                      description: The original name of the uploaded file.
                    mime_type:
                      type: string
                      nullable: true
                      description: The file's MIME type (e.g. `application/pdf`).
                    size_bytes:
                      type: integer
                      description: File size in bytes.
                    uploaded_by:
                      type: object
                      nullable: true
                      description: The user who uploaded the file. Null if the uploader is unknown.
                      properties:
                        id:
                          type: integer
                          description: User ID
                        name:
                          type: string
                          nullable: true
                          description: 'The uploader''s full name, or email address if no name is set.'
                    created_at:
                      type: string
                      format: date-time
                      nullable: true
                      description: ISO 8601 timestamp of when the attachment was created.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token owner lacks the `salesOrders.read` permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: uploadSalesOrderAttachment
      tags:
        - Sales Orders
      summary: Upload a sales order attachment
      description: |
        Upload a file and attach it to a sales order. Send the file as `multipart/form-data`
        in a field named `file`.

        Allowed file types: PDF, PNG, JPG/JPEG, GIF, WEBP, DOC, DOCX, XLS, XLSX, CSV, TXT.
        Maximum file size: 20 MB.

        Requires the `salesOrders.update` permission on the API token's owner.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The file to upload
      responses:
        '200':
          description: Attachment uploaded
          content:
            application/json:
              schema:
                type: object
                description: A file attached to a sales order.
                properties:
                  id:
                    type: integer
                    description: Attachment ID
                  original_filename:
                    type: string
                    description: The original name of the uploaded file.
                  mime_type:
                    type: string
                    nullable: true
                    description: The file's MIME type (e.g. `application/pdf`).
                  size_bytes:
                    type: integer
                    description: File size in bytes.
                  uploaded_by:
                    type: object
                    nullable: true
                    description: The user who uploaded the file. Null if the uploader is unknown.
                    properties:
                      id:
                        type: integer
                        description: User ID
                      name:
                        type: string
                        nullable: true
                        description: 'The uploader''s full name, or email address if no name is set.'
                  created_at:
                    type: string
                    format: date-time
                    nullable: true
                    description: ISO 8601 timestamp of when the attachment was created.
        '400':
          description: 'The file was rejected (type not allowed, or exceeds the 20 MB limit)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token owner lacks the `salesOrders.update` permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/attachments/{attachmentId}/download':
    get:
      operationId: downloadSalesOrderAttachment
      tags:
        - Sales Orders
      summary: Download a sales order attachment
      description: |
        Download an attachment file from a sales order. The file bytes are streamed over the
        authenticated connection.

        Requires the `salesOrders.read` permission on the API token's owner.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
        - in: path
          name: attachmentId
          required: true
          schema:
            type: integer
          description: Attachment ID
      responses:
        '200':
          description: File download
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: The attachment has no file on disk
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token owner lacks the `salesOrders.read` permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order or attachment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/sales-orders/{salesOrderId}/attachments/{attachmentId}':
    delete:
      operationId: deleteSalesOrderAttachment
      tags:
        - Sales Orders
      summary: Delete a sales order attachment
      description: |
        Delete an attachment from a sales order.

        Requires the `salesOrders.update` permission on the API token's owner.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: Sales order ID
        - in: path
          name: attachmentId
          required: true
          schema:
            type: integer
          description: Attachment ID
      responses:
        '200':
          description: Attachment deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: string
                    example: Attachment deleted.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token owner lacks the `salesOrders.update` permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Sales order or attachment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /purgatory/orders:
    get:
      operationId: getPurgatoryOrders
      tags:
        - Purgatory
      summary: List non-posted (purgatory) sales orders
      description: |
        Returns a paginated list of sales orders currently in purgatory — orders
        that have been ingested from a sales channel but **not yet posted** into
        Luminous inventory and accounting (`is_posted = false`).

        Accepts every filter, sort, and pagination parameter that `GET /sales-orders`
        accepts. The `posted=false` constraint is forced on regardless of caller input.

        An order sits in purgatory while at least one of these conditions holds:
        - A line item's channel SKU doesn't match any Luminous product SKU or alternate SKU.
        - The order is empty or all lines are marked as ignored.
        - Tenant policy requires human review before the order touches inventory.

        Use `PATCH /purgatory/order-items/{id}` to map line items, then
        `POST /purgatory/jobs/reprocess` to re-evaluate orders against the current settings.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Items per page (max 100)
        - in: query
          name: order_number
          schema:
            type: string
          description: Filter by order number
        - in: query
          name: order_status
          schema:
            type: string
          description: Filter by order status
        - in: query
          name: channel_name
          schema:
            type: string
          description: Filter by channel name
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by tag name
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
      responses:
        '200':
          description: Paginated list of purgatory sales orders
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the sales order
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the order was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the order was last updated
                        status:
                          type: string
                          description: Current status of the order
                        order_id:
                          type: string
                          description: External order identifier
                        order_number:
                          type: string
                          description: Order number
                        order_date:
                          type: string
                          format: date
                          description: Date when the order was placed
                        payment_date:
                          type: string
                          format: date
                          description: Date when payment was received
                        ship_by_date:
                          type: string
                          format: date
                          description: Required ship by date
                        age:
                          type: integer
                          description: Age of the order in days
                        order_status:
                          type: string
                          description: Status of the order
                        customer_id:
                          type: string
                          description: Customer identifier
                        customer_username:
                          type: string
                          description: Customer's username
                        customer_email:
                          type: string
                          description: Customer's email address
                        bill_to:
                          type: object
                          description: Billing information
                        ship_to:
                          type: object
                          description: Shipping information
                        requested_shipping_service:
                          type: string
                          nullable: true
                          description: What shipping service to use when shipping this order
                        total:
                          type: number
                          format: float
                          description: Total order amount
                        total_paid:
                          type: number
                          format: float
                          description: Amount paid
                        total_tax:
                          type: number
                          format: float
                          description: Total tax amount
                        total_shipping:
                          type: number
                          format: float
                          description: Total shipping amount
                        customer_notes:
                          type: string
                          description: Notes from the customer
                        internal_notes:
                          type: string
                          description: Internal notes
                        ship_date:
                          type: string
                          format: date
                          description: Date when order was shipped
                        hold_until_date:
                          type: string
                          format: date
                          description: Hold until date
                        earliest_ship_date:
                          type: string
                          format: date
                          nullable: true
                          description: Earliest date the order can be shipped
                        user_id:
                          type: integer
                          description: User ID associated with the order
                        externally_fulfilled:
                          type: boolean
                          description: Whether the order is fulfilled externally
                        externally_fulfilled_by:
                          type: string
                          description: Entity fulfilling the order externally
                        is_posted:
                          type: boolean
                          description: Whether the order is posted
                        posted_by:
                          type: string
                          description: User who posted the order
                        not_sync:
                          type: boolean
                          description: Sync status
                        sales_posted:
                          type: boolean
                          description: Sales posting status
                        split_order:
                          type: boolean
                          description: Whether the order is split
                        skip_inventory:
                          type: boolean
                          description: Whether to skip inventory
                        skip_sales_report:
                          type: boolean
                          description: Whether to skip sales report
                        channel_id:
                          type: integer
                          description: Channel identifier
                        total_order_cost:
                          type: number
                          format: float
                          description: Total cost of order
                        total_order_quantity:
                          type: number
                          format: float
                          description: Total quantity of items
                        order_cost_details:
                          type: object
                          description: Detailed order cost information
                        source:
                          type: string
                          description: Order source
                        shipstation_order_id:
                          type: string
                          description: ShipStation order identifier
                        type:
                          type: string
                          description: Order type
                        parent_id:
                          type: integer
                          description: Parent order ID if applicable
                        shipping_revenue:
                          type: number
                          format: float
                          description: Revenue from shipping
                        product_total:
                          type: number
                          format: float
                          description: Total product amount
                        total_discount:
                          type: number
                          format: float
                          description: Total discount amount
                        picking_status:
                          type: string
                          description: Status of picking process
                        starred_description:
                          type: string
                          description: Description for starred orders
                        customer_po_number:
                          type: string
                          description: Customer PO number
                        company_id:
                          type: integer
                          nullable: true
                          description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                          example: 123
                        company:
                          nullable: true
                          description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the company
                              example: 123456
                            created_at:
                              type: string
                              format: date-time
                              description: When the company was created
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              description: When the company was last updated
                              example: '2023-03-15T14:30:00Z'
                            status:
                              type: string
                              description: Status of the company
                              enum:
                                - active
                                - inactive
                              example: active
                            name:
                              type: string
                              description: Company name
                              example: Acme Corporation
                            type:
                              type: string
                              nullable: true
                              description: Type of business
                              example: Retail
                            phone:
                              type: string
                              nullable: true
                              description: Primary phone number for the company
                              example: 555-123-4567
                            address:
                              type: string
                              nullable: true
                              description: Street address for the company
                              example: 123 Main St
                            address_line_2:
                              type: string
                              nullable: true
                              description: Additional address information
                              example: Suite 500
                            city:
                              type: string
                              nullable: true
                              description: City
                              example: Austin
                            state:
                              type: string
                              nullable: true
                              description: State/province
                              example: TX
                            postal_code:
                              type: string
                              nullable: true
                              description: Postal/ZIP code
                              example: '78701'
                            country:
                              type: string
                              nullable: true
                              description: Country
                              example: USA
                            full_address:
                              type: string
                              nullable: true
                              description: Complete formatted address
                              example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                            shipping_first_name:
                              type: string
                              nullable: true
                              description: First name for shipping contact (legacy field)
                              example: John
                            shipping_last_name:
                              type: string
                              nullable: true
                              description: Last name for shipping contact (legacy field)
                              example: Doe
                            shipping_email:
                              type: string
                              format: email
                              nullable: true
                              description: Email for shipping contact (legacy field)
                              example: shipping@acmecorp.com
                            shipping_phone:
                              type: string
                              nullable: true
                              description: Phone number for shipping contact (legacy field)
                              example: 555-987-6543
                            shipping_address:
                              type: string
                              nullable: true
                              description: Shipping street address (legacy field)
                              example: 456 Warehouse Blvd
                            shipping_city:
                              type: string
                              nullable: true
                              description: Shipping city (legacy field)
                              example: Austin
                            shipping_state:
                              type: string
                              nullable: true
                              description: Shipping state/province (legacy field)
                              example: TX
                            shipping_postal_code:
                              type: string
                              nullable: true
                              description: Shipping postal/ZIP code (legacy field)
                              example: '78745'
                            shipping_country:
                              type: string
                              nullable: true
                              description: Shipping country (legacy field)
                              example: USA
                            shipping_full_address:
                              type: string
                              nullable: true
                              description: Complete formatted shipping address (legacy field)
                              example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                            payment_term:
                              type: string
                              nullable: true
                              description: Payment terms for the company
                              example: Net 30
                            tax_exempt:
                              type: boolean
                              nullable: true
                              description: Whether the company is exempt from taxes
                              example: false
                            tax_rate:
                              type: number
                              format: float
                              nullable: true
                              description: Tax rate applied to the company's orders
                              example: 8.25
                            due_date_days:
                              type: integer
                              nullable: true
                              description: Number of days until payment is due
                              example: 30
                            credit_limit:
                              type: number
                              format: float
                              nullable: true
                              description: Credit limit for the company. `null` means no limit is set.
                              example: 5000
                            header_discount_enabled:
                              type: boolean
                              description: Whether an order-header trade discount is applied by default for this company
                              example: false
                            header_discount_type:
                              type: string
                              nullable: true
                              enum:
                                - PERCENT
                                - FIXED_AMOUNT
                              description: How the header discount is calculated — a percentage of the order or a fixed amount
                              example: PERCENT
                            header_discount_value:
                              type: number
                              format: float
                              nullable: true
                              description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                              example: 5
                            header_discount_effective_from:
                              type: string
                              format: date
                              nullable: true
                              description: Date from which the header discount takes effect (YYYY-MM-DD)
                              example: '2026-01-01'
                            default_currency_code:
                              type: string
                              nullable: true
                              description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                              example: USD
                            price_level:
                              nullable: true
                              description: Price level associated with this company
                              type: object
                              properties:
                                id:
                                  type: number
                                  description: Unique identifier for the price level
                                  example: 123
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the price level was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the price level was last updated
                                  example: '2023-03-15T14:30:00Z'
                                status:
                                  type: string
                                  description: Status of the price level
                                  enum:
                                    - active
                                    - inactive
                                  example: active
                                name:
                                  type: string
                                  description: Name of the price level
                                  example: Wholesale
                                type:
                                  type: string
                                  description: Type of the price level
                                  example: percentage
                                percent_increase:
                                  type: number
                                  format: float
                                  description: Percentage increase (or decrease) for this price level
                                  example: 15.5
                            notes:
                              type: string
                              nullable: true
                              description: Additional notes about the company
                              example: 'Key account, requires special handling'
                            fein:
                              type: string
                              nullable: true
                              description: Federal Employer Identification Number
                              example: 12-3456789
                            tags:
                              type: array
                              nullable: true
                              description: List of tags associated with the company
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the tag
                                  name:
                                    type: string
                                    description: Name of the tag
                                  description:
                                    type: string
                                    nullable: true
                                    description: Description of the tag
                                  icon:
                                    type: string
                                    nullable: true
                                    description: Icon identifier or URL for the tag
                                  color:
                                    type: string
                                    nullable: true
                                    description: Color code for the tag
                                required:
                                  - id
                                  - name
                            default_shipping:
                              nullable: true
                              description: Default shipping address
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the shipping address
                                  example: 789
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was last updated
                                  example: '2023-03-15T14:30:00Z'
                                company_id:
                                  type: integer
                                  description: ID of the company this shipping address belongs to
                                  example: 123456
                                company_name:
                                  type: string
                                  nullable: true
                                  description: Name of the company
                                  example: Acme Corporation
                                address:
                                  type: string
                                  description: Street address
                                  example: 456 Warehouse Blvd
                                address_line_2:
                                  type: string
                                  nullable: true
                                  description: Additional address information
                                  example: Building 2
                                city:
                                  type: string
                                  description: City
                                  example: Austin
                                state:
                                  type: string
                                  description: State/province
                                  example: TX
                                postal_code:
                                  type: string
                                  description: Postal/ZIP code
                                  example: '78745'
                                country:
                                  type: string
                                  description: Country
                                  example: USA
                                full_address:
                                  type: string
                                  description: Complete formatted address
                                  example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                full_name:
                                  type: string
                                  description: Full name of the contact person
                                  example: John Doe
                                first_name:
                                  type: string
                                  nullable: true
                                  description: First name of the contact person
                                  example: John
                                last_name:
                                  type: string
                                  nullable: true
                                  description: Last name of the contact person
                                  example: Doe
                                phone:
                                  type: string
                                  nullable: true
                                  description: Phone number
                                  example: 555-987-6543
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  description: Email address
                                  example: shipping@acmecorp.com
                                is_default:
                                  type: boolean
                                  description: Whether this is the default shipping address
                                  example: true
                              required:
                                - id
                                - company_id
                                - address
                                - city
                                - state
                                - postal_code
                                - country
                            shipping_addresses:
                              type: array
                              nullable: true
                              description: List of shipping addresses for the company
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the shipping address
                                    example: 789
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: When the shipping address was created
                                    example: '2023-03-15T14:30:00Z'
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: When the shipping address was last updated
                                    example: '2023-03-15T14:30:00Z'
                                  company_id:
                                    type: integer
                                    description: ID of the company this shipping address belongs to
                                    example: 123456
                                  company_name:
                                    type: string
                                    nullable: true
                                    description: Name of the company
                                    example: Acme Corporation
                                  address:
                                    type: string
                                    description: Street address
                                    example: 456 Warehouse Blvd
                                  address_line_2:
                                    type: string
                                    nullable: true
                                    description: Additional address information
                                    example: Building 2
                                  city:
                                    type: string
                                    description: City
                                    example: Austin
                                  state:
                                    type: string
                                    description: State/province
                                    example: TX
                                  postal_code:
                                    type: string
                                    description: Postal/ZIP code
                                    example: '78745'
                                  country:
                                    type: string
                                    description: Country
                                    example: USA
                                  full_address:
                                    type: string
                                    description: Complete formatted address
                                    example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                  full_name:
                                    type: string
                                    description: Full name of the contact person
                                    example: John Doe
                                  first_name:
                                    type: string
                                    nullable: true
                                    description: First name of the contact person
                                    example: John
                                  last_name:
                                    type: string
                                    nullable: true
                                    description: Last name of the contact person
                                    example: Doe
                                  phone:
                                    type: string
                                    nullable: true
                                    description: Phone number
                                    example: 555-987-6543
                                  email:
                                    type: string
                                    format: email
                                    nullable: true
                                    description: Email address
                                    example: shipping@acmecorp.com
                                  is_default:
                                    type: boolean
                                    description: Whether this is the default shipping address
                                    example: true
                                required:
                                  - id
                                  - company_id
                                  - address
                                  - city
                                  - state
                                  - postal_code
                                  - country
                            billing_info:
                              type: object
                              nullable: true
                              description: Billing information
                              properties:
                                id:
                                  type: integer
                                  example: 456
                                created_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                first_name:
                                  type: string
                                  nullable: true
                                  example: Jane
                                last_name:
                                  type: string
                                  nullable: true
                                  example: Smith
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  example: accounting@acmecorp.com
                                receiving_bank_name:
                                  type: string
                                  nullable: true
                                  example: First National Bank
                                receiving_bank_address:
                                  type: string
                                  nullable: true
                                  example: '789 Finance Street, Austin, TX 78701'
                            client_type:
                              type: object
                              nullable: true
                              description: Type of client
                              properties:
                                id:
                                  type: integer
                                  example: 123
                                created_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                name:
                                  type: string
                                  example: Retail
                                description:
                                  type: string
                                  nullable: true
                                  example: Retail business client
                            parent_company_id:
                              type: integer
                              nullable: true
                              description: ID of the parent company
                              example: 456
                            invoice_export_template_id:
                              type: integer
                              nullable: true
                              description: ID of the invoice export template
                              example: 789
                            custom_fields:
                              type: object
                              description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              example:
                                Industry: Manufacturing
                                Region: Southwest
                                Annual Revenue: $5M-$10M
                            assigned_sales_reps:
                              type: array
                              description: |
                                Sales rep users assigned to this company (Go Team members). Resolved from the company's
                                `goTeamMember.user` relation. Only present when the relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: User ID of the assigned sales rep
                                    example: 42
                                  email:
                                    type: string
                                    description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                    example: rep@example.com
                                  first_name:
                                    type: string
                                    nullable: true
                                    example: Jane
                                  last_name:
                                    type: string
                                    nullable: true
                                    example: Doe
                            sales_channel:
                              allOf:
                                - type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Sales channel ID.
                                    status:
                                      type: string
                                      description: Sales channel status (e.g. active).
                                    label:
                                      type: string
                                      nullable: true
                                      description: Human-readable channel label.
                                    channel_type:
                                      type: string
                                      nullable: true
                                      description: Channel type (e.g. the integration/platform the channel represents).
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                              nullable: true
                              description: The company's default sales channel. Only present when the relation is loaded.
                          required:
                            - id
                            - name
                            - status
                        custom_fields:
                          type: object
                          description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties:
                            type: string
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the order item
                              line_number:
                                type: integer
                                description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                              created_at:
                                type: string
                                format: date-time
                                description: Creation timestamp
                              updated_at:
                                type: string
                                format: date-time
                                description: Last update timestamp
                              sku:
                                type: string
                                description: Stock keeping unit
                              name:
                                type: string
                                description: Product name
                              image_url:
                                type: string
                                description: URL of product image
                              weight:
                                type: object
                                description: Weight information
                              quantity:
                                type: number
                                format: float
                                description: Ordered quantity
                              unit_price:
                                type: number
                                format: float
                                description: Price per unit
                              tax:
                                type: number
                                format: float
                                description: Tax amount
                              shipping:
                                type: number
                                format: float
                                description: Shipping amount
                              warehouse_location:
                                type: string
                                description: Location in warehouse
                              options:
                                type: object
                                description: Additional options
                              fulfillment_sku:
                                type: string
                                description: SKU used for fulfillment
                              adjustment:
                                type: number
                                format: float
                                description: Price adjustment
                              upc:
                                type: string
                                description: Universal Product Code
                              stock_id:
                                type: integer
                                description: Stock identifier
                              kit_id:
                                type: integer
                                description: Kit identifier if part of a kit
                              non_physical_item:
                                type: boolean
                                description: Whether item is non-physical
                              ignore_item:
                                type: boolean
                                description: Whether to ignore this item
                              is_locally_added:
                                type: boolean
                                description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                              quantity_shipped:
                                type: number
                                format: float
                                description: Quantity shipped
                              quantity_cancelled:
                                type: number
                                format: float
                                description: Quantity cancelled
                              quantity_invoiced:
                                type: number
                                format: float
                                description: Quantity invoiced
                              quantity_ordered:
                                type: number
                                format: float
                                description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                              base_uom_id:
                                type: integer
                                description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                              ordered_uom_id:
                                type: integer
                                description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                              product_id:
                                type: integer
                                description: Product identifier
                              total_returned_base_quantity:
                                type: number
                                format: float
                                description: Total quantity returned
                              parent_id:
                                type: integer
                                description: Parent item ID
                              status:
                                type: string
                                description: Item status
                              discount:
                                type: number
                                format: float
                                description: Discount amount
                              estimated_ship_date:
                                type: string
                                format: date
                                description: Estimated shipping date
                              custom_fields:
                                type: object
                                description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties:
                                  type: string
                              product:
                                type: object
                                description: Product information
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the product
                                  name:
                                    type: string
                                    description: Product name
                                  description:
                                    type: string
                                    nullable: true
                                    description: Product description
                                  retail_price:
                                    type: number
                                    format: float
                                    description: Retail price
                                  wholesale_price:
                                    type: number
                                    format: float
                                    description: Wholesale price
                                  unit_cost:
                                    type: number
                                    format: float
                                    description: Cost per unit
                                  product_weight:
                                    type: number
                                    format: float
                                    description: Weight of the product
                                  product_length:
                                    type: number
                                    format: float
                                    description: Length of the product (in inches)
                                  product_width:
                                    type: number
                                    format: float
                                    description: Width of the product (in inches)
                                  product_height:
                                    type: number
                                    format: float
                                    description: Height of the product (in inches)
                                  sellable:
                                    type: boolean
                                    description: Whether the product can be sold
                                  discontinued:
                                    type: boolean
                                    description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                  image_url:
                                    type: string
                                    nullable: true
                                    description: URL to the product's main image
                                  category:
                                    type: object
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                    description: Product category information
                                  subcategory:
                                    type: object
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                    description: Product subcategory information
                                  custom_fields:
                                    type: object
                                    description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                    additionalProperties:
                                      type: string
                                  variant_attributes:
                                    type: object
                                    nullable: true
                                    description: Available variant attributes
                                  sku:
                                    type: string
                                    description: Internal SKU
                                  alternate_skus:
                                    type: array
                                    description: Alternate SKUs
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                        sku:
                                          type: string
                                  upc:
                                    type: string
                                    description: UPC/Barcode
                                  tags:
                                    type: array
                                    description: Tags associated with the product
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the tag
                                        name:
                                          type: string
                                          description: Name of the tag
                                        description:
                                          type: string
                                          nullable: true
                                          description: Description of the tag
                                        icon:
                                          type: string
                                          nullable: true
                                          description: Icon identifier or URL for the tag
                                        color:
                                          type: string
                                          nullable: true
                                          description: Color code for the tag
                                      required:
                                        - id
                                        - name
                                  supplier:
                                    type: object
                                    nullable: true
                                    description: Supplier information
                                  type:
                                    type: string
                                    enum:
                                      - PRODUCT
                                      - KIT
                                    description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                  kit_items:
                                    type: array
                                    nullable: true
                                    description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the kit item
                                        product_id:
                                          type: integer
                                          description: ID of the product component
                                        quantity:
                                          type: number
                                          format: float
                                          description: Quantity of this component in the kit
                                        uom_id:
                                          type: integer
                                          description: Unit of measure ID for the quantity
                                        base_uom_quantity:
                                          type: number
                                          format: float
                                          description: Quantity converted to base unit of measure
                                        price:
                                          type: number
                                          format: float
                                          description: Price for this kit item
                                        original_price:
                                          type: number
                                          format: float
                                          description: Original price for this kit item
                                        total:
                                          type: number
                                          format: float
                                          description: Calculated total (quantity * price)
                                        product:
                                          type: object
                                          nullable: true
                                          description: Product information for this kit item (when loaded)
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                            sku:
                                              type: string
                                            description:
                                              type: string
                                              nullable: true
                                            retail_price:
                                              type: number
                                              format: float
                                            wholesale_price:
                                              type: number
                                              format: float
                                        unit_of_measure:
                                          type: object
                                          nullable: true
                                          description: Unit of measure information (when loaded)
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                            description:
                                              type: string
                                              nullable: true
                                            base_unit:
                                              type: boolean
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was last updated
                              tags:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    description:
                                      type: string
                                    icon:
                                      type: string
                                    color:
                                      type: string
                                    discount_structure:
                                      type: object
                                    markup_structure:
                                      type: object
                                description: Tags associated with the sales order item
                          description: Line items in the order
                        fulfillment_orders:
                          type: array
                          description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Fulfillment order ID
                              order_number:
                                type: string
                                description: Fulfillment order number
                              order_key:
                                type: string
                                nullable: true
                                description: Fulfillment order key
                              order_status:
                                type: string
                                description: Fulfillment order status
                              sales_order_id:
                                type: integer
                                description: Associated sales order ID
                              warehouse_group_id:
                                type: integer
                                nullable: true
                                description: Warehouse group ID
                              destination_oms_id:
                                type: integer
                                nullable: true
                                description: Destination app integration account ID
                              destination_oms_store_id:
                                type: integer
                                nullable: true
                              fulfillment_channel_id:
                                type: integer
                                nullable: true
                              pushed_at:
                                type: string
                                format: date-time
                                nullable: true
                              packing_slip_printed_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                              error_message:
                                type: string
                                nullable: true
                                description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                              ship_by_date:
                                type: string
                                format: date
                                nullable: true
                                description: Ship by date
                              total:
                                type: number
                                format: float
                                nullable: true
                                description: Order total
                              bill_to:
                                type: object
                                nullable: true
                                description: Billing address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              ship_to:
                                type: object
                                nullable: true
                                description: Shipping address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              invoice_to:
                                type: object
                                nullable: true
                                description: Invoice address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              sales_order:
                                type: object
                                nullable: true
                                description: Nested sales order data
                              picklists:
                                type: array
                                description: Associated picklists
                                items:
                                  type: object
                              fulfillment_order_items:
                                type: array
                                description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      nullable: true
                                      description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                    shipment_id:
                                      type: integer
                                      nullable: true
                                      description: ID of the fulfillment order this line belongs to.
                                    status:
                                      nullable: true
                                      description: Line status.
                                    sales_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                    sku:
                                      type: string
                                      nullable: true
                                    name:
                                      type: string
                                      nullable: true
                                    weight:
                                      nullable: true
                                      description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                    dimensions:
                                      nullable: true
                                      description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                    quantity:
                                      type: number
                                      description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                    unit_price:
                                      type: number
                                      description: Unit price. Always `0` on synthetic component rows.
                                    lot_id:
                                      type: integer
                                      nullable: true
                                    lot_number:
                                      type: string
                                      nullable: true
                                    expiry_date:
                                      type: string
                                      nullable: true
                                      description: Lot expiry date.
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    is_kit_component:
                                      type: boolean
                                      description: True when the row is a component of a kit (stored or synthetic).
                                    parent_fulfillment_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                    kit_sales_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                    is_synthetic:
                                      type: boolean
                                      description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                              total_weight:
                                type: object
                                nullable: true
                                description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                                properties:
                                  total_oz:
                                    type: number
                                    format: float
                                    description: Total weight in ounces
                                  total_lb:
                                    type: number
                                    format: float
                                    description: Total weight in pounds
                                  line_count:
                                    type: integer
                                    description: Number of fulfillment order lines
                                  weighed_line_count:
                                    type: integer
                                    description: Number of lines that had a usable weight and contributed to the total
                                  is_complete:
                                    type: boolean
                                    description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                              tags:
                                type: array
                                description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the tag
                                    name:
                                      type: string
                                      description: Name of the tag
                                    description:
                                      type: string
                                      nullable: true
                                      description: Description of the tag
                                    icon:
                                      type: string
                                      nullable: true
                                      description: Icon identifier or URL for the tag
                                    color:
                                      type: string
                                      nullable: true
                                      description: Color code for the tag
                                  required:
                                    - id
                                    - name
                              purchase_orders:
                                type: array
                                description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    order_status:
                                      type: string
                                      nullable: true
                                      enum:
                                        - active
                                        - deleted
                                        - completed
                              source_reference_identifier:
                                type: string
                                nullable: true
                                description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                              held_for_item_change:
                                type: boolean
                                description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                              created_at:
                                type: string
                                format: date-time
                                description: When the fulfillment order was created
                              updated_at:
                                type: string
                                format: date-time
                                description: When the fulfillment order was last updated
                        tags:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                              icon:
                                type: string
                              color:
                                type: string
                              discount_structure:
                                type: object
                              markup_structure:
                                type: object
                          description: Tags associated with the order
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purgatory/orders/{salesOrderId}':
    get:
      operationId: getPurgatoryOrder
      tags:
        - Purgatory
      summary: Get a single non-posted order
      description: |
        Returns a single sales order that is currently in purgatory, including its
        line items, tags, custom fields, and fulfillment orders.

        Returns **410 Gone** if the order has already been posted (i.e. it has left
        purgatory). The 410 body includes a `redirect` field pointing at the
        canonical `GET /sales-orders/{id}` endpoint for posted orders — this is
        the expected healthy outcome after a successful purgatory reprocess.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderId
          required: true
          schema:
            type: integer
          description: ID of the sales order
      responses:
        '200':
          description: Sales order details
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the sales order
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the order was last updated
                      status:
                        type: string
                        description: Current status of the order
                      order_id:
                        type: string
                        description: External order identifier
                      order_number:
                        type: string
                        description: Order number
                      order_date:
                        type: string
                        format: date
                        description: Date when the order was placed
                      payment_date:
                        type: string
                        format: date
                        description: Date when payment was received
                      ship_by_date:
                        type: string
                        format: date
                        description: Required ship by date
                      age:
                        type: integer
                        description: Age of the order in days
                      order_status:
                        type: string
                        description: Status of the order
                      customer_id:
                        type: string
                        description: Customer identifier
                      customer_username:
                        type: string
                        description: Customer's username
                      customer_email:
                        type: string
                        description: Customer's email address
                      bill_to:
                        type: object
                        description: Billing information
                      ship_to:
                        type: object
                        description: Shipping information
                      requested_shipping_service:
                        type: string
                        nullable: true
                        description: What shipping service to use when shipping this order
                      total:
                        type: number
                        format: float
                        description: Total order amount
                      total_paid:
                        type: number
                        format: float
                        description: Amount paid
                      total_tax:
                        type: number
                        format: float
                        description: Total tax amount
                      total_shipping:
                        type: number
                        format: float
                        description: Total shipping amount
                      customer_notes:
                        type: string
                        description: Notes from the customer
                      internal_notes:
                        type: string
                        description: Internal notes
                      ship_date:
                        type: string
                        format: date
                        description: Date when order was shipped
                      hold_until_date:
                        type: string
                        format: date
                        description: Hold until date
                      earliest_ship_date:
                        type: string
                        format: date
                        nullable: true
                        description: Earliest date the order can be shipped
                      user_id:
                        type: integer
                        description: User ID associated with the order
                      externally_fulfilled:
                        type: boolean
                        description: Whether the order is fulfilled externally
                      externally_fulfilled_by:
                        type: string
                        description: Entity fulfilling the order externally
                      is_posted:
                        type: boolean
                        description: Whether the order is posted
                      posted_by:
                        type: string
                        description: User who posted the order
                      not_sync:
                        type: boolean
                        description: Sync status
                      sales_posted:
                        type: boolean
                        description: Sales posting status
                      split_order:
                        type: boolean
                        description: Whether the order is split
                      skip_inventory:
                        type: boolean
                        description: Whether to skip inventory
                      skip_sales_report:
                        type: boolean
                        description: Whether to skip sales report
                      channel_id:
                        type: integer
                        description: Channel identifier
                      total_order_cost:
                        type: number
                        format: float
                        description: Total cost of order
                      total_order_quantity:
                        type: number
                        format: float
                        description: Total quantity of items
                      order_cost_details:
                        type: object
                        description: Detailed order cost information
                      source:
                        type: string
                        description: Order source
                      shipstation_order_id:
                        type: string
                        description: ShipStation order identifier
                      type:
                        type: string
                        description: Order type
                      parent_id:
                        type: integer
                        description: Parent order ID if applicable
                      shipping_revenue:
                        type: number
                        format: float
                        description: Revenue from shipping
                      product_total:
                        type: number
                        format: float
                        description: Total product amount
                      total_discount:
                        type: number
                        format: float
                        description: Total discount amount
                      picking_status:
                        type: string
                        description: Status of picking process
                      starred_description:
                        type: string
                        description: Description for starred orders
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      company_id:
                        type: integer
                        nullable: true
                        description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                        example: 123
                      company:
                        nullable: true
                        description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the company
                            example: 123456
                          created_at:
                            type: string
                            format: date-time
                            description: When the company was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the company was last updated
                            example: '2023-03-15T14:30:00Z'
                          status:
                            type: string
                            description: Status of the company
                            enum:
                              - active
                              - inactive
                            example: active
                          name:
                            type: string
                            description: Company name
                            example: Acme Corporation
                          type:
                            type: string
                            nullable: true
                            description: Type of business
                            example: Retail
                          phone:
                            type: string
                            nullable: true
                            description: Primary phone number for the company
                            example: 555-123-4567
                          address:
                            type: string
                            nullable: true
                            description: Street address for the company
                            example: 123 Main St
                          address_line_2:
                            type: string
                            nullable: true
                            description: Additional address information
                            example: Suite 500
                          city:
                            type: string
                            nullable: true
                            description: City
                            example: Austin
                          state:
                            type: string
                            nullable: true
                            description: State/province
                            example: TX
                          postal_code:
                            type: string
                            nullable: true
                            description: Postal/ZIP code
                            example: '78701'
                          country:
                            type: string
                            nullable: true
                            description: Country
                            example: USA
                          full_address:
                            type: string
                            nullable: true
                            description: Complete formatted address
                            example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                          shipping_first_name:
                            type: string
                            nullable: true
                            description: First name for shipping contact (legacy field)
                            example: John
                          shipping_last_name:
                            type: string
                            nullable: true
                            description: Last name for shipping contact (legacy field)
                            example: Doe
                          shipping_email:
                            type: string
                            format: email
                            nullable: true
                            description: Email for shipping contact (legacy field)
                            example: shipping@acmecorp.com
                          shipping_phone:
                            type: string
                            nullable: true
                            description: Phone number for shipping contact (legacy field)
                            example: 555-987-6543
                          shipping_address:
                            type: string
                            nullable: true
                            description: Shipping street address (legacy field)
                            example: 456 Warehouse Blvd
                          shipping_city:
                            type: string
                            nullable: true
                            description: Shipping city (legacy field)
                            example: Austin
                          shipping_state:
                            type: string
                            nullable: true
                            description: Shipping state/province (legacy field)
                            example: TX
                          shipping_postal_code:
                            type: string
                            nullable: true
                            description: Shipping postal/ZIP code (legacy field)
                            example: '78745'
                          shipping_country:
                            type: string
                            nullable: true
                            description: Shipping country (legacy field)
                            example: USA
                          shipping_full_address:
                            type: string
                            nullable: true
                            description: Complete formatted shipping address (legacy field)
                            example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                          payment_term:
                            type: string
                            nullable: true
                            description: Payment terms for the company
                            example: Net 30
                          tax_exempt:
                            type: boolean
                            nullable: true
                            description: Whether the company is exempt from taxes
                            example: false
                          tax_rate:
                            type: number
                            format: float
                            nullable: true
                            description: Tax rate applied to the company's orders
                            example: 8.25
                          due_date_days:
                            type: integer
                            nullable: true
                            description: Number of days until payment is due
                            example: 30
                          credit_limit:
                            type: number
                            format: float
                            nullable: true
                            description: Credit limit for the company. `null` means no limit is set.
                            example: 5000
                          header_discount_enabled:
                            type: boolean
                            description: Whether an order-header trade discount is applied by default for this company
                            example: false
                          header_discount_type:
                            type: string
                            nullable: true
                            enum:
                              - PERCENT
                              - FIXED_AMOUNT
                            description: How the header discount is calculated — a percentage of the order or a fixed amount
                            example: PERCENT
                          header_discount_value:
                            type: number
                            format: float
                            nullable: true
                            description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                            example: 5
                          header_discount_effective_from:
                            type: string
                            format: date
                            nullable: true
                            description: Date from which the header discount takes effect (YYYY-MM-DD)
                            example: '2026-01-01'
                          default_currency_code:
                            type: string
                            nullable: true
                            description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                            example: USD
                          price_level:
                            nullable: true
                            description: Price level associated with this company
                            type: object
                            properties:
                              id:
                                type: number
                                description: Unique identifier for the price level
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                description: When the price level was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the price level was last updated
                                example: '2023-03-15T14:30:00Z'
                              status:
                                type: string
                                description: Status of the price level
                                enum:
                                  - active
                                  - inactive
                                example: active
                              name:
                                type: string
                                description: Name of the price level
                                example: Wholesale
                              type:
                                type: string
                                description: Type of the price level
                                example: percentage
                              percent_increase:
                                type: number
                                format: float
                                description: Percentage increase (or decrease) for this price level
                                example: 15.5
                          notes:
                            type: string
                            nullable: true
                            description: Additional notes about the company
                            example: 'Key account, requires special handling'
                          fein:
                            type: string
                            nullable: true
                            description: Federal Employer Identification Number
                            example: 12-3456789
                          tags:
                            type: array
                            nullable: true
                            description: List of tags associated with the company
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the tag
                                name:
                                  type: string
                                  description: Name of the tag
                                description:
                                  type: string
                                  nullable: true
                                  description: Description of the tag
                                icon:
                                  type: string
                                  nullable: true
                                  description: Icon identifier or URL for the tag
                                color:
                                  type: string
                                  nullable: true
                                  description: Color code for the tag
                              required:
                                - id
                                - name
                          default_shipping:
                            nullable: true
                            description: Default shipping address
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the shipping address
                                example: 789
                              created_at:
                                type: string
                                format: date-time
                                description: When the shipping address was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the shipping address was last updated
                                example: '2023-03-15T14:30:00Z'
                              company_id:
                                type: integer
                                description: ID of the company this shipping address belongs to
                                example: 123456
                              company_name:
                                type: string
                                nullable: true
                                description: Name of the company
                                example: Acme Corporation
                              address:
                                type: string
                                description: Street address
                                example: 456 Warehouse Blvd
                              address_line_2:
                                type: string
                                nullable: true
                                description: Additional address information
                                example: Building 2
                              city:
                                type: string
                                description: City
                                example: Austin
                              state:
                                type: string
                                description: State/province
                                example: TX
                              postal_code:
                                type: string
                                description: Postal/ZIP code
                                example: '78745'
                              country:
                                type: string
                                description: Country
                                example: USA
                              full_address:
                                type: string
                                description: Complete formatted address
                                example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                              full_name:
                                type: string
                                description: Full name of the contact person
                                example: John Doe
                              first_name:
                                type: string
                                nullable: true
                                description: First name of the contact person
                                example: John
                              last_name:
                                type: string
                                nullable: true
                                description: Last name of the contact person
                                example: Doe
                              phone:
                                type: string
                                nullable: true
                                description: Phone number
                                example: 555-987-6543
                              email:
                                type: string
                                format: email
                                nullable: true
                                description: Email address
                                example: shipping@acmecorp.com
                              is_default:
                                type: boolean
                                description: Whether this is the default shipping address
                                example: true
                            required:
                              - id
                              - company_id
                              - address
                              - city
                              - state
                              - postal_code
                              - country
                          shipping_addresses:
                            type: array
                            nullable: true
                            description: List of shipping addresses for the company
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the shipping address
                                  example: 789
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was last updated
                                  example: '2023-03-15T14:30:00Z'
                                company_id:
                                  type: integer
                                  description: ID of the company this shipping address belongs to
                                  example: 123456
                                company_name:
                                  type: string
                                  nullable: true
                                  description: Name of the company
                                  example: Acme Corporation
                                address:
                                  type: string
                                  description: Street address
                                  example: 456 Warehouse Blvd
                                address_line_2:
                                  type: string
                                  nullable: true
                                  description: Additional address information
                                  example: Building 2
                                city:
                                  type: string
                                  description: City
                                  example: Austin
                                state:
                                  type: string
                                  description: State/province
                                  example: TX
                                postal_code:
                                  type: string
                                  description: Postal/ZIP code
                                  example: '78745'
                                country:
                                  type: string
                                  description: Country
                                  example: USA
                                full_address:
                                  type: string
                                  description: Complete formatted address
                                  example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                full_name:
                                  type: string
                                  description: Full name of the contact person
                                  example: John Doe
                                first_name:
                                  type: string
                                  nullable: true
                                  description: First name of the contact person
                                  example: John
                                last_name:
                                  type: string
                                  nullable: true
                                  description: Last name of the contact person
                                  example: Doe
                                phone:
                                  type: string
                                  nullable: true
                                  description: Phone number
                                  example: 555-987-6543
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  description: Email address
                                  example: shipping@acmecorp.com
                                is_default:
                                  type: boolean
                                  description: Whether this is the default shipping address
                                  example: true
                              required:
                                - id
                                - company_id
                                - address
                                - city
                                - state
                                - postal_code
                                - country
                          billing_info:
                            type: object
                            nullable: true
                            description: Billing information
                            properties:
                              id:
                                type: integer
                                example: 456
                              created_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              first_name:
                                type: string
                                nullable: true
                                example: Jane
                              last_name:
                                type: string
                                nullable: true
                                example: Smith
                              email:
                                type: string
                                format: email
                                nullable: true
                                example: accounting@acmecorp.com
                              receiving_bank_name:
                                type: string
                                nullable: true
                                example: First National Bank
                              receiving_bank_address:
                                type: string
                                nullable: true
                                example: '789 Finance Street, Austin, TX 78701'
                          client_type:
                            type: object
                            nullable: true
                            description: Type of client
                            properties:
                              id:
                                type: integer
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                example: '2023-03-15T14:30:00Z'
                              name:
                                type: string
                                example: Retail
                              description:
                                type: string
                                nullable: true
                                example: Retail business client
                          parent_company_id:
                            type: integer
                            nullable: true
                            description: ID of the parent company
                            example: 456
                          invoice_export_template_id:
                            type: integer
                            nullable: true
                            description: ID of the invoice export template
                            example: 789
                          custom_fields:
                            type: object
                            description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                            example:
                              Industry: Manufacturing
                              Region: Southwest
                              Annual Revenue: $5M-$10M
                          assigned_sales_reps:
                            type: array
                            description: |
                              Sales rep users assigned to this company (Go Team members). Resolved from the company's
                              `goTeamMember.user` relation. Only present when the relation is loaded.
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: User ID of the assigned sales rep
                                  example: 42
                                email:
                                  type: string
                                  description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                  example: rep@example.com
                                first_name:
                                  type: string
                                  nullable: true
                                  example: Jane
                                last_name:
                                  type: string
                                  nullable: true
                                  example: Doe
                          sales_channel:
                            allOf:
                              - type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Sales channel ID.
                                  status:
                                    type: string
                                    description: Sales channel status (e.g. active).
                                  label:
                                    type: string
                                    nullable: true
                                    description: Human-readable channel label.
                                  channel_type:
                                    type: string
                                    nullable: true
                                    description: Channel type (e.g. the integration/platform the channel represents).
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            nullable: true
                            description: The company's default sales channel. Only present when the relation is loaded.
                        required:
                          - id
                          - name
                          - status
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the order item
                            line_number:
                              type: integer
                              description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                            created_at:
                              type: string
                              format: date-time
                              description: Creation timestamp
                            updated_at:
                              type: string
                              format: date-time
                              description: Last update timestamp
                            sku:
                              type: string
                              description: Stock keeping unit
                            name:
                              type: string
                              description: Product name
                            image_url:
                              type: string
                              description: URL of product image
                            weight:
                              type: object
                              description: Weight information
                            quantity:
                              type: number
                              format: float
                              description: Ordered quantity
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            tax:
                              type: number
                              format: float
                              description: Tax amount
                            shipping:
                              type: number
                              format: float
                              description: Shipping amount
                            warehouse_location:
                              type: string
                              description: Location in warehouse
                            options:
                              type: object
                              description: Additional options
                            fulfillment_sku:
                              type: string
                              description: SKU used for fulfillment
                            adjustment:
                              type: number
                              format: float
                              description: Price adjustment
                            upc:
                              type: string
                              description: Universal Product Code
                            stock_id:
                              type: integer
                              description: Stock identifier
                            kit_id:
                              type: integer
                              description: Kit identifier if part of a kit
                            non_physical_item:
                              type: boolean
                              description: Whether item is non-physical
                            ignore_item:
                              type: boolean
                              description: Whether to ignore this item
                            is_locally_added:
                              type: boolean
                              description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                            quantity_shipped:
                              type: number
                              format: float
                              description: Quantity shipped
                            quantity_cancelled:
                              type: number
                              format: float
                              description: Quantity cancelled
                            quantity_invoiced:
                              type: number
                              format: float
                              description: Quantity invoiced
                            quantity_ordered:
                              type: number
                              format: float
                              description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                            base_uom_id:
                              type: integer
                              description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                            ordered_uom_id:
                              type: integer
                              description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                            product_id:
                              type: integer
                              description: Product identifier
                            total_returned_base_quantity:
                              type: number
                              format: float
                              description: Total quantity returned
                            parent_id:
                              type: integer
                              description: Parent item ID
                            status:
                              type: string
                              description: Item status
                            discount:
                              type: number
                              format: float
                              description: Discount amount
                            estimated_ship_date:
                              type: string
                              format: date
                              description: Estimated shipping date
                            custom_fields:
                              type: object
                              description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties:
                                type: string
                            product:
                              type: object
                              description: Product information
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: number
                                  format: float
                                  description: Weight of the product
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                category:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                  description: Product category information
                                subcategory:
                                  type: object
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                  description: Product subcategory information
                                custom_fields:
                                  type: object
                                  description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                  additionalProperties:
                                    type: string
                                variant_attributes:
                                  type: object
                                  nullable: true
                                  description: Available variant attributes
                                sku:
                                  type: string
                                  description: Internal SKU
                                alternate_skus:
                                  type: array
                                  description: Alternate SKUs
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                tags:
                                  type: array
                                  description: Tags associated with the product
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the tag
                                      name:
                                        type: string
                                        description: Name of the tag
                                      description:
                                        type: string
                                        nullable: true
                                        description: Description of the tag
                                      icon:
                                        type: string
                                        nullable: true
                                        description: Icon identifier or URL for the tag
                                      color:
                                        type: string
                                        nullable: true
                                        description: Color code for the tag
                                    required:
                                      - id
                                      - name
                                supplier:
                                  type: object
                                  nullable: true
                                  description: Supplier information
                                type:
                                  type: string
                                  enum:
                                    - PRODUCT
                                    - KIT
                                  description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                kit_items:
                                  type: array
                                  nullable: true
                                  description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the kit item
                                      product_id:
                                        type: integer
                                        description: ID of the product component
                                      quantity:
                                        type: number
                                        format: float
                                        description: Quantity of this component in the kit
                                      uom_id:
                                        type: integer
                                        description: Unit of measure ID for the quantity
                                      base_uom_quantity:
                                        type: number
                                        format: float
                                        description: Quantity converted to base unit of measure
                                      price:
                                        type: number
                                        format: float
                                        description: Price for this kit item
                                      original_price:
                                        type: number
                                        format: float
                                        description: Original price for this kit item
                                      total:
                                        type: number
                                        format: float
                                        description: Calculated total (quantity * price)
                                      product:
                                        type: object
                                        nullable: true
                                        description: Product information for this kit item (when loaded)
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          sku:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          retail_price:
                                            type: number
                                            format: float
                                          wholesale_price:
                                            type: number
                                            format: float
                                      unit_of_measure:
                                        type: object
                                        nullable: true
                                        description: Unit of measure information (when loaded)
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          base_unit:
                                            type: boolean
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                            tags:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  description:
                                    type: string
                                  icon:
                                    type: string
                                  color:
                                    type: string
                                  discount_structure:
                                    type: object
                                  markup_structure:
                                    type: object
                              description: Tags associated with the sales order item
                        description: Line items in the order
                      fulfillment_orders:
                        type: array
                        description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Fulfillment order ID
                            order_number:
                              type: string
                              description: Fulfillment order number
                            order_key:
                              type: string
                              nullable: true
                              description: Fulfillment order key
                            order_status:
                              type: string
                              description: Fulfillment order status
                            sales_order_id:
                              type: integer
                              description: Associated sales order ID
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              description: Warehouse group ID
                            destination_oms_id:
                              type: integer
                              nullable: true
                              description: Destination app integration account ID
                            destination_oms_store_id:
                              type: integer
                              nullable: true
                            fulfillment_channel_id:
                              type: integer
                              nullable: true
                            pushed_at:
                              type: string
                              format: date-time
                              nullable: true
                            packing_slip_printed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                            error_message:
                              type: string
                              nullable: true
                              description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                            ship_by_date:
                              type: string
                              format: date
                              nullable: true
                              description: Ship by date
                            total:
                              type: number
                              format: float
                              nullable: true
                              description: Order total
                            bill_to:
                              type: object
                              nullable: true
                              description: Billing address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            ship_to:
                              type: object
                              nullable: true
                              description: Shipping address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            invoice_to:
                              type: object
                              nullable: true
                              description: Invoice address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            sales_order:
                              type: object
                              nullable: true
                              description: Nested sales order data
                            picklists:
                              type: array
                              description: Associated picklists
                              items:
                                type: object
                            fulfillment_order_items:
                              type: array
                              description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    nullable: true
                                    description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                  shipment_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the fulfillment order this line belongs to.
                                  status:
                                    nullable: true
                                    description: Line status.
                                  sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                  sku:
                                    type: string
                                    nullable: true
                                  name:
                                    type: string
                                    nullable: true
                                  weight:
                                    nullable: true
                                    description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                  dimensions:
                                    nullable: true
                                    description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                  quantity:
                                    type: number
                                    description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                  unit_price:
                                    type: number
                                    description: Unit price. Always `0` on synthetic component rows.
                                  lot_id:
                                    type: integer
                                    nullable: true
                                  lot_number:
                                    type: string
                                    nullable: true
                                  expiry_date:
                                    type: string
                                    nullable: true
                                    description: Lot expiry date.
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  is_kit_component:
                                    type: boolean
                                    description: True when the row is a component of a kit (stored or synthetic).
                                  parent_fulfillment_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                  kit_sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                  is_synthetic:
                                    type: boolean
                                    description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                            total_weight:
                              type: object
                              nullable: true
                              description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                              properties:
                                total_oz:
                                  type: number
                                  format: float
                                  description: Total weight in ounces
                                total_lb:
                                  type: number
                                  format: float
                                  description: Total weight in pounds
                                line_count:
                                  type: integer
                                  description: Number of fulfillment order lines
                                weighed_line_count:
                                  type: integer
                                  description: Number of lines that had a usable weight and contributed to the total
                                is_complete:
                                  type: boolean
                                  description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                            tags:
                              type: array
                              description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the tag
                                  name:
                                    type: string
                                    description: Name of the tag
                                  description:
                                    type: string
                                    nullable: true
                                    description: Description of the tag
                                  icon:
                                    type: string
                                    nullable: true
                                    description: Icon identifier or URL for the tag
                                  color:
                                    type: string
                                    nullable: true
                                    description: Color code for the tag
                                required:
                                  - id
                                  - name
                            purchase_orders:
                              type: array
                              description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  order_status:
                                    type: string
                                    nullable: true
                                    enum:
                                      - active
                                      - deleted
                                      - completed
                            source_reference_identifier:
                              type: string
                              nullable: true
                              description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                            held_for_item_change:
                              type: boolean
                              description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                            created_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was last updated
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                            icon:
                              type: string
                            color:
                              type: string
                            discount_structure:
                              type: object
                            markup_structure:
                              type: object
                        description: Tags associated with the order
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '410':
          description: |
            Order has already been posted and is no longer in purgatory. Follow
            the `redirect` field to fetch the posted order via `/sales-orders/{id}`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Sales order is already posted; it is no longer in purgatory.
                  sales_order_id:
                    type: integer
                  status:
                    type: string
                    enum:
                      - posted
                  redirect:
                    type: string
                    description: Canonical path for the posted order
                    example: /external/api/v1/sales-orders/12345
                  hint:
                    type: string
  '/purgatory/order-items/{salesOrderItemId}':
    patch:
      operationId: mapPurgatoryOrderItem
      tags:
        - Purgatory
      summary: Map a line item to a product / toggle flags
      description: |
        Maps a non-posted sales order line item to a Luminous product, and/or
        toggles the `ignore_item` / `non_physical_item` flags so unmappable lines
        can clear purgatory.

        **Side effects:**
        - When `product_id` is set, the line's `rfq_id` is updated. If the parent
          order has a `warehouse_group_id`, a stock record for that
          product/warehouse-group pair is resolved or created.
        - When `add_as_alternate_sku=true` and the channel SKU differs from the
          product's internal SKU, an alternate SKU row is upserted so future orders
          with that SKU auto-map.
        - After the save, the parent order is re-evaluated against the current
          purgatory settings. If `post_clean_orders=true` and the last unmapped
          line just became mapped, the order can post automatically in the same step.

        Returns **422** if the parent order is already posted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: salesOrderItemId
          required: true
          schema:
            type: integer
          description: ID of the sales order line item
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                product_id:
                  type: integer
                  minimum: 1
                  nullable: true
                  description: |
                    Luminous product ID to map this line to. Omit to leave the mapping
                    untouched (useful when only toggling flags).
                add_as_alternate_sku:
                  type: boolean
                  default: false
                  description: |
                    When `true` and the line's channel SKU differs from the product's
                    internal SKU, upsert an alternate SKU record so future orders with
                    that SKU auto-map.
                non_physical_item:
                  type: boolean
                  description: Mark the line as non-physical (no inventory effect on post).
                ignore_item:
                  type: boolean
                  description: Mark the line as ignored for purgatory evaluation.
      responses:
        '200':
          description: Updated sales order line item
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the order item
                      line_number:
                        type: integer
                        description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                      created_at:
                        type: string
                        format: date-time
                        description: Creation timestamp
                      updated_at:
                        type: string
                        format: date-time
                        description: Last update timestamp
                      sku:
                        type: string
                        description: Stock keeping unit
                      name:
                        type: string
                        description: Product name
                      image_url:
                        type: string
                        description: URL of product image
                      weight:
                        type: object
                        description: Weight information
                      quantity:
                        type: number
                        format: float
                        description: Ordered quantity
                      unit_price:
                        type: number
                        format: float
                        description: Price per unit
                      tax:
                        type: number
                        format: float
                        description: Tax amount
                      shipping:
                        type: number
                        format: float
                        description: Shipping amount
                      warehouse_location:
                        type: string
                        description: Location in warehouse
                      options:
                        type: object
                        description: Additional options
                      fulfillment_sku:
                        type: string
                        description: SKU used for fulfillment
                      adjustment:
                        type: number
                        format: float
                        description: Price adjustment
                      upc:
                        type: string
                        description: Universal Product Code
                      stock_id:
                        type: integer
                        description: Stock identifier
                      kit_id:
                        type: integer
                        description: Kit identifier if part of a kit
                      non_physical_item:
                        type: boolean
                        description: Whether item is non-physical
                      ignore_item:
                        type: boolean
                        description: Whether to ignore this item
                      is_locally_added:
                        type: boolean
                        description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                      quantity_shipped:
                        type: number
                        format: float
                        description: Quantity shipped
                      quantity_cancelled:
                        type: number
                        format: float
                        description: Quantity cancelled
                      quantity_invoiced:
                        type: number
                        format: float
                        description: Quantity invoiced
                      quantity_ordered:
                        type: number
                        format: float
                        description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                      base_uom_id:
                        type: integer
                        description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                      ordered_uom_id:
                        type: integer
                        description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                      product_id:
                        type: integer
                        description: Product identifier
                      total_returned_base_quantity:
                        type: number
                        format: float
                        description: Total quantity returned
                      parent_id:
                        type: integer
                        description: Parent item ID
                      status:
                        type: string
                        description: Item status
                      discount:
                        type: number
                        format: float
                        description: Discount amount
                      estimated_ship_date:
                        type: string
                        format: date
                        description: Estimated shipping date
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      product:
                        type: object
                        description: Product information
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the product
                          name:
                            type: string
                            description: Product name
                          description:
                            type: string
                            nullable: true
                            description: Product description
                          retail_price:
                            type: number
                            format: float
                            description: Retail price
                          wholesale_price:
                            type: number
                            format: float
                            description: Wholesale price
                          unit_cost:
                            type: number
                            format: float
                            description: Cost per unit
                          product_weight:
                            type: number
                            format: float
                            description: Weight of the product
                          product_length:
                            type: number
                            format: float
                            description: Length of the product (in inches)
                          product_width:
                            type: number
                            format: float
                            description: Width of the product (in inches)
                          product_height:
                            type: number
                            format: float
                            description: Height of the product (in inches)
                          sellable:
                            type: boolean
                            description: Whether the product can be sold
                          discontinued:
                            type: boolean
                            description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                          image_url:
                            type: string
                            nullable: true
                            description: URL to the product's main image
                          category:
                            type: object
                            nullable: true
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                            description: Product category information
                          subcategory:
                            type: object
                            nullable: true
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                            description: Product subcategory information
                          custom_fields:
                            type: object
                            description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                            additionalProperties:
                              type: string
                          variant_attributes:
                            type: object
                            nullable: true
                            description: Available variant attributes
                          sku:
                            type: string
                            description: Internal SKU
                          alternate_skus:
                            type: array
                            description: Alternate SKUs
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                          upc:
                            type: string
                            description: UPC/Barcode
                          tags:
                            type: array
                            description: Tags associated with the product
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the tag
                                name:
                                  type: string
                                  description: Name of the tag
                                description:
                                  type: string
                                  nullable: true
                                  description: Description of the tag
                                icon:
                                  type: string
                                  nullable: true
                                  description: Icon identifier or URL for the tag
                                color:
                                  type: string
                                  nullable: true
                                  description: Color code for the tag
                              required:
                                - id
                                - name
                          supplier:
                            type: object
                            nullable: true
                            description: Supplier information
                          type:
                            type: string
                            enum:
                              - PRODUCT
                              - KIT
                            description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                          kit_items:
                            type: array
                            nullable: true
                            description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the kit item
                                product_id:
                                  type: integer
                                  description: ID of the product component
                                quantity:
                                  type: number
                                  format: float
                                  description: Quantity of this component in the kit
                                uom_id:
                                  type: integer
                                  description: Unit of measure ID for the quantity
                                base_uom_quantity:
                                  type: number
                                  format: float
                                  description: Quantity converted to base unit of measure
                                price:
                                  type: number
                                  format: float
                                  description: Price for this kit item
                                original_price:
                                  type: number
                                  format: float
                                  description: Original price for this kit item
                                total:
                                  type: number
                                  format: float
                                  description: Calculated total (quantity * price)
                                product:
                                  type: object
                                  nullable: true
                                  description: Product information for this kit item (when loaded)
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    sku:
                                      type: string
                                    description:
                                      type: string
                                      nullable: true
                                    retail_price:
                                      type: number
                                      format: float
                                    wholesale_price:
                                      type: number
                                      format: float
                                unit_of_measure:
                                  type: object
                                  nullable: true
                                  description: Unit of measure information (when loaded)
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    description:
                                      type: string
                                      nullable: true
                                    base_unit:
                                      type: boolean
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when the product was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when the product was last updated
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                            icon:
                              type: string
                            color:
                              type: string
                            discount_structure:
                              type: object
                            markup_structure:
                              type: object
                        description: Tags associated with the sales order item
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error or order already posted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /purgatory/jobs/auto-map:
    post:
      operationId: dispatchPurgatoryAutoMap
      tags:
        - Purgatory
      summary: Dispatch auto-mapping job
      description: |
        Dispatches the `OrderAutoMappingJob` to attempt to map line items in every
        non-posted order using existing SKU and alternate-SKU rules. Equivalent to
        the admin **"Auto Map SKUs and Reprocess Orders"** button.

        When `apply_purgatory_settings=true`, the job also re-runs purgatory rules
        after mapping completes, so cleanly-mapped orders can post automatically.

        Returns immediately — the actual work happens in the queue. Poll the order
        list or individual orders to see the results.
      security:
        - BearerAuth: []
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                apply_purgatory_settings:
                  type: boolean
                  default: false
                  description: |
                    When `true`, re-run purgatory rules after auto-mapping completes.
                    Equivalent to chaining auto-map and reprocess in one call.
      responses:
        '200':
          description: Job dispatched
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  job_id:
                    type: integer
                  apply_purgatory_settings:
                    type: boolean
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /purgatory/jobs/reprocess:
    post:
      operationId: dispatchPurgatoryReprocess
      tags:
        - Purgatory
      summary: Dispatch reprocess-purgatory job
      description: |
        Dispatches the `ReprocessOrdersThroughPurgatoryJob`, which re-evaluates
        every non-posted order against the **current** purgatory settings.

        Use this after editing settings via `PUT /purgatory/settings` if you want
        existing non-posted orders to feel the new rules immediately — by default,
        settings changes only apply to orders ingested after the change.

        Returns immediately — the actual work happens in the queue.
      security:
        - BearerAuth: []
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Job dispatched
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  job_id:
                    type: integer
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /purgatory/settings/schema:
    get:
      operationId: getPurgatorySettingsSchema
      tags:
        - Purgatory
      summary: Get purgatory settings schema
      description: |
        Returns the self-describing schema for the purgatory settings endpoint:
        every field's `type`, `default`, and human-readable `description`.

        Use this to build a settings UI or form without reading source code. The
        `schema_url` field on `GET /purgatory/settings` responses also points here.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Settings schema
          content:
            application/json:
              schema:
                type: object
                properties:
                  fields:
                    type: object
                    description: Keyed by external field name
                    additionalProperties:
                      type: object
                      properties:
                        type:
                          type: string
                          description: 'One of `bool`, `int`, `float`, `string`, `date`, `array<string>`'
                        description:
                          type: string
                        default:
                          nullable: true
                          description: Default value applied when the field is absent from storage
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /purgatory/settings:
    get:
      operationId: getPurgatorySettings
      tags:
        - Purgatory
      summary: Get purgatory automation settings
      description: |
        Returns all purgatory automation settings for the tenant, keyed by their
        external (snake_case) names. Includes a `schema_url` pointing at
        `GET /purgatory/settings/schema` for field-level documentation.

        Fields missing from stored configuration fall back to the default declared
        in the schema.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Current settings
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Purgatory automation settings. All fields are optional in write payloads —
                      only keys present in the body are updated. See `GET /purgatory/settings/schema`
                      for field-level types, defaults, and descriptions.
                    properties:
                      post_empty_orders:
                        type: boolean
                        description: Auto-post sales orders that have no line items.
                      post_orders_ignored_all_items:
                        type: boolean
                        description: Auto-post orders whose every line item is ignored.
                      post_clean_orders:
                        type: boolean
                        description: |
                          Auto-post orders whose remaining non-ignored lines are all mapped to a
                          product. **Affects inventory** — orders posted this way decrement stock.
                      ignore_empty_sku:
                        type: boolean
                        description: Treat line items with an empty SKU as ignored.
                      ignore_adjustment_line_item:
                        type: boolean
                        description: 'Treat adjustment lines (coupons, negative qty, etc.) as ignored.'
                      skip_inventory_for_old_shipments:
                        type: boolean
                        description: Do not deduct inventory for shipments older than the threshold.
                      skip_inventory_for_old_shipments_days:
                        type: integer
                        minimum: 0
                        description: Age in days at which a shipment is considered "old" for the skip rule.
                      skip_inventory_for_similar_orders:
                        type: boolean
                        description: Skip inventory for shipments that look like duplicates of recently-posted orders.
                      similarity_threshold:
                        type: number
                        format: float
                        minimum: 0
                        maximum: 1
                        nullable: true
                        description: |
                          Score (0–1) above which two orders are considered duplicates.
                          Required when `skip_inventory_for_similar_orders` is `true`.
                      skip_orders_older_than_date_cutoff:
                        type: string
                        format: date-time
                        nullable: true
                        description: |
                          Orders with `order_date` before this ISO 8601 datetime are skipped by
                          purgatory automation. `null` disables the cutoff.
                      skip_orders_older_than_date_cutoff_by_account:
                        type: array
                        description: |
                          Per-app-integration-account `order_date` cutoffs. A matching account row
                          overrides the global `skip_orders_older_than_date_cutoff` for that account;
                          accounts without a row fall back to the global cutoff.
                        items:
                          type: object
                          required:
                            - app_integration_account_id
                            - cutoff
                          properties:
                            app_integration_account_id:
                              type: integer
                              minimum: 1
                              description: ID of the app integration account this cutoff applies to.
                            cutoff:
                              type: string
                              format: date-time
                              description: ISO 8601 datetime; orders with `order_date` strictly before this are dropped for this account.
                      ignored_skus:
                        type: array
                        items:
                          type: string
                        description: 'SKUs to always treat as ignored (exact match, case-insensitive).'
                      ignored_product_names:
                        type: array
                        items:
                          type: string
                        description: 'Product names to always treat as ignored (exact match, case-insensitive).'
                      ignored_patterns:
                        type: array
                        items:
                          type: string
                        description: |
                          Substrings or PHP regex patterns (wrap regex in slashes, e.g. `/^test/`)
                          matched against the line item SKU or name.
                      push_client_invoice_to_shipstation:
                        type: boolean
                        description: Push generated client invoices back to ShipStation as posted orders.
                      push_client_invoice_shipstation_store_id:
                        type: integer
                        nullable: true
                        description: ShipStation store ID that receives pushed client invoices.
                      push_client_invoice_to_shipstation_automatically:
                        type: boolean
                        description: Push client invoices automatically rather than waiting for a manual trigger.
                      push_client_invoice_to_shipstation_timing:
                        type: string
                        nullable: true
                        description: 'When the automatic push fires (e.g. `on_invoice_create`, `on_invoice_send`).'
                      auto_create_skus:
                        type: object
                        description: |
                          Rules that auto-create a product (SKU) for unmapped purgatory line items
                          instead of leaving them unmapped (CS-10171). On a partial update, a
                          partial `auto_create_skus` object updates only the keys it names.
                        properties:
                          enabled:
                            type: boolean
                            description: Whether auto-create-SKU rules run.
                          channel_ids:
                            type: array
                            description: Sales channel IDs the rules apply to. Empty/omitted means all channels.
                            items:
                              type: integer
                              minimum: 1
                          default_category_id:
                            type: integer
                            minimum: 1
                            nullable: true
                            description: Product category assigned to a created SKU when a matching rule names no category.
                          default_user_id:
                            type: integer
                            minimum: 0
                            nullable: true
                            description: User recorded as the creator of auto-created SKUs.
                          rules:
                            type: array
                            description: Ordered rules. The first rule whose conditions all match a line item decides the created SKU's category.
                            items:
                              type: object
                              required:
                                - conditions
                              properties:
                                name:
                                  type: string
                                  maxLength: 255
                                  nullable: true
                                  description: Optional label for the rule.
                                product_category_id:
                                  type: integer
                                  minimum: 1
                                  nullable: true
                                  description: Category assigned to SKUs created by this rule; falls back to `default_category_id`.
                                conditions:
                                  type: array
                                  minItems: 1
                                  description: All conditions must match for the rule to apply.
                                  items:
                                    type: object
                                    required:
                                      - operator
                                      - value
                                    properties:
                                      field:
                                        type: string
                                        enum:
                                          - sku
                                          - product_name
                                        description: Which line-item field the condition tests. Defaults to `sku`.
                                      operator:
                                        type: string
                                        enum:
                                          - equals
                                          - starts_with
                                          - ends_with
                                          - contains
                                          - not_contains
                                          - regex
                                          - length_equals
                                          - length_min
                                          - length_max
                                        description: Comparison operator.
                                      value:
                                        description: 'Value to compare against (string for text operators, integer for the `length_*` operators; a valid PHP regex for `regex`).'
                  schema_url:
                    type: string
                    description: Absolute URL of `/purgatory/settings/schema`
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updatePurgatorySettings
      tags:
        - Purgatory
      summary: Partially update purgatory settings
      description: |
        **Partial update** — only fields present in the body are written. Omitted
        fields keep their stored values. Unknown field names are rejected with a
        pointer to `GET /purgatory/settings/schema`.

        Settings changes apply to **new** orders by default. Call
        `POST /purgatory/jobs/reprocess` afterwards to apply the new rules to
        existing non-posted orders.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Purgatory automation settings. All fields are optional in write payloads —
                only keys present in the body are updated. See `GET /purgatory/settings/schema`
                for field-level types, defaults, and descriptions.
              properties:
                post_empty_orders:
                  type: boolean
                  description: Auto-post sales orders that have no line items.
                post_orders_ignored_all_items:
                  type: boolean
                  description: Auto-post orders whose every line item is ignored.
                post_clean_orders:
                  type: boolean
                  description: |
                    Auto-post orders whose remaining non-ignored lines are all mapped to a
                    product. **Affects inventory** — orders posted this way decrement stock.
                ignore_empty_sku:
                  type: boolean
                  description: Treat line items with an empty SKU as ignored.
                ignore_adjustment_line_item:
                  type: boolean
                  description: 'Treat adjustment lines (coupons, negative qty, etc.) as ignored.'
                skip_inventory_for_old_shipments:
                  type: boolean
                  description: Do not deduct inventory for shipments older than the threshold.
                skip_inventory_for_old_shipments_days:
                  type: integer
                  minimum: 0
                  description: Age in days at which a shipment is considered "old" for the skip rule.
                skip_inventory_for_similar_orders:
                  type: boolean
                  description: Skip inventory for shipments that look like duplicates of recently-posted orders.
                similarity_threshold:
                  type: number
                  format: float
                  minimum: 0
                  maximum: 1
                  nullable: true
                  description: |
                    Score (0–1) above which two orders are considered duplicates.
                    Required when `skip_inventory_for_similar_orders` is `true`.
                skip_orders_older_than_date_cutoff:
                  type: string
                  format: date-time
                  nullable: true
                  description: |
                    Orders with `order_date` before this ISO 8601 datetime are skipped by
                    purgatory automation. `null` disables the cutoff.
                skip_orders_older_than_date_cutoff_by_account:
                  type: array
                  description: |
                    Per-app-integration-account `order_date` cutoffs. A matching account row
                    overrides the global `skip_orders_older_than_date_cutoff` for that account;
                    accounts without a row fall back to the global cutoff.
                  items:
                    type: object
                    required:
                      - app_integration_account_id
                      - cutoff
                    properties:
                      app_integration_account_id:
                        type: integer
                        minimum: 1
                        description: ID of the app integration account this cutoff applies to.
                      cutoff:
                        type: string
                        format: date-time
                        description: ISO 8601 datetime; orders with `order_date` strictly before this are dropped for this account.
                ignored_skus:
                  type: array
                  items:
                    type: string
                  description: 'SKUs to always treat as ignored (exact match, case-insensitive).'
                ignored_product_names:
                  type: array
                  items:
                    type: string
                  description: 'Product names to always treat as ignored (exact match, case-insensitive).'
                ignored_patterns:
                  type: array
                  items:
                    type: string
                  description: |
                    Substrings or PHP regex patterns (wrap regex in slashes, e.g. `/^test/`)
                    matched against the line item SKU or name.
                push_client_invoice_to_shipstation:
                  type: boolean
                  description: Push generated client invoices back to ShipStation as posted orders.
                push_client_invoice_shipstation_store_id:
                  type: integer
                  nullable: true
                  description: ShipStation store ID that receives pushed client invoices.
                push_client_invoice_to_shipstation_automatically:
                  type: boolean
                  description: Push client invoices automatically rather than waiting for a manual trigger.
                push_client_invoice_to_shipstation_timing:
                  type: string
                  nullable: true
                  description: 'When the automatic push fires (e.g. `on_invoice_create`, `on_invoice_send`).'
                auto_create_skus:
                  type: object
                  description: |
                    Rules that auto-create a product (SKU) for unmapped purgatory line items
                    instead of leaving them unmapped (CS-10171). On a partial update, a
                    partial `auto_create_skus` object updates only the keys it names.
                  properties:
                    enabled:
                      type: boolean
                      description: Whether auto-create-SKU rules run.
                    channel_ids:
                      type: array
                      description: Sales channel IDs the rules apply to. Empty/omitted means all channels.
                      items:
                        type: integer
                        minimum: 1
                    default_category_id:
                      type: integer
                      minimum: 1
                      nullable: true
                      description: Product category assigned to a created SKU when a matching rule names no category.
                    default_user_id:
                      type: integer
                      minimum: 0
                      nullable: true
                      description: User recorded as the creator of auto-created SKUs.
                    rules:
                      type: array
                      description: Ordered rules. The first rule whose conditions all match a line item decides the created SKU's category.
                      items:
                        type: object
                        required:
                          - conditions
                        properties:
                          name:
                            type: string
                            maxLength: 255
                            nullable: true
                            description: Optional label for the rule.
                          product_category_id:
                            type: integer
                            minimum: 1
                            nullable: true
                            description: Category assigned to SKUs created by this rule; falls back to `default_category_id`.
                          conditions:
                            type: array
                            minItems: 1
                            description: All conditions must match for the rule to apply.
                            items:
                              type: object
                              required:
                                - operator
                                - value
                              properties:
                                field:
                                  type: string
                                  enum:
                                    - sku
                                    - product_name
                                  description: Which line-item field the condition tests. Defaults to `sku`.
                                operator:
                                  type: string
                                  enum:
                                    - equals
                                    - starts_with
                                    - ends_with
                                    - contains
                                    - not_contains
                                    - regex
                                    - length_equals
                                    - length_min
                                    - length_max
                                  description: Comparison operator.
                                value:
                                  description: 'Value to compare against (string for text operators, integer for the `length_*` operators; a valid PHP regex for `regex`).'
      responses:
        '200':
          description: Merged settings after update
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Purgatory automation settings. All fields are optional in write payloads —
                      only keys present in the body are updated. See `GET /purgatory/settings/schema`
                      for field-level types, defaults, and descriptions.
                    properties:
                      post_empty_orders:
                        type: boolean
                        description: Auto-post sales orders that have no line items.
                      post_orders_ignored_all_items:
                        type: boolean
                        description: Auto-post orders whose every line item is ignored.
                      post_clean_orders:
                        type: boolean
                        description: |
                          Auto-post orders whose remaining non-ignored lines are all mapped to a
                          product. **Affects inventory** — orders posted this way decrement stock.
                      ignore_empty_sku:
                        type: boolean
                        description: Treat line items with an empty SKU as ignored.
                      ignore_adjustment_line_item:
                        type: boolean
                        description: 'Treat adjustment lines (coupons, negative qty, etc.) as ignored.'
                      skip_inventory_for_old_shipments:
                        type: boolean
                        description: Do not deduct inventory for shipments older than the threshold.
                      skip_inventory_for_old_shipments_days:
                        type: integer
                        minimum: 0
                        description: Age in days at which a shipment is considered "old" for the skip rule.
                      skip_inventory_for_similar_orders:
                        type: boolean
                        description: Skip inventory for shipments that look like duplicates of recently-posted orders.
                      similarity_threshold:
                        type: number
                        format: float
                        minimum: 0
                        maximum: 1
                        nullable: true
                        description: |
                          Score (0–1) above which two orders are considered duplicates.
                          Required when `skip_inventory_for_similar_orders` is `true`.
                      skip_orders_older_than_date_cutoff:
                        type: string
                        format: date-time
                        nullable: true
                        description: |
                          Orders with `order_date` before this ISO 8601 datetime are skipped by
                          purgatory automation. `null` disables the cutoff.
                      skip_orders_older_than_date_cutoff_by_account:
                        type: array
                        description: |
                          Per-app-integration-account `order_date` cutoffs. A matching account row
                          overrides the global `skip_orders_older_than_date_cutoff` for that account;
                          accounts without a row fall back to the global cutoff.
                        items:
                          type: object
                          required:
                            - app_integration_account_id
                            - cutoff
                          properties:
                            app_integration_account_id:
                              type: integer
                              minimum: 1
                              description: ID of the app integration account this cutoff applies to.
                            cutoff:
                              type: string
                              format: date-time
                              description: ISO 8601 datetime; orders with `order_date` strictly before this are dropped for this account.
                      ignored_skus:
                        type: array
                        items:
                          type: string
                        description: 'SKUs to always treat as ignored (exact match, case-insensitive).'
                      ignored_product_names:
                        type: array
                        items:
                          type: string
                        description: 'Product names to always treat as ignored (exact match, case-insensitive).'
                      ignored_patterns:
                        type: array
                        items:
                          type: string
                        description: |
                          Substrings or PHP regex patterns (wrap regex in slashes, e.g. `/^test/`)
                          matched against the line item SKU or name.
                      push_client_invoice_to_shipstation:
                        type: boolean
                        description: Push generated client invoices back to ShipStation as posted orders.
                      push_client_invoice_shipstation_store_id:
                        type: integer
                        nullable: true
                        description: ShipStation store ID that receives pushed client invoices.
                      push_client_invoice_to_shipstation_automatically:
                        type: boolean
                        description: Push client invoices automatically rather than waiting for a manual trigger.
                      push_client_invoice_to_shipstation_timing:
                        type: string
                        nullable: true
                        description: 'When the automatic push fires (e.g. `on_invoice_create`, `on_invoice_send`).'
                      auto_create_skus:
                        type: object
                        description: |
                          Rules that auto-create a product (SKU) for unmapped purgatory line items
                          instead of leaving them unmapped (CS-10171). On a partial update, a
                          partial `auto_create_skus` object updates only the keys it names.
                        properties:
                          enabled:
                            type: boolean
                            description: Whether auto-create-SKU rules run.
                          channel_ids:
                            type: array
                            description: Sales channel IDs the rules apply to. Empty/omitted means all channels.
                            items:
                              type: integer
                              minimum: 1
                          default_category_id:
                            type: integer
                            minimum: 1
                            nullable: true
                            description: Product category assigned to a created SKU when a matching rule names no category.
                          default_user_id:
                            type: integer
                            minimum: 0
                            nullable: true
                            description: User recorded as the creator of auto-created SKUs.
                          rules:
                            type: array
                            description: Ordered rules. The first rule whose conditions all match a line item decides the created SKU's category.
                            items:
                              type: object
                              required:
                                - conditions
                              properties:
                                name:
                                  type: string
                                  maxLength: 255
                                  nullable: true
                                  description: Optional label for the rule.
                                product_category_id:
                                  type: integer
                                  minimum: 1
                                  nullable: true
                                  description: Category assigned to SKUs created by this rule; falls back to `default_category_id`.
                                conditions:
                                  type: array
                                  minItems: 1
                                  description: All conditions must match for the rule to apply.
                                  items:
                                    type: object
                                    required:
                                      - operator
                                      - value
                                    properties:
                                      field:
                                        type: string
                                        enum:
                                          - sku
                                          - product_name
                                        description: Which line-item field the condition tests. Defaults to `sku`.
                                      operator:
                                        type: string
                                        enum:
                                          - equals
                                          - starts_with
                                          - ends_with
                                          - contains
                                          - not_contains
                                          - regex
                                          - length_equals
                                          - length_min
                                          - length_max
                                        description: Comparison operator.
                                      value:
                                        description: 'Value to compare against (string for text operators, integer for the `length_*` operators; a valid PHP regex for `regex`).'
                  schema_url:
                    type: string
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (unknown field or type mismatch)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /activity-logs/ask-ai:
    post:
      operationId: askAIAboutActivityLog
      tags:
        - Activity Logs
      summary: Ask an AI about a record's history
      description: |
        Sends the complete (unpaginated) activity history for a sales order,
        fulfillment order, shipment, product, or
        supplier purchase order to an LLM along with a free-text question,
        and returns the model's answer.

        Useful for summarising what has happened to a record, diagnosing why an
        order behaved a certain way, or generating narrative explanations from
        raw audit-trail entries without having to paginate and parse them yourself.

        The endpoint loads the full history server-side, so it does not respect
        the `page` / `limit` filters of the list endpoint — every entry for the
        subject is included in the prompt.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - subjectType
                - subjectId
                - question
              properties:
                subjectType:
                  type: string
                  enum:
                    - sales_order
                    - fulfillment_order
                    - shipment
                    - product
                    - supplier_purchase_order
                  description: Type of subject record
                subjectId:
                  type: integer
                  minimum: 1
                  description: ID of the subject record
                question:
                  type: string
                  maxLength: 1000
                  description: Free-text question to ask about the record's history
            example:
              subjectType: sales_order
              subjectId: 12345
              question: Why did this order spend two days in purgatory before posting?
      responses:
        '200':
          description: AI-generated answer
          content:
            application/json:
              schema:
                type: object
                properties:
                  answer:
                    type: string
                    description: Natural-language answer derived from the record's activity log
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /activity-logs:
    get:
      operationId: getActivityLogs
      tags:
        - Activity Logs
      summary: List activity log entries for a subject
      description: |
        Returns paginated activity-log entries for a single subject record — a
        sales order, fulfillment order, shipment, product, or
        supplier purchase order. Each entry captures a change
        (status update, field edit, system action, etc.) along with the actor that
        caused it.

        `subjectType` and `subjectId` are required and together identify the
        record whose history you want. Sort defaults to newest-first
        (`created_at desc`); override with `sortField` / `sortDirection` or the
        shortcut `dateSort`.

        Use `userType=user` to see only human-initiated entries, or
        `userType=system` for automated changes. Use `includeLogName` to scope
        to a single log channel (e.g. `automation`), or `excludeLogNames[]` to
        hide noisy channels — `excludeLogNames` is ignored when `includeLogName`
        is set.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: subjectType
          required: true
          schema:
            type: string
            enum:
              - sales_order
              - fulfillment_order
              - shipment
              - product
              - supplier_purchase_order
          description: |
            Type of subject record whose history is being requested. `product` returns the
            product's change history: `created`, `updated` (catalogue edits such as name, SKU,
            UPC, category, type, sellable/discontinued, lot tracking, taxable, preferred vendor,
            reorder level), and `deleted` (soft-delete) events, each carrying the source in
            `properties.via` (`user`, `api`, `import`, `auto_create_sku`, `job`, or `system`).
            Inventory and cost changes are not logged. `supplier_purchase_order` takes the
            purchase order's numeric ID as `subjectId`.
        - in: query
          name: subjectId
          required: true
          schema:
            type: integer
            minimum: 1
          description: ID of the subject record
        - in: query
          name: userType
          schema:
            type: string
            enum:
              - user
              - system
            nullable: true
          description: Filter by actor kind — `user` (human-initiated) or `system` (automated)
        - in: query
          name: dateSort
          schema:
            type: string
            enum:
              - asc
              - desc
            nullable: true
          description: 'Shortcut to override sort direction on `created_at`. When set, takes precedence over `sortField` / `sortDirection`.'
        - in: query
          name: includeLogName
          schema:
            type: string
            nullable: true
          description: Return only entries with this `log_name` (e.g. `automation`)
        - in: query
          name: excludeLogNames
          schema:
            type: array
            items:
              type: string
            nullable: true
          description: Exclude entries whose `log_name` is in this list. Ignored when `includeLogName` is set.
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Page number
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
          description: Results per page (max 100)
        - in: query
          name: sortField
          schema:
            type: string
            default: created_at
            nullable: true
          description: Field to sort by (default `created_at`; overridden when `dateSort` is provided)
        - in: query
          name: sortDirection
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
            nullable: true
          description: Sort direction
      responses:
        '200':
          description: Paginated list of activity-log entries
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A single activity-log entry recording a change to a sales order, fulfillment
                        order, or shipment. Mirrors the Spatie ActivityLog record shape with PII
                        redaction applied to free-text fields.
                      properties:
                        id:
                          type: integer
                          description: Activity log entry ID
                        logName:
                          type: string
                          nullable: true
                          description: |
                            Logical grouping for the entry (e.g. `automation`, `default`). Use
                            `includeLogName` / `excludeLogNames` query params to filter on this.
                        description:
                          type: string
                          description: Human-readable description of the change (PII-redacted)
                        subjectId:
                          type: integer
                          description: 'ID of the subject record (sales order, fulfillment order, shipment, product, or purchase order)'
                        subjectType:
                          type: string
                          description: |
                            Fully-qualified model class of the subject (e.g.
                            `App\Models\Inventory\SalesOrder`). For filtering, use the short form
                            (`sales_order`, `fulfillment_order`, `shipment`, `product`,
                            `supplier_purchase_order`) on the request. Purchase order entries return
                            `App\Models\MTPurchaseOrder`.
                        causerId:
                          type: integer
                          nullable: true
                          description: ID of the user/system actor that caused the entry; null when system-initiated without an attributable actor
                        causerType:
                          type: string
                          nullable: true
                          description: Fully-qualified model class of the causer (e.g. user / admin model)
                        createdAt:
                          type: string
                          format: date-time
                        updatedAt:
                          type: string
                          format: date-time
                        properties:
                          type: object
                          description: |
                            Decoded structured payload attached to the entry — typically `attributes`
                            (new values) and `old` (previous values) for update entries. Shape varies
                            by entry type. PII fields are redacted.
                          additionalProperties: true
                        propertiesJson:
                          type: string
                          description: |
                            Pretty-printed JSON string of `properties`. Returned alongside the
                            decoded object for clients that prefer to render the raw payload.
                        causer:
                          type: object
                          nullable: true
                          description: |
                            Embedded causer (admin user) record. Only present when the relation is
                            eager-loaded by the server.
                          additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (invalid `subjectType`, missing `subjectId`, etc.) or service-level error'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /invoices:
    post:
      operationId: createInvoice
      tags:
        - Invoices
      summary: Create invoice
      description: |
        Create a new invoice (client purchase order). At least one line item is required.
        Each item must supply either `product_id` or `sku`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - company_id
                - order_date
                - payment_terms
                - items
              properties:
                company_id:
                  type: integer
                  description: ID of the company (customer) this invoice is for
                status:
                  type: string
                  nullable: true
                  enum:
                    - DRAFT
                    - ESTIMATE
                    - ACTIVE
                  description: 'Status to create the invoice with. Defaults to `ACTIVE` when omitted, which creates the invoice and its sales order immediately (the historical behavior). `DRAFT` and `ESTIMATE` create the invoice without a sales order — the sales order is generated later when the invoice is activated. Case-insensitive; invalid values return a 422.'
                order_date:
                  type: string
                  format: date
                  description: Invoice date (YYYY-MM-DD)
                payment_terms:
                  type: string
                  description: Payment terms label (e.g. "Net 30")
                ship_by_date:
                  type: string
                  format: date
                  nullable: true
                  description: Required ship by date (YYYY-MM-DD)
                customer_po_number:
                  type: string
                  nullable: true
                  description: Customer PO number
                public_note:
                  type: string
                  nullable: true
                  description: Note visible to the customer
                private_note:
                  type: string
                  nullable: true
                  description: Internal note
                total_shipping:
                  type: number
                  format: float
                  nullable: true
                  description: Shipping charge to apply to the invoice
                tax_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Tax amount
                order_discount_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Order-level discount amount
                warehouse_id:
                  type: integer
                  nullable: true
                  description: Warehouse ID to associate with the invoice
                sales_channel_id:
                  type: integer
                  nullable: true
                  description: Sales channel ID
                revenue_account_id:
                  type: integer
                  nullable: true
                  description: Chart of accounts ID for revenue recognition
                invoice_export_template_id:
                  type: integer
                  nullable: true
                  description: Export template ID
                alternate_ids:
                  type: array
                  nullable: true
                  description: Alternate identifier strings for the invoice
                  items:
                    type: string
                tags:
                  type: array
                  nullable: true
                  description: Tags to attach to the invoice
                  items:
                    type: string
                custom_fields:
                  type: object
                  nullable: true
                  description: Custom field key/value pairs
                ship_to:
                  type: object
                  nullable: true
                  description: Shipping address
                  properties:
                    address_1:
                      type: string
                      nullable: true
                    address_2:
                      type: string
                      nullable: true
                    city:
                      type: string
                      nullable: true
                    state:
                      type: string
                      nullable: true
                    zip:
                      type: string
                      nullable: true
                    country:
                      type: string
                      nullable: true
                items:
                  type: array
                  minItems: 1
                  description: Line items for the invoice
                  items:
                    type: object
                    required:
                      - quantity
                      - unit_price
                    properties:
                      product_id:
                        type: integer
                        nullable: true
                        description: Product ID — required if `sku` is not provided
                      sku:
                        type: string
                        nullable: true
                        description: Product SKU — required if `product_id` is not provided
                      quantity:
                        type: number
                        format: float
                        description: Line item quantity
                      unit_price:
                        type: number
                        format: float
                        description: Unit price
                      description:
                        type: string
                        nullable: true
                        description: Line item description
      responses:
        '201':
          description: Invoice created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the invoice
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was last updated
                      status:
                        type: string
                        description: Current status of the invoice
                      payment_status:
                        type: string
                        description: Payment status of the invoice
                      order_date:
                        type: string
                        format: date-time
                        description: Date when the invoice was created
                      ship_by_date:
                        type: string
                        format: date-time
                        description: Required ship by date
                      approval_status:
                        type: string
                        description: Approval status of the invoice
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      payment_terms:
                        type: string
                        nullable: true
                        description: Payment terms for the invoice
                      public_note:
                        type: string
                        nullable: true
                        description: Public note visible to customer
                      private_note:
                        type: string
                        nullable: true
                        description: Private internal note
                      total_qty:
                        type: number
                        format: float
                        description: Total quantity of items
                      total_shipping:
                        type: number
                        format: float
                        description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_discount:
                        type: number
                        format: float
                        description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total:
                        type: number
                        format: float
                        description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                      total_paid:
                        type: number
                        format: float
                        description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_due:
                        type: number
                        format: float
                        description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Associated warehouse ID
                      ship_to:
                        type: object
                        properties:
                          address_1:
                            type: string
                            nullable: true
                          address_2:
                            type: string
                            nullable: true
                          city:
                            type: string
                            nullable: true
                          state:
                            type: string
                            nullable: true
                          zip:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                        description: Shipping address details
                      quickbooks_invoice_id:
                        type: string
                        nullable: true
                        description: QuickBooks invoice ID
                      quickbooks_message:
                        type: string
                        description: Message from QuickBooks integration
                      customer:
                        description: Customer information
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the customer
                          name:
                            type: string
                            description: Business name
                          address_1:
                            type: string
                            nullable: true
                            description: Primary address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address
                          city:
                            type: string
                            nullable: true
                            description: City
                          state:
                            type: string
                            nullable: true
                            description: State/Province
                          zip:
                            type: string
                            nullable: true
                            description: Postal code
                          country:
                            type: string
                            nullable: true
                            description: Country
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                          email:
                            type: string
                            nullable: true
                            description: Email address
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was last updated
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                            sku:
                              type: string
                              description: Product SKU
                            name:
                              type: string
                              description: Product name
                            product_id:
                              type: integer
                              description: Product identifier
                            qty:
                              type: number
                              format: float
                              description: Quantity ordered
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            discount:
                              type: number
                              format: float
                              nullable: true
                              description: Discount amount
                            total:
                              type: number
                              format: float
                              description: Total line item amount
                            taxable:
                              type: boolean
                              description: Whether the line item is subject to sales tax. Defaults to true when not set.
                        description: Line items in the invoice
                      payments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            invoice_id:
                              type: integer
                              description: Associated invoice ID
                            gateway:
                              type: string
                              description: Payment gateway used
                            type:
                              type: string
                              description: Payment type
                            charge_type:
                              type: string
                              description: Type of charge
                            amount:
                              type: number
                              format: float
                              description: Payment amount
                            date:
                              type: string
                              format: date-time
                              description: Payment date
                            status:
                              type: string
                              description: Payment status
                            external_id:
                              type: string
                              nullable: true
                              description: External payment identifier
                            notes:
                              type: string
                              nullable: true
                              description: Payment notes
                            reference_id:
                              type: string
                              nullable: true
                              description: Reference identifier
                            gateway_response:
                              type: object
                              properties:
                                status:
                                  type: string
                                  description: Gateway response status
                                code:
                                  type: string
                                  description: Response code
                                message:
                                  type: string
                                  description: Response message
                                metadata:
                                  type: string
                                  description: Additional metadata
                              description: Payment gateway response details
                            created_by:
                              type: integer
                              nullable: true
                              description: User who created the payment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was last updated
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Soft delete timestamp
                        description: Payment records for the invoice
                      sales_order:
                        type: object
                        nullable: true
                        description: Sales order associated with the invoice (if any)
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the sales order
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was last updated
                          status:
                            type: string
                            description: Current status of the order
                          order_id:
                            type: string
                            description: External order identifier
                          order_number:
                            type: string
                            description: Order number
                          order_date:
                            type: string
                            format: date
                            description: Date when the order was placed
                          payment_date:
                            type: string
                            format: date
                            description: Date when payment was received
                          ship_by_date:
                            type: string
                            format: date
                            description: Required ship by date
                          age:
                            type: integer
                            description: Age of the order in days
                          order_status:
                            type: string
                            description: Status of the order
                          customer_id:
                            type: string
                            description: Customer identifier
                          customer_username:
                            type: string
                            description: Customer's username
                          customer_email:
                            type: string
                            description: Customer's email address
                          bill_to:
                            type: object
                            description: Billing information
                          ship_to:
                            type: object
                            description: Shipping information
                          requested_shipping_service:
                            type: string
                            nullable: true
                            description: What shipping service to use when shipping this order
                          total:
                            type: number
                            format: float
                            description: Total order amount
                          total_paid:
                            type: number
                            format: float
                            description: Amount paid
                          total_tax:
                            type: number
                            format: float
                            description: Total tax amount
                          total_shipping:
                            type: number
                            format: float
                            description: Total shipping amount
                          customer_notes:
                            type: string
                            description: Notes from the customer
                          internal_notes:
                            type: string
                            description: Internal notes
                          ship_date:
                            type: string
                            format: date
                            description: Date when order was shipped
                          hold_until_date:
                            type: string
                            format: date
                            description: Hold until date
                          user_id:
                            type: integer
                            description: User ID associated with the order
                          externally_fulfilled:
                            type: boolean
                            description: Whether the order is fulfilled externally
                          externally_fulfilled_by:
                            type: string
                            description: Entity fulfilling the order externally
                          is_posted:
                            type: boolean
                            description: Whether the order is posted
                          posted_by:
                            type: string
                            description: User who posted the order
                          not_sync:
                            type: boolean
                            description: Sync status
                          sales_posted:
                            type: boolean
                            description: Sales posting status
                          split_order:
                            type: boolean
                            description: Whether the order is split
                          skip_inventory:
                            type: boolean
                            description: Whether to skip inventory
                          skip_sales_report:
                            type: boolean
                            description: Whether to skip sales report
                          channel_id:
                            type: integer
                            description: Channel identifier
                          total_order_cost:
                            type: number
                            format: float
                            description: Total cost of order
                          total_order_quantity:
                            type: number
                            format: float
                            description: Total quantity of items
                          order_cost_details:
                            type: object
                            description: Detailed order cost information
                          source:
                            type: string
                            description: Order source
                          shipstation_order_id:
                            type: string
                            description: ShipStation order identifier
                          type:
                            type: string
                            description: Order type
                          parent_id:
                            type: integer
                            description: Parent order ID if applicable
                          shipping_revenue:
                            type: number
                            format: float
                            description: Revenue from shipping
                          product_total:
                            type: number
                            format: float
                            description: Total product amount
                          total_discount:
                            type: number
                            format: float
                            description: Total discount amount
                          picking_status:
                            type: string
                            description: Status of picking process
                          starred_description:
                            type: string
                            description: Description for starred orders
                          customer_po_number:
                            type: string
                            description: Customer PO number
                      custom_fields:
                        type: object
                        description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Field Name 1: Some Value
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                        description: Tags associated with the invoice
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    get:
      operationId: getInvoices
      tags:
        - Invoices
      summary: Invoices
      description: |
        Get a paginated list of invoices with optional filtering.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### Integer Filters
        - `company_id` (alias `customer_id`): Company (customer) ID
        - `sales_channel_id`: Sales channel ID

        ### String Filters
        - `status`: Invoice status
        - `sales_order.order_number`: Sales order number (if sales order attached)
        - `payment_status`: Payment status
        - `approval_status`: Approval status
        - `customer_po_number`: Customer PO number
        - `tag`: Invoice tags

        ### Date Filters
        - `order_date`: Date the invoice was created
        - `ship_by_date`: Required ship by date
        - `due_date`: Date payment is due

        ### DateTime Filters
        - `created_at`: When the invoice was created
        - `updated_at`: When the invoice was last updated

        ### Numeric Filters
        - `total_qty`: Total quantity of items
        - `total`: Invoice total amount
        - `total_shipping`: Shipping cost
        - `total_discount`: Discount amount
        - `total_paid`: Amount paid
        - `total_due`: Amount still due

        ### Custom Field Filters
        - `custom_fields.{fieldName}`: Filter by a custom field assigned to the Invoices record type (fields assigned only to other record types are not accepted)

        ## Examples
        ```
        # Find unpaid invoices over $500
        ?total[gt]=500.00&total_due[gt]=0

        # Find invoices by a specific tag
        ?tag[eq]=Urgent

        # Find completed invoices from last month
        ?status[eq]=completed&created_at[gte]=2024-11-01 00:00:00

        # Find invoices with specific PO numbers
        ?customer_po_number[contains]=INV-123

        # Find invoices by custom fields
        ?custom_fields.My Custom Field[eq]=Some value

        # Find invoices where a specific custom field is empty
        ?custom_fields.My Custom Field[notset]
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: fields
          schema:
            type: string
          description: 'Comma-separated list of fields to include in each returned invoice (field projection). When omitted, the full invoice object is returned. Example: `fields=id,status,total`.'
        - in: query
          name: company_id
          schema:
            type: integer
          description: Filter by the ID of the company (customer) the invoice belongs to
        - in: query
          name: customer_id
          schema:
            type: integer
          description: Alias for `company_id` — filter by the ID of the company (customer) the invoice belongs to
        - in: query
          name: sales_channel_id
          schema:
            type: integer
          description: Filter by the sales channel ID associated with the invoice
        - in: query
          name: status
          schema:
            type: string
          description: Filter by invoice status
        - in: query
          name: sales_order.order_number
          schema:
            type: string
          description: Filter by sales order number (if sales order is attached to invoice)
        - in: query
          name: payment_status
          schema:
            type: string
          description: Filter by payment status
        - in: query
          name: approval_status
          schema:
            type: string
          description: Filter by approval status
        - in: query
          name: customer_po_number
          schema:
            type: string
          description: Filter by customer PO number
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by tag name
        - in: query
          name: order_date
          schema:
            type: string
            format: date
          description: Filter by order date (YYYY-MM-DD)
        - in: query
          name: ship_by_date
          schema:
            type: string
            format: date
          description: Filter by ship by date (YYYY-MM-DD)
        - in: query
          name: due_date
          schema:
            type: string
            format: date
          description: Filter by due date (YYYY-MM-DD)
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: total_qty
          schema:
            type: number
          description: Filter by total quantity
        - in: query
          name: total
          schema:
            type: number
          description: Filter by invoice total amount
        - in: query
          name: total_shipping
          schema:
            type: number
          description: Filter by shipping amount
        - in: query
          name: total_discount
          schema:
            type: number
          description: Filter by discount amount
        - in: query
          name: total_paid
          schema:
            type: number
          description: Filter by amount paid
        - in: query
          name: total_due
          schema:
            type: number
          description: Filter by amount due
        - in: query
          name: custom_fields
          schema:
            type: object
          description: Filter by custom fields
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the invoice
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the invoice was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the invoice was last updated
                        status:
                          type: string
                          description: Current status of the invoice
                        payment_status:
                          type: string
                          description: Payment status of the invoice
                        order_date:
                          type: string
                          format: date-time
                          description: Date when the invoice was created
                        ship_by_date:
                          type: string
                          format: date-time
                          description: Required ship by date
                        approval_status:
                          type: string
                          description: Approval status of the invoice
                        customer_po_number:
                          type: string
                          description: Customer PO number
                        payment_terms:
                          type: string
                          nullable: true
                          description: Payment terms for the invoice
                        public_note:
                          type: string
                          nullable: true
                          description: Public note visible to customer
                        private_note:
                          type: string
                          nullable: true
                          description: Private internal note
                        total_qty:
                          type: number
                          format: float
                          description: Total quantity of items
                        total_shipping:
                          type: number
                          format: float
                          description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total_discount:
                          type: number
                          format: float
                          description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total:
                          type: number
                          format: float
                          description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                        total_paid:
                          type: number
                          format: float
                          description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total_due:
                          type: number
                          format: float
                          description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: Associated warehouse ID
                        ship_to:
                          type: object
                          properties:
                            address_1:
                              type: string
                              nullable: true
                            address_2:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                            state:
                              type: string
                              nullable: true
                            zip:
                              type: string
                              nullable: true
                            country:
                              type: string
                              nullable: true
                          description: Shipping address details
                        quickbooks_invoice_id:
                          type: string
                          nullable: true
                          description: QuickBooks invoice ID
                        quickbooks_message:
                          type: string
                          description: Message from QuickBooks integration
                        customer:
                          description: Customer information
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the customer
                            name:
                              type: string
                              description: Business name
                            address_1:
                              type: string
                              nullable: true
                              description: Primary address
                            address_2:
                              type: string
                              nullable: true
                              description: Secondary address
                            city:
                              type: string
                              nullable: true
                              description: City
                            state:
                              type: string
                              nullable: true
                              description: State/Province
                            zip:
                              type: string
                              nullable: true
                              description: Postal code
                            country:
                              type: string
                              nullable: true
                              description: Country
                            phone:
                              type: string
                              nullable: true
                              description: Phone number
                            email:
                              type: string
                              nullable: true
                              description: Email address
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when customer was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when customer was last updated
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the line item
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was last updated
                              sku:
                                type: string
                                description: Product SKU
                              name:
                                type: string
                                description: Product name
                              product_id:
                                type: integer
                                description: Product identifier
                              qty:
                                type: number
                                format: float
                                description: Quantity ordered
                              unit_price:
                                type: number
                                format: float
                                description: Price per unit
                              discount:
                                type: number
                                format: float
                                nullable: true
                                description: Discount amount
                              total:
                                type: number
                                format: float
                                description: Total line item amount
                              taxable:
                                type: boolean
                                description: Whether the line item is subject to sales tax. Defaults to true when not set.
                          description: Line items in the invoice
                        payments:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the payment
                              invoice_id:
                                type: integer
                                description: Associated invoice ID
                              gateway:
                                type: string
                                description: Payment gateway used
                              type:
                                type: string
                                description: Payment type
                              charge_type:
                                type: string
                                description: Type of charge
                              amount:
                                type: number
                                format: float
                                description: Payment amount
                              date:
                                type: string
                                format: date-time
                                description: Payment date
                              status:
                                type: string
                                description: Payment status
                              external_id:
                                type: string
                                nullable: true
                                description: External payment identifier
                              notes:
                                type: string
                                nullable: true
                                description: Payment notes
                              reference_id:
                                type: string
                                nullable: true
                                description: Reference identifier
                              gateway_response:
                                type: object
                                properties:
                                  status:
                                    type: string
                                    description: Gateway response status
                                  code:
                                    type: string
                                    description: Response code
                                  message:
                                    type: string
                                    description: Response message
                                  metadata:
                                    type: string
                                    description: Additional metadata
                                description: Payment gateway response details
                              created_by:
                                type: integer
                                nullable: true
                                description: User who created the payment
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when payment was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when payment was last updated
                              deleted_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: Soft delete timestamp
                          description: Payment records for the invoice
                        sales_order:
                          type: object
                          nullable: true
                          description: Sales order associated with the invoice (if any)
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the sales order
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the order was last updated
                            status:
                              type: string
                              description: Current status of the order
                            order_id:
                              type: string
                              description: External order identifier
                            order_number:
                              type: string
                              description: Order number
                            order_date:
                              type: string
                              format: date
                              description: Date when the order was placed
                            payment_date:
                              type: string
                              format: date
                              description: Date when payment was received
                            ship_by_date:
                              type: string
                              format: date
                              description: Required ship by date
                            age:
                              type: integer
                              description: Age of the order in days
                            order_status:
                              type: string
                              description: Status of the order
                            customer_id:
                              type: string
                              description: Customer identifier
                            customer_username:
                              type: string
                              description: Customer's username
                            customer_email:
                              type: string
                              description: Customer's email address
                            bill_to:
                              type: object
                              description: Billing information
                            ship_to:
                              type: object
                              description: Shipping information
                            requested_shipping_service:
                              type: string
                              nullable: true
                              description: What shipping service to use when shipping this order
                            total:
                              type: number
                              format: float
                              description: Total order amount
                            total_paid:
                              type: number
                              format: float
                              description: Amount paid
                            total_tax:
                              type: number
                              format: float
                              description: Total tax amount
                            total_shipping:
                              type: number
                              format: float
                              description: Total shipping amount
                            customer_notes:
                              type: string
                              description: Notes from the customer
                            internal_notes:
                              type: string
                              description: Internal notes
                            ship_date:
                              type: string
                              format: date
                              description: Date when order was shipped
                            hold_until_date:
                              type: string
                              format: date
                              description: Hold until date
                            user_id:
                              type: integer
                              description: User ID associated with the order
                            externally_fulfilled:
                              type: boolean
                              description: Whether the order is fulfilled externally
                            externally_fulfilled_by:
                              type: string
                              description: Entity fulfilling the order externally
                            is_posted:
                              type: boolean
                              description: Whether the order is posted
                            posted_by:
                              type: string
                              description: User who posted the order
                            not_sync:
                              type: boolean
                              description: Sync status
                            sales_posted:
                              type: boolean
                              description: Sales posting status
                            split_order:
                              type: boolean
                              description: Whether the order is split
                            skip_inventory:
                              type: boolean
                              description: Whether to skip inventory
                            skip_sales_report:
                              type: boolean
                              description: Whether to skip sales report
                            channel_id:
                              type: integer
                              description: Channel identifier
                            total_order_cost:
                              type: number
                              format: float
                              description: Total cost of order
                            total_order_quantity:
                              type: number
                              format: float
                              description: Total quantity of items
                            order_cost_details:
                              type: object
                              description: Detailed order cost information
                            source:
                              type: string
                              description: Order source
                            shipstation_order_id:
                              type: string
                              description: ShipStation order identifier
                            type:
                              type: string
                              description: Order type
                            parent_id:
                              type: integer
                              description: Parent order ID if applicable
                            shipping_revenue:
                              type: number
                              format: float
                              description: Revenue from shipping
                            product_total:
                              type: number
                              format: float
                              description: Total product amount
                            total_discount:
                              type: number
                              format: float
                              description: Total discount amount
                            picking_status:
                              type: string
                              description: Status of picking process
                            starred_description:
                              type: string
                              description: Description for starred orders
                            customer_po_number:
                              type: string
                              description: Customer PO number
                        custom_fields:
                          type: object
                          description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          example:
                            Field Name 1: Some Value
                        tags:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the tag
                              name:
                                type: string
                                description: Name of the tag
                              description:
                                type: string
                                nullable: true
                                description: Description of the tag
                              icon:
                                type: string
                                nullable: true
                                description: Icon identifier or URL for the tag
                              color:
                                type: string
                                nullable: true
                                description: Color code for the tag
                            required:
                              - id
                              - name
                          description: Tags associated with the invoice
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /invoices/bulk-void-delete:
    post:
      operationId: bulkVoidDeleteInvoices
      tags:
        - Invoices
      summary: Bulk void or delete invoices
      description: |
        Void or delete up to 50 invoices in one call. Each invoice follows the same
        rules as the single-invoice endpoints (`POST /invoices/{invoiceId}/void` and
        `DELETE /invoices/{id}`). Invoices are handled one at a time, so one refusal or
        failure does not stop the rest.

        The response is `200` whenever the request itself is valid. Check each
        entry in `results` for its outcome. An ID that does not match an invoice is
        returned as `skipped` with the reason `Invoice not found.`.

        Requires the API token user to have the invoice update permission
        (`invoices.update`).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - action
                - ids
              properties:
                action:
                  type: string
                  enum:
                    - void
                    - delete
                  description: Whether to void or delete the listed invoices
                ids:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    type: integer
                    minimum: 1
                  description: IDs of the invoices to process (1 to 50). Duplicates are processed once.
                delete_sales_order:
                  type: boolean
                  default: false
                  description: |
                    `void` only. Also delete each invoice's linked sales order. Only a sales
                    order that Luminous created from the invoice is deleted.
              example:
                action: void
                ids:
                  - 101
                  - 102
                  - 103
                delete_sales_order: false
      responses:
        '200':
          description: 'Request processed; one result per invoice ID, in the order given'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      action:
                        type: string
                        enum:
                          - void
                          - delete
                      summary:
                        type: object
                        description: Count of invoices per result
                        properties:
                          voided:
                            type: integer
                          deleted:
                            type: integer
                          skipped:
                            type: integer
                          failed:
                            type: integer
                      results:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Invoice ID
                            result:
                              type: string
                              enum:
                                - voided
                                - deleted
                                - skipped
                                - failed
                            reason:
                              type: string
                              nullable: true
                              description: 'Why the invoice was skipped, or the error if it failed. `null` on success.'
              example:
                data:
                  action: void
                  summary:
                    voided: 2
                    deleted: 0
                    skipped: 1
                    failed: 0
                  results:
                    - id: 101
                      result: voided
                      reason: null
                    - id: 102
                      result: voided
                      reason: null
                    - id: 103
                      result: skipped
                      reason: Invoice is already void.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Token user lacks the invoice update permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (missing or invalid `action`, or `ids` empty or longer than 50)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/invoices/{id}':
    get:
      operationId: getInvoice
      tags:
        - Invoices
      summary: Single invoice
      description: Get details of a specific invoice by ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the invoice to retrieve
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the invoice
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was last updated
                      status:
                        type: string
                        description: Current status of the invoice
                      payment_status:
                        type: string
                        description: Payment status of the invoice
                      order_date:
                        type: string
                        format: date-time
                        description: Date when the invoice was created
                      ship_by_date:
                        type: string
                        format: date-time
                        description: Required ship by date
                      approval_status:
                        type: string
                        description: Approval status of the invoice
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      payment_terms:
                        type: string
                        nullable: true
                        description: Payment terms for the invoice
                      public_note:
                        type: string
                        nullable: true
                        description: Public note visible to customer
                      private_note:
                        type: string
                        nullable: true
                        description: Private internal note
                      total_qty:
                        type: number
                        format: float
                        description: Total quantity of items
                      total_shipping:
                        type: number
                        format: float
                        description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_discount:
                        type: number
                        format: float
                        description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total:
                        type: number
                        format: float
                        description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                      total_paid:
                        type: number
                        format: float
                        description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_due:
                        type: number
                        format: float
                        description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Associated warehouse ID
                      ship_to:
                        type: object
                        properties:
                          address_1:
                            type: string
                            nullable: true
                          address_2:
                            type: string
                            nullable: true
                          city:
                            type: string
                            nullable: true
                          state:
                            type: string
                            nullable: true
                          zip:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                        description: Shipping address details
                      quickbooks_invoice_id:
                        type: string
                        nullable: true
                        description: QuickBooks invoice ID
                      quickbooks_message:
                        type: string
                        description: Message from QuickBooks integration
                      customer:
                        description: Customer information
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the customer
                          name:
                            type: string
                            description: Business name
                          address_1:
                            type: string
                            nullable: true
                            description: Primary address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address
                          city:
                            type: string
                            nullable: true
                            description: City
                          state:
                            type: string
                            nullable: true
                            description: State/Province
                          zip:
                            type: string
                            nullable: true
                            description: Postal code
                          country:
                            type: string
                            nullable: true
                            description: Country
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                          email:
                            type: string
                            nullable: true
                            description: Email address
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was last updated
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                            sku:
                              type: string
                              description: Product SKU
                            name:
                              type: string
                              description: Product name
                            product_id:
                              type: integer
                              description: Product identifier
                            qty:
                              type: number
                              format: float
                              description: Quantity ordered
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            discount:
                              type: number
                              format: float
                              nullable: true
                              description: Discount amount
                            total:
                              type: number
                              format: float
                              description: Total line item amount
                            taxable:
                              type: boolean
                              description: Whether the line item is subject to sales tax. Defaults to true when not set.
                        description: Line items in the invoice
                      payments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            invoice_id:
                              type: integer
                              description: Associated invoice ID
                            gateway:
                              type: string
                              description: Payment gateway used
                            type:
                              type: string
                              description: Payment type
                            charge_type:
                              type: string
                              description: Type of charge
                            amount:
                              type: number
                              format: float
                              description: Payment amount
                            date:
                              type: string
                              format: date-time
                              description: Payment date
                            status:
                              type: string
                              description: Payment status
                            external_id:
                              type: string
                              nullable: true
                              description: External payment identifier
                            notes:
                              type: string
                              nullable: true
                              description: Payment notes
                            reference_id:
                              type: string
                              nullable: true
                              description: Reference identifier
                            gateway_response:
                              type: object
                              properties:
                                status:
                                  type: string
                                  description: Gateway response status
                                code:
                                  type: string
                                  description: Response code
                                message:
                                  type: string
                                  description: Response message
                                metadata:
                                  type: string
                                  description: Additional metadata
                              description: Payment gateway response details
                            created_by:
                              type: integer
                              nullable: true
                              description: User who created the payment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was last updated
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Soft delete timestamp
                        description: Payment records for the invoice
                      sales_order:
                        type: object
                        nullable: true
                        description: Sales order associated with the invoice (if any)
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the sales order
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was last updated
                          status:
                            type: string
                            description: Current status of the order
                          order_id:
                            type: string
                            description: External order identifier
                          order_number:
                            type: string
                            description: Order number
                          order_date:
                            type: string
                            format: date
                            description: Date when the order was placed
                          payment_date:
                            type: string
                            format: date
                            description: Date when payment was received
                          ship_by_date:
                            type: string
                            format: date
                            description: Required ship by date
                          age:
                            type: integer
                            description: Age of the order in days
                          order_status:
                            type: string
                            description: Status of the order
                          customer_id:
                            type: string
                            description: Customer identifier
                          customer_username:
                            type: string
                            description: Customer's username
                          customer_email:
                            type: string
                            description: Customer's email address
                          bill_to:
                            type: object
                            description: Billing information
                          ship_to:
                            type: object
                            description: Shipping information
                          requested_shipping_service:
                            type: string
                            nullable: true
                            description: What shipping service to use when shipping this order
                          total:
                            type: number
                            format: float
                            description: Total order amount
                          total_paid:
                            type: number
                            format: float
                            description: Amount paid
                          total_tax:
                            type: number
                            format: float
                            description: Total tax amount
                          total_shipping:
                            type: number
                            format: float
                            description: Total shipping amount
                          customer_notes:
                            type: string
                            description: Notes from the customer
                          internal_notes:
                            type: string
                            description: Internal notes
                          ship_date:
                            type: string
                            format: date
                            description: Date when order was shipped
                          hold_until_date:
                            type: string
                            format: date
                            description: Hold until date
                          user_id:
                            type: integer
                            description: User ID associated with the order
                          externally_fulfilled:
                            type: boolean
                            description: Whether the order is fulfilled externally
                          externally_fulfilled_by:
                            type: string
                            description: Entity fulfilling the order externally
                          is_posted:
                            type: boolean
                            description: Whether the order is posted
                          posted_by:
                            type: string
                            description: User who posted the order
                          not_sync:
                            type: boolean
                            description: Sync status
                          sales_posted:
                            type: boolean
                            description: Sales posting status
                          split_order:
                            type: boolean
                            description: Whether the order is split
                          skip_inventory:
                            type: boolean
                            description: Whether to skip inventory
                          skip_sales_report:
                            type: boolean
                            description: Whether to skip sales report
                          channel_id:
                            type: integer
                            description: Channel identifier
                          total_order_cost:
                            type: number
                            format: float
                            description: Total cost of order
                          total_order_quantity:
                            type: number
                            format: float
                            description: Total quantity of items
                          order_cost_details:
                            type: object
                            description: Detailed order cost information
                          source:
                            type: string
                            description: Order source
                          shipstation_order_id:
                            type: string
                            description: ShipStation order identifier
                          type:
                            type: string
                            description: Order type
                          parent_id:
                            type: integer
                            description: Parent order ID if applicable
                          shipping_revenue:
                            type: number
                            format: float
                            description: Revenue from shipping
                          product_total:
                            type: number
                            format: float
                            description: Total product amount
                          total_discount:
                            type: number
                            format: float
                            description: Total discount amount
                          picking_status:
                            type: string
                            description: Status of picking process
                          starred_description:
                            type: string
                            description: Description for starred orders
                          customer_po_number:
                            type: string
                            description: Customer PO number
                      custom_fields:
                        type: object
                        description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Field Name 1: Some Value
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                        description: Tags associated with the invoice
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    patch:
      operationId: updateInvoice
      tags:
        - Invoices
      summary: Update invoice
      description: |
        Partially update an existing invoice. Only the fields you supply are changed;
        any field you omit is left untouched.

        When `items` is provided it **replaces** the full set of line items, so include
        every line you want to keep. Each item must supply either `product_id` or `sku`.
        Monetary totals (`total_amount`, `total_units`, `net_total_amount`) are recomputed
        automatically when items or monetary fields change.

        The update is atomic: if any part of it fails to persist (for example, saving
        `alternate_ids`), the entire update is rolled back and the invoice and its
        installments are left unchanged.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the invoice to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                company_id:
                  type: integer
                  description: ID of the company (customer) this invoice is for
                order_date:
                  type: string
                  format: date
                  description: Invoice date (YYYY-MM-DD)
                payment_terms:
                  type: string
                  description: Payment terms label (e.g. "Net 30")
                ship_by_date:
                  type: string
                  format: date
                  nullable: true
                  description: Required ship by date (YYYY-MM-DD)
                customer_po_number:
                  type: string
                  nullable: true
                  description: Customer PO number
                public_note:
                  type: string
                  nullable: true
                  description: Note visible to the customer
                private_note:
                  type: string
                  nullable: true
                  description: Internal note
                total_shipping:
                  type: number
                  format: float
                  nullable: true
                  description: Shipping charge to apply to the invoice
                tax_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Tax amount
                order_discount_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Order-level discount amount
                warehouse_id:
                  type: integer
                  nullable: true
                  description: Warehouse ID to associate with the invoice
                sales_channel_id:
                  type: integer
                  nullable: true
                  description: Sales channel ID
                revenue_account_id:
                  type: integer
                  nullable: true
                  description: Chart of accounts ID for revenue recognition
                invoice_export_template_id:
                  type: integer
                  nullable: true
                  description: Export template ID
                alternate_ids:
                  type: array
                  nullable: true
                  description: Alternate identifier strings for the invoice
                  items:
                    type: string
                tags:
                  type: array
                  nullable: true
                  description: Tags to attach to the invoice
                  items:
                    type: string
                custom_fields:
                  type: object
                  nullable: true
                  description: Custom field key/value pairs
                ship_to:
                  type: object
                  nullable: true
                  description: Shipping address
                  properties:
                    address_1:
                      type: string
                      nullable: true
                    address_2:
                      type: string
                      nullable: true
                    city:
                      type: string
                      nullable: true
                    state:
                      type: string
                      nullable: true
                    zip:
                      type: string
                      nullable: true
                    country:
                      type: string
                      nullable: true
                currency_code:
                  type: string
                  nullable: true
                  description: ISO 4217 currency code (3 letters) for the invoice presentment currency
                exchange_rate:
                  type: number
                  format: float
                  nullable: true
                  description: Exchange rate from the presentment currency to the base currency (must be greater than 0)
                presentment_total_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Invoice total in the presentment currency
                presentment_net_total_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Net total in the presentment currency
                presentment_paid_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Amount paid in the presentment currency
                presentment_tax_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Tax amount in the presentment currency
                presentment_shipping_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Shipping amount in the presentment currency
                presentment_discount_amount:
                  type: number
                  format: float
                  nullable: true
                  description: Discount amount in the presentment currency
                items:
                  type: array
                  minItems: 1
                  description: 'Replacement line items for the invoice. When provided, this replaces all existing line items, so include every line you want to keep.'
                  items:
                    type: object
                    required:
                      - quantity
                      - unit_price
                    properties:
                      product_id:
                        type: integer
                        nullable: true
                        description: Product ID — required if `sku` is not provided
                      sku:
                        type: string
                        nullable: true
                        description: Product SKU — required if `product_id` is not provided
                      quantity:
                        type: number
                        format: float
                        description: Line item quantity
                      unit_price:
                        type: number
                        format: float
                        description: Unit price
                      description:
                        type: string
                        nullable: true
                        description: Line item description
                      presentment_unit_price:
                        type: number
                        format: float
                        nullable: true
                        description: Unit price in the presentment currency
      responses:
        '200':
          description: Invoice updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the invoice
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was last updated
                      status:
                        type: string
                        description: Current status of the invoice
                      payment_status:
                        type: string
                        description: Payment status of the invoice
                      order_date:
                        type: string
                        format: date-time
                        description: Date when the invoice was created
                      ship_by_date:
                        type: string
                        format: date-time
                        description: Required ship by date
                      approval_status:
                        type: string
                        description: Approval status of the invoice
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      payment_terms:
                        type: string
                        nullable: true
                        description: Payment terms for the invoice
                      public_note:
                        type: string
                        nullable: true
                        description: Public note visible to customer
                      private_note:
                        type: string
                        nullable: true
                        description: Private internal note
                      total_qty:
                        type: number
                        format: float
                        description: Total quantity of items
                      total_shipping:
                        type: number
                        format: float
                        description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_discount:
                        type: number
                        format: float
                        description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total:
                        type: number
                        format: float
                        description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                      total_paid:
                        type: number
                        format: float
                        description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_due:
                        type: number
                        format: float
                        description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Associated warehouse ID
                      ship_to:
                        type: object
                        properties:
                          address_1:
                            type: string
                            nullable: true
                          address_2:
                            type: string
                            nullable: true
                          city:
                            type: string
                            nullable: true
                          state:
                            type: string
                            nullable: true
                          zip:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                        description: Shipping address details
                      quickbooks_invoice_id:
                        type: string
                        nullable: true
                        description: QuickBooks invoice ID
                      quickbooks_message:
                        type: string
                        description: Message from QuickBooks integration
                      customer:
                        description: Customer information
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the customer
                          name:
                            type: string
                            description: Business name
                          address_1:
                            type: string
                            nullable: true
                            description: Primary address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address
                          city:
                            type: string
                            nullable: true
                            description: City
                          state:
                            type: string
                            nullable: true
                            description: State/Province
                          zip:
                            type: string
                            nullable: true
                            description: Postal code
                          country:
                            type: string
                            nullable: true
                            description: Country
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                          email:
                            type: string
                            nullable: true
                            description: Email address
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was last updated
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                            sku:
                              type: string
                              description: Product SKU
                            name:
                              type: string
                              description: Product name
                            product_id:
                              type: integer
                              description: Product identifier
                            qty:
                              type: number
                              format: float
                              description: Quantity ordered
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            discount:
                              type: number
                              format: float
                              nullable: true
                              description: Discount amount
                            total:
                              type: number
                              format: float
                              description: Total line item amount
                            taxable:
                              type: boolean
                              description: Whether the line item is subject to sales tax. Defaults to true when not set.
                        description: Line items in the invoice
                      payments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            invoice_id:
                              type: integer
                              description: Associated invoice ID
                            gateway:
                              type: string
                              description: Payment gateway used
                            type:
                              type: string
                              description: Payment type
                            charge_type:
                              type: string
                              description: Type of charge
                            amount:
                              type: number
                              format: float
                              description: Payment amount
                            date:
                              type: string
                              format: date-time
                              description: Payment date
                            status:
                              type: string
                              description: Payment status
                            external_id:
                              type: string
                              nullable: true
                              description: External payment identifier
                            notes:
                              type: string
                              nullable: true
                              description: Payment notes
                            reference_id:
                              type: string
                              nullable: true
                              description: Reference identifier
                            gateway_response:
                              type: object
                              properties:
                                status:
                                  type: string
                                  description: Gateway response status
                                code:
                                  type: string
                                  description: Response code
                                message:
                                  type: string
                                  description: Response message
                                metadata:
                                  type: string
                                  description: Additional metadata
                              description: Payment gateway response details
                            created_by:
                              type: integer
                              nullable: true
                              description: User who created the payment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was last updated
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Soft delete timestamp
                        description: Payment records for the invoice
                      sales_order:
                        type: object
                        nullable: true
                        description: Sales order associated with the invoice (if any)
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the sales order
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was last updated
                          status:
                            type: string
                            description: Current status of the order
                          order_id:
                            type: string
                            description: External order identifier
                          order_number:
                            type: string
                            description: Order number
                          order_date:
                            type: string
                            format: date
                            description: Date when the order was placed
                          payment_date:
                            type: string
                            format: date
                            description: Date when payment was received
                          ship_by_date:
                            type: string
                            format: date
                            description: Required ship by date
                          age:
                            type: integer
                            description: Age of the order in days
                          order_status:
                            type: string
                            description: Status of the order
                          customer_id:
                            type: string
                            description: Customer identifier
                          customer_username:
                            type: string
                            description: Customer's username
                          customer_email:
                            type: string
                            description: Customer's email address
                          bill_to:
                            type: object
                            description: Billing information
                          ship_to:
                            type: object
                            description: Shipping information
                          requested_shipping_service:
                            type: string
                            nullable: true
                            description: What shipping service to use when shipping this order
                          total:
                            type: number
                            format: float
                            description: Total order amount
                          total_paid:
                            type: number
                            format: float
                            description: Amount paid
                          total_tax:
                            type: number
                            format: float
                            description: Total tax amount
                          total_shipping:
                            type: number
                            format: float
                            description: Total shipping amount
                          customer_notes:
                            type: string
                            description: Notes from the customer
                          internal_notes:
                            type: string
                            description: Internal notes
                          ship_date:
                            type: string
                            format: date
                            description: Date when order was shipped
                          hold_until_date:
                            type: string
                            format: date
                            description: Hold until date
                          user_id:
                            type: integer
                            description: User ID associated with the order
                          externally_fulfilled:
                            type: boolean
                            description: Whether the order is fulfilled externally
                          externally_fulfilled_by:
                            type: string
                            description: Entity fulfilling the order externally
                          is_posted:
                            type: boolean
                            description: Whether the order is posted
                          posted_by:
                            type: string
                            description: User who posted the order
                          not_sync:
                            type: boolean
                            description: Sync status
                          sales_posted:
                            type: boolean
                            description: Sales posting status
                          split_order:
                            type: boolean
                            description: Whether the order is split
                          skip_inventory:
                            type: boolean
                            description: Whether to skip inventory
                          skip_sales_report:
                            type: boolean
                            description: Whether to skip sales report
                          channel_id:
                            type: integer
                            description: Channel identifier
                          total_order_cost:
                            type: number
                            format: float
                            description: Total cost of order
                          total_order_quantity:
                            type: number
                            format: float
                            description: Total quantity of items
                          order_cost_details:
                            type: object
                            description: Detailed order cost information
                          source:
                            type: string
                            description: Order source
                          shipstation_order_id:
                            type: string
                            description: ShipStation order identifier
                          type:
                            type: string
                            description: Order type
                          parent_id:
                            type: integer
                            description: Parent order ID if applicable
                          shipping_revenue:
                            type: number
                            format: float
                            description: Revenue from shipping
                          product_total:
                            type: number
                            format: float
                            description: Total product amount
                          total_discount:
                            type: number
                            format: float
                            description: Total discount amount
                          picking_status:
                            type: string
                            description: Status of picking process
                          starred_description:
                            type: string
                            description: Description for starred orders
                          customer_po_number:
                            type: string
                            description: Customer PO number
                      custom_fields:
                        type: object
                        description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Field Name 1: Some Value
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                        description: Tags associated with the invoice
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '500':
          description: |
            A write inside the update transaction failed (for example, saving
            `alternate_ids`). The update was rolled back, so the invoice is unchanged.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteInvoice
      tags:
        - Invoices
      summary: Delete invoice
      description: |
        Delete a `draft` or `estimate` invoice that has no sales order. An invoice
        with a sales order cannot be deleted; void it instead with
        `POST /invoices/{invoiceId}/void`.

        Where the applied-payment guard is on, an invoice with a card, check or other
        non-credit-memo payment applied is refused until that payment is reversed.
        Applied credit-memo payments are reversed as part of the delete.

        Requires the API token user to have the invoice update permission
        (`invoices.update`).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the invoice to delete
      responses:
        '200':
          description: Invoice deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Invoice deleted.
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: ID of the deleted invoice
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Token user lacks the invoice update permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            The invoice cannot be deleted: it has a sales order, its status is not
            `draft`/`estimate`, or a non-credit-memo payment is applied. `message`
            says which (for example `Only Draft or Estimate invoices can be deleted. Void it instead.`).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '500':
          description: The delete failed while reversing applied payments. Nothing was changed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/invoices/{invoiceId}/void':
    post:
      operationId: voidInvoice
      tags:
        - Invoices
      summary: Void invoice
      description: |
        Void an `active` or `completed` invoice. This has the same effects as the
        admin Void action: applied credit-memo discounts are rolled back, the sales
        order's invoiced quantities are rolled back, and a QuickBooks or Xero invoice
        is voided on the next accounting sync.

        The linked sales order is kept by default. Send `"delete_sales_order": true`
        to delete it as well. Only a sales order that Luminous created from the
        invoice is deleted; a channel order (for example, from Shopify) is always kept.

        Requires the API token user to have the invoice update permission
        (`invoices.update`).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: invoiceId
          required: true
          schema:
            type: integer
          description: ID of the invoice to void
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                delete_sales_order:
                  type: boolean
                  default: false
                  description: |
                    Also delete the linked sales order. Only a sales order that Luminous
                    created from the invoice is deleted; channel orders are always kept.
      responses:
        '200':
          description: Invoice voided; returns the updated invoice
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the invoice
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was last updated
                      status:
                        type: string
                        description: Current status of the invoice
                      payment_status:
                        type: string
                        description: Payment status of the invoice
                      order_date:
                        type: string
                        format: date-time
                        description: Date when the invoice was created
                      ship_by_date:
                        type: string
                        format: date-time
                        description: Required ship by date
                      approval_status:
                        type: string
                        description: Approval status of the invoice
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      payment_terms:
                        type: string
                        nullable: true
                        description: Payment terms for the invoice
                      public_note:
                        type: string
                        nullable: true
                        description: Public note visible to customer
                      private_note:
                        type: string
                        nullable: true
                        description: Private internal note
                      total_qty:
                        type: number
                        format: float
                        description: Total quantity of items
                      total_shipping:
                        type: number
                        format: float
                        description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_discount:
                        type: number
                        format: float
                        description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total:
                        type: number
                        format: float
                        description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                      total_paid:
                        type: number
                        format: float
                        description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_due:
                        type: number
                        format: float
                        description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Associated warehouse ID
                      ship_to:
                        type: object
                        properties:
                          address_1:
                            type: string
                            nullable: true
                          address_2:
                            type: string
                            nullable: true
                          city:
                            type: string
                            nullable: true
                          state:
                            type: string
                            nullable: true
                          zip:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                        description: Shipping address details
                      quickbooks_invoice_id:
                        type: string
                        nullable: true
                        description: QuickBooks invoice ID
                      quickbooks_message:
                        type: string
                        description: Message from QuickBooks integration
                      customer:
                        description: Customer information
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the customer
                          name:
                            type: string
                            description: Business name
                          address_1:
                            type: string
                            nullable: true
                            description: Primary address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address
                          city:
                            type: string
                            nullable: true
                            description: City
                          state:
                            type: string
                            nullable: true
                            description: State/Province
                          zip:
                            type: string
                            nullable: true
                            description: Postal code
                          country:
                            type: string
                            nullable: true
                            description: Country
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                          email:
                            type: string
                            nullable: true
                            description: Email address
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was last updated
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                            sku:
                              type: string
                              description: Product SKU
                            name:
                              type: string
                              description: Product name
                            product_id:
                              type: integer
                              description: Product identifier
                            qty:
                              type: number
                              format: float
                              description: Quantity ordered
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            discount:
                              type: number
                              format: float
                              nullable: true
                              description: Discount amount
                            total:
                              type: number
                              format: float
                              description: Total line item amount
                            taxable:
                              type: boolean
                              description: Whether the line item is subject to sales tax. Defaults to true when not set.
                        description: Line items in the invoice
                      payments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            invoice_id:
                              type: integer
                              description: Associated invoice ID
                            gateway:
                              type: string
                              description: Payment gateway used
                            type:
                              type: string
                              description: Payment type
                            charge_type:
                              type: string
                              description: Type of charge
                            amount:
                              type: number
                              format: float
                              description: Payment amount
                            date:
                              type: string
                              format: date-time
                              description: Payment date
                            status:
                              type: string
                              description: Payment status
                            external_id:
                              type: string
                              nullable: true
                              description: External payment identifier
                            notes:
                              type: string
                              nullable: true
                              description: Payment notes
                            reference_id:
                              type: string
                              nullable: true
                              description: Reference identifier
                            gateway_response:
                              type: object
                              properties:
                                status:
                                  type: string
                                  description: Gateway response status
                                code:
                                  type: string
                                  description: Response code
                                message:
                                  type: string
                                  description: Response message
                                metadata:
                                  type: string
                                  description: Additional metadata
                              description: Payment gateway response details
                            created_by:
                              type: integer
                              nullable: true
                              description: User who created the payment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was last updated
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Soft delete timestamp
                        description: Payment records for the invoice
                      sales_order:
                        type: object
                        nullable: true
                        description: Sales order associated with the invoice (if any)
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the sales order
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was last updated
                          status:
                            type: string
                            description: Current status of the order
                          order_id:
                            type: string
                            description: External order identifier
                          order_number:
                            type: string
                            description: Order number
                          order_date:
                            type: string
                            format: date
                            description: Date when the order was placed
                          payment_date:
                            type: string
                            format: date
                            description: Date when payment was received
                          ship_by_date:
                            type: string
                            format: date
                            description: Required ship by date
                          age:
                            type: integer
                            description: Age of the order in days
                          order_status:
                            type: string
                            description: Status of the order
                          customer_id:
                            type: string
                            description: Customer identifier
                          customer_username:
                            type: string
                            description: Customer's username
                          customer_email:
                            type: string
                            description: Customer's email address
                          bill_to:
                            type: object
                            description: Billing information
                          ship_to:
                            type: object
                            description: Shipping information
                          requested_shipping_service:
                            type: string
                            nullable: true
                            description: What shipping service to use when shipping this order
                          total:
                            type: number
                            format: float
                            description: Total order amount
                          total_paid:
                            type: number
                            format: float
                            description: Amount paid
                          total_tax:
                            type: number
                            format: float
                            description: Total tax amount
                          total_shipping:
                            type: number
                            format: float
                            description: Total shipping amount
                          customer_notes:
                            type: string
                            description: Notes from the customer
                          internal_notes:
                            type: string
                            description: Internal notes
                          ship_date:
                            type: string
                            format: date
                            description: Date when order was shipped
                          hold_until_date:
                            type: string
                            format: date
                            description: Hold until date
                          user_id:
                            type: integer
                            description: User ID associated with the order
                          externally_fulfilled:
                            type: boolean
                            description: Whether the order is fulfilled externally
                          externally_fulfilled_by:
                            type: string
                            description: Entity fulfilling the order externally
                          is_posted:
                            type: boolean
                            description: Whether the order is posted
                          posted_by:
                            type: string
                            description: User who posted the order
                          not_sync:
                            type: boolean
                            description: Sync status
                          sales_posted:
                            type: boolean
                            description: Sales posting status
                          split_order:
                            type: boolean
                            description: Whether the order is split
                          skip_inventory:
                            type: boolean
                            description: Whether to skip inventory
                          skip_sales_report:
                            type: boolean
                            description: Whether to skip sales report
                          channel_id:
                            type: integer
                            description: Channel identifier
                          total_order_cost:
                            type: number
                            format: float
                            description: Total cost of order
                          total_order_quantity:
                            type: number
                            format: float
                            description: Total quantity of items
                          order_cost_details:
                            type: object
                            description: Detailed order cost information
                          source:
                            type: string
                            description: Order source
                          shipstation_order_id:
                            type: string
                            description: ShipStation order identifier
                          type:
                            type: string
                            description: Order type
                          parent_id:
                            type: integer
                            description: Parent order ID if applicable
                          shipping_revenue:
                            type: number
                            format: float
                            description: Revenue from shipping
                          product_total:
                            type: number
                            format: float
                            description: Total product amount
                          total_discount:
                            type: number
                            format: float
                            description: Total discount amount
                          picking_status:
                            type: string
                            description: Status of picking process
                          starred_description:
                            type: string
                            description: Description for starred orders
                          customer_po_number:
                            type: string
                            description: Customer PO number
                      custom_fields:
                        type: object
                        description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Field Name 1: Some Value
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                        description: Tags associated with the invoice
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Token user lacks the invoice update permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            The invoice cannot be voided: it is already void, its status is not
            `active`/`completed`, it has a price override that is not approved yet, or
            it has no valid payment terms. `message` says which (for example
            `Invoice is already void.`).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '500':
          description: The void failed while writing its changes.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/invoices/{invoiceId}/approve':
    post:
      operationId: approveInvoice
      tags:
        - Invoices
      summary: Approve invoice
      description: |
        Approve an invoice that is pending approval. Mirrors the admin approve action:
        on success the invoice's `approval_status` becomes `APPROVED`, its `status`
        becomes `active`, and the approval is recorded in the invoice's approval log.

        After approval, a linked sales order is created from the invoice — or, if a
        non-active linked sales order already exists, it is updated to match the
        invoice. Approval fails with a `400` if an **active** sales order entry
        already exists for the invoice.

        Requires the API token user to have the invoice approval permission
        (`invoices.approve.company`).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: invoiceId
          required: true
          schema:
            type: integer
          description: ID of the invoice to approve
      responses:
        '200':
          description: Invoice approved; returns the updated invoice
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the invoice
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was last updated
                      status:
                        type: string
                        description: Current status of the invoice
                      payment_status:
                        type: string
                        description: Payment status of the invoice
                      order_date:
                        type: string
                        format: date-time
                        description: Date when the invoice was created
                      ship_by_date:
                        type: string
                        format: date-time
                        description: Required ship by date
                      approval_status:
                        type: string
                        description: Approval status of the invoice
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      payment_terms:
                        type: string
                        nullable: true
                        description: Payment terms for the invoice
                      public_note:
                        type: string
                        nullable: true
                        description: Public note visible to customer
                      private_note:
                        type: string
                        nullable: true
                        description: Private internal note
                      total_qty:
                        type: number
                        format: float
                        description: Total quantity of items
                      total_shipping:
                        type: number
                        format: float
                        description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_discount:
                        type: number
                        format: float
                        description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total:
                        type: number
                        format: float
                        description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                      total_paid:
                        type: number
                        format: float
                        description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_due:
                        type: number
                        format: float
                        description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Associated warehouse ID
                      ship_to:
                        type: object
                        properties:
                          address_1:
                            type: string
                            nullable: true
                          address_2:
                            type: string
                            nullable: true
                          city:
                            type: string
                            nullable: true
                          state:
                            type: string
                            nullable: true
                          zip:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                        description: Shipping address details
                      quickbooks_invoice_id:
                        type: string
                        nullable: true
                        description: QuickBooks invoice ID
                      quickbooks_message:
                        type: string
                        description: Message from QuickBooks integration
                      customer:
                        description: Customer information
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the customer
                          name:
                            type: string
                            description: Business name
                          address_1:
                            type: string
                            nullable: true
                            description: Primary address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address
                          city:
                            type: string
                            nullable: true
                            description: City
                          state:
                            type: string
                            nullable: true
                            description: State/Province
                          zip:
                            type: string
                            nullable: true
                            description: Postal code
                          country:
                            type: string
                            nullable: true
                            description: Country
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                          email:
                            type: string
                            nullable: true
                            description: Email address
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was last updated
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                            sku:
                              type: string
                              description: Product SKU
                            name:
                              type: string
                              description: Product name
                            product_id:
                              type: integer
                              description: Product identifier
                            qty:
                              type: number
                              format: float
                              description: Quantity ordered
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            discount:
                              type: number
                              format: float
                              nullable: true
                              description: Discount amount
                            total:
                              type: number
                              format: float
                              description: Total line item amount
                            taxable:
                              type: boolean
                              description: Whether the line item is subject to sales tax. Defaults to true when not set.
                        description: Line items in the invoice
                      payments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            invoice_id:
                              type: integer
                              description: Associated invoice ID
                            gateway:
                              type: string
                              description: Payment gateway used
                            type:
                              type: string
                              description: Payment type
                            charge_type:
                              type: string
                              description: Type of charge
                            amount:
                              type: number
                              format: float
                              description: Payment amount
                            date:
                              type: string
                              format: date-time
                              description: Payment date
                            status:
                              type: string
                              description: Payment status
                            external_id:
                              type: string
                              nullable: true
                              description: External payment identifier
                            notes:
                              type: string
                              nullable: true
                              description: Payment notes
                            reference_id:
                              type: string
                              nullable: true
                              description: Reference identifier
                            gateway_response:
                              type: object
                              properties:
                                status:
                                  type: string
                                  description: Gateway response status
                                code:
                                  type: string
                                  description: Response code
                                message:
                                  type: string
                                  description: Response message
                                metadata:
                                  type: string
                                  description: Additional metadata
                              description: Payment gateway response details
                            created_by:
                              type: integer
                              nullable: true
                              description: User who created the payment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was last updated
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Soft delete timestamp
                        description: Payment records for the invoice
                      sales_order:
                        type: object
                        nullable: true
                        description: Sales order associated with the invoice (if any)
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the sales order
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was last updated
                          status:
                            type: string
                            description: Current status of the order
                          order_id:
                            type: string
                            description: External order identifier
                          order_number:
                            type: string
                            description: Order number
                          order_date:
                            type: string
                            format: date
                            description: Date when the order was placed
                          payment_date:
                            type: string
                            format: date
                            description: Date when payment was received
                          ship_by_date:
                            type: string
                            format: date
                            description: Required ship by date
                          age:
                            type: integer
                            description: Age of the order in days
                          order_status:
                            type: string
                            description: Status of the order
                          customer_id:
                            type: string
                            description: Customer identifier
                          customer_username:
                            type: string
                            description: Customer's username
                          customer_email:
                            type: string
                            description: Customer's email address
                          bill_to:
                            type: object
                            description: Billing information
                          ship_to:
                            type: object
                            description: Shipping information
                          requested_shipping_service:
                            type: string
                            nullable: true
                            description: What shipping service to use when shipping this order
                          total:
                            type: number
                            format: float
                            description: Total order amount
                          total_paid:
                            type: number
                            format: float
                            description: Amount paid
                          total_tax:
                            type: number
                            format: float
                            description: Total tax amount
                          total_shipping:
                            type: number
                            format: float
                            description: Total shipping amount
                          customer_notes:
                            type: string
                            description: Notes from the customer
                          internal_notes:
                            type: string
                            description: Internal notes
                          ship_date:
                            type: string
                            format: date
                            description: Date when order was shipped
                          hold_until_date:
                            type: string
                            format: date
                            description: Hold until date
                          user_id:
                            type: integer
                            description: User ID associated with the order
                          externally_fulfilled:
                            type: boolean
                            description: Whether the order is fulfilled externally
                          externally_fulfilled_by:
                            type: string
                            description: Entity fulfilling the order externally
                          is_posted:
                            type: boolean
                            description: Whether the order is posted
                          posted_by:
                            type: string
                            description: User who posted the order
                          not_sync:
                            type: boolean
                            description: Sync status
                          sales_posted:
                            type: boolean
                            description: Sales posting status
                          split_order:
                            type: boolean
                            description: Whether the order is split
                          skip_inventory:
                            type: boolean
                            description: Whether to skip inventory
                          skip_sales_report:
                            type: boolean
                            description: Whether to skip sales report
                          channel_id:
                            type: integer
                            description: Channel identifier
                          total_order_cost:
                            type: number
                            format: float
                            description: Total cost of order
                          total_order_quantity:
                            type: number
                            format: float
                            description: Total quantity of items
                          order_cost_details:
                            type: object
                            description: Detailed order cost information
                          source:
                            type: string
                            description: Order source
                          shipstation_order_id:
                            type: string
                            description: ShipStation order identifier
                          type:
                            type: string
                            description: Order type
                          parent_id:
                            type: integer
                            description: Parent order ID if applicable
                          shipping_revenue:
                            type: number
                            format: float
                            description: Revenue from shipping
                          product_total:
                            type: number
                            format: float
                            description: Total product amount
                          total_discount:
                            type: number
                            format: float
                            description: Total discount amount
                          picking_status:
                            type: string
                            description: Status of picking process
                          starred_description:
                            type: string
                            description: Description for starred orders
                          customer_po_number:
                            type: string
                            description: Customer PO number
                      custom_fields:
                        type: object
                        description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Field Name 1: Some Value
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                        description: Tags associated with the invoice
        '400':
          description: 'Cannot approve — an active sales order entry already exists for this invoice, or the approval could not be persisted'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Token user lacks the invoice approval permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/invoices/{invoiceId}/reject':
    post:
      operationId: rejectInvoice
      tags:
        - Invoices
      summary: Reject invoice
      description: |
        Reject an invoice that is pending approval. Mirrors the admin reject action:
        on success the invoice's `approval_status` becomes `DECLINED`, its `status`
        reverts to `draft`, and the rejection is recorded in the invoice's approval
        log. Rejection fails with a `400` if an **active** sales order entry already
        exists for the invoice.

        Requires the API token user to have the invoice approval permission
        (`invoices.approve.company`).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: invoiceId
          required: true
          schema:
            type: integer
          description: ID of the invoice to reject
      responses:
        '200':
          description: Invoice rejected; returns the updated invoice
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the invoice
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was last updated
                      status:
                        type: string
                        description: Current status of the invoice
                      payment_status:
                        type: string
                        description: Payment status of the invoice
                      order_date:
                        type: string
                        format: date-time
                        description: Date when the invoice was created
                      ship_by_date:
                        type: string
                        format: date-time
                        description: Required ship by date
                      approval_status:
                        type: string
                        description: Approval status of the invoice
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      payment_terms:
                        type: string
                        nullable: true
                        description: Payment terms for the invoice
                      public_note:
                        type: string
                        nullable: true
                        description: Public note visible to customer
                      private_note:
                        type: string
                        nullable: true
                        description: Private internal note
                      total_qty:
                        type: number
                        format: float
                        description: Total quantity of items
                      total_shipping:
                        type: number
                        format: float
                        description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_discount:
                        type: number
                        format: float
                        description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total:
                        type: number
                        format: float
                        description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                      total_paid:
                        type: number
                        format: float
                        description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_due:
                        type: number
                        format: float
                        description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Associated warehouse ID
                      ship_to:
                        type: object
                        properties:
                          address_1:
                            type: string
                            nullable: true
                          address_2:
                            type: string
                            nullable: true
                          city:
                            type: string
                            nullable: true
                          state:
                            type: string
                            nullable: true
                          zip:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                        description: Shipping address details
                      quickbooks_invoice_id:
                        type: string
                        nullable: true
                        description: QuickBooks invoice ID
                      quickbooks_message:
                        type: string
                        description: Message from QuickBooks integration
                      customer:
                        description: Customer information
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the customer
                          name:
                            type: string
                            description: Business name
                          address_1:
                            type: string
                            nullable: true
                            description: Primary address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address
                          city:
                            type: string
                            nullable: true
                            description: City
                          state:
                            type: string
                            nullable: true
                            description: State/Province
                          zip:
                            type: string
                            nullable: true
                            description: Postal code
                          country:
                            type: string
                            nullable: true
                            description: Country
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                          email:
                            type: string
                            nullable: true
                            description: Email address
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was last updated
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                            sku:
                              type: string
                              description: Product SKU
                            name:
                              type: string
                              description: Product name
                            product_id:
                              type: integer
                              description: Product identifier
                            qty:
                              type: number
                              format: float
                              description: Quantity ordered
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            discount:
                              type: number
                              format: float
                              nullable: true
                              description: Discount amount
                            total:
                              type: number
                              format: float
                              description: Total line item amount
                            taxable:
                              type: boolean
                              description: Whether the line item is subject to sales tax. Defaults to true when not set.
                        description: Line items in the invoice
                      payments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            invoice_id:
                              type: integer
                              description: Associated invoice ID
                            gateway:
                              type: string
                              description: Payment gateway used
                            type:
                              type: string
                              description: Payment type
                            charge_type:
                              type: string
                              description: Type of charge
                            amount:
                              type: number
                              format: float
                              description: Payment amount
                            date:
                              type: string
                              format: date-time
                              description: Payment date
                            status:
                              type: string
                              description: Payment status
                            external_id:
                              type: string
                              nullable: true
                              description: External payment identifier
                            notes:
                              type: string
                              nullable: true
                              description: Payment notes
                            reference_id:
                              type: string
                              nullable: true
                              description: Reference identifier
                            gateway_response:
                              type: object
                              properties:
                                status:
                                  type: string
                                  description: Gateway response status
                                code:
                                  type: string
                                  description: Response code
                                message:
                                  type: string
                                  description: Response message
                                metadata:
                                  type: string
                                  description: Additional metadata
                              description: Payment gateway response details
                            created_by:
                              type: integer
                              nullable: true
                              description: User who created the payment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was last updated
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Soft delete timestamp
                        description: Payment records for the invoice
                      sales_order:
                        type: object
                        nullable: true
                        description: Sales order associated with the invoice (if any)
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the sales order
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was last updated
                          status:
                            type: string
                            description: Current status of the order
                          order_id:
                            type: string
                            description: External order identifier
                          order_number:
                            type: string
                            description: Order number
                          order_date:
                            type: string
                            format: date
                            description: Date when the order was placed
                          payment_date:
                            type: string
                            format: date
                            description: Date when payment was received
                          ship_by_date:
                            type: string
                            format: date
                            description: Required ship by date
                          age:
                            type: integer
                            description: Age of the order in days
                          order_status:
                            type: string
                            description: Status of the order
                          customer_id:
                            type: string
                            description: Customer identifier
                          customer_username:
                            type: string
                            description: Customer's username
                          customer_email:
                            type: string
                            description: Customer's email address
                          bill_to:
                            type: object
                            description: Billing information
                          ship_to:
                            type: object
                            description: Shipping information
                          requested_shipping_service:
                            type: string
                            nullable: true
                            description: What shipping service to use when shipping this order
                          total:
                            type: number
                            format: float
                            description: Total order amount
                          total_paid:
                            type: number
                            format: float
                            description: Amount paid
                          total_tax:
                            type: number
                            format: float
                            description: Total tax amount
                          total_shipping:
                            type: number
                            format: float
                            description: Total shipping amount
                          customer_notes:
                            type: string
                            description: Notes from the customer
                          internal_notes:
                            type: string
                            description: Internal notes
                          ship_date:
                            type: string
                            format: date
                            description: Date when order was shipped
                          hold_until_date:
                            type: string
                            format: date
                            description: Hold until date
                          user_id:
                            type: integer
                            description: User ID associated with the order
                          externally_fulfilled:
                            type: boolean
                            description: Whether the order is fulfilled externally
                          externally_fulfilled_by:
                            type: string
                            description: Entity fulfilling the order externally
                          is_posted:
                            type: boolean
                            description: Whether the order is posted
                          posted_by:
                            type: string
                            description: User who posted the order
                          not_sync:
                            type: boolean
                            description: Sync status
                          sales_posted:
                            type: boolean
                            description: Sales posting status
                          split_order:
                            type: boolean
                            description: Whether the order is split
                          skip_inventory:
                            type: boolean
                            description: Whether to skip inventory
                          skip_sales_report:
                            type: boolean
                            description: Whether to skip sales report
                          channel_id:
                            type: integer
                            description: Channel identifier
                          total_order_cost:
                            type: number
                            format: float
                            description: Total cost of order
                          total_order_quantity:
                            type: number
                            format: float
                            description: Total quantity of items
                          order_cost_details:
                            type: object
                            description: Detailed order cost information
                          source:
                            type: string
                            description: Order source
                          shipstation_order_id:
                            type: string
                            description: ShipStation order identifier
                          type:
                            type: string
                            description: Order type
                          parent_id:
                            type: integer
                            description: Parent order ID if applicable
                          shipping_revenue:
                            type: number
                            format: float
                            description: Revenue from shipping
                          product_total:
                            type: number
                            format: float
                            description: Total product amount
                          total_discount:
                            type: number
                            format: float
                            description: Total discount amount
                          picking_status:
                            type: string
                            description: Status of picking process
                          starred_description:
                            type: string
                            description: Description for starred orders
                          customer_po_number:
                            type: string
                            description: Customer PO number
                      custom_fields:
                        type: object
                        description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Field Name 1: Some Value
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                        description: Tags associated with the invoice
        '400':
          description: 'Cannot reject — an active sales order entry already exists for this invoice, or the rejection could not be persisted'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Token user lacks the invoice approval permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/invoices/{invoiceId}/send-email':
    post:
      operationId: sendInvoiceEmail
      tags:
        - Invoices
      summary: Email a Draft invoice
      description: |
        Email a **Draft** invoice to the contact(s) on file for its account. Mirrors
        the admin "send invoice" action: the invoice PDF is rendered from the tenant's
        default template and the email is **queued** for delivery. The account's sales
        reps are CC'd, exactly as the UI action does.

        The endpoint accepts **no request body** — recipients are always the invoice's
        contact(s) on file, and the template cannot be chosen per request.

        Only invoices in `Draft` status can be emailed; any other status returns `422`.

        The reported `status` describes **acceptance onto the send queue, not delivery** —
        knowing whether mail landed, bounced, or was opened is out of scope. `send_reference`
        is an opaque handle echoed back and written to the invoice's activity log so a send
        can be correlated after the fact.

        Requires the API token user to have the send-invoices permission
        (`invoices.send`), granted to super-admin and admin roles only.

        **Idempotency:** this endpoint has an irreversible side effect — once the customer
        has the mail, no retry can unsend it — so it supports the optional `Idempotency-Key`
        request header. Send the same key on a retry to replay the original response instead
        of queueing a second email; replayed responses carry an `Idempotent-Replay: true`
        header. Omitting the header passes straight through with no idempotency guard, so two
        identical calls queue two emails (exactly as two clicks of the UI action would).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: invoiceId
          required: true
          schema:
            type: integer
          description: ID of the Draft invoice to email
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: |
            Optional opt-in idempotency token. When supplied, a retry carrying the same key
            replays the original stored response (with an `Idempotent-Replay: true` header)
            instead of queueing another email. Omit it to disable the guard for this request.
      responses:
        '200':
          description: |
            The email was queued for at least one recipient. A `partial` status means some
            recipients were queued and some could not be; see the per-recipient `recipients`
            array for detail.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      invoice_id:
                        type: integer
                        description: ID of the invoice that was emailed
                      send_reference:
                        type: string
                        format: uuid
                        description: 'Opaque handle for this send, echoed back and recorded on the activity log'
                      status:
                        type: string
                        enum:
                          - queued
                          - partial
                          - failed
                        description: |
                          Acceptance outcome (not delivery). `queued` — every recipient accepted;
                          `partial` — some accepted; `failed` — nothing could be queued.
                      accepted_at:
                        type: string
                        format: date-time
                        description: ISO-8601 timestamp when the send was accepted
                      recipients:
                        type: array
                        description: Per-recipient acceptance outcome
                        items:
                          type: object
                          properties:
                            email:
                              type: string
                              format: email
                            type:
                              type: string
                              enum:
                                - to
                                - cc
                              description: Whether the recipient was a primary (`to`) or CC address
                            status:
                              type: string
                              enum:
                                - queued
                                - failed
                            error:
                              type: string
                              description: Present only when this recipient could not be queued
        '401':
          description: Unauthorized — no authenticated user resolved from the token
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Token user lacks the send-invoices permission (`invoices.send`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Cannot send — the invoice is not in `Draft` status, has no contact on file, or
            the tenant has no default invoice template configured.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '502':
          description: |
            The email could not be queued (e.g. the queue backend was unreachable). The body
            includes a `data` object with the `failed` status and per-recipient detail.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /estimates:
    get:
      operationId: getEstimates
      tags:
        - Invoices
      summary: Estimates
      description: |
        Get a paginated list of estimates. An estimate is an invoice whose status is `ESTIMATE`
        (create one with `POST /invoices` and `status: ESTIMATE`), so each row has the same shape as
        `GET /invoices` and the same filters apply. Invoice endpoints are unchanged and still return
        estimates alongside other invoices.

        A `status` filter is still applied on top of the estimate restriction, so for example
        `status=ACTIVE` returns no rows.

        See `GET /invoices` for the full filter list, and the
        [Filter System Documentation](/filters) for operators.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: fields
          schema:
            type: string
          description: 'Comma-separated list of fields to include in each returned estimate (field projection). When omitted, the full invoice object is returned. Example: `fields=id,status,total`.'
        - in: query
          name: company_id
          schema:
            type: integer
          description: Filter by the ID of the company (customer) the invoice belongs to
        - in: query
          name: customer_id
          schema:
            type: integer
          description: Alias for `company_id` — filter by the ID of the company (customer) the invoice belongs to
        - in: query
          name: sales_channel_id
          schema:
            type: integer
          description: Filter by the sales channel ID associated with the invoice
        - in: query
          name: status
          schema:
            type: string
          description: Filter by invoice status
        - in: query
          name: sales_order.order_number
          schema:
            type: string
          description: Filter by sales order number (if sales order is attached to invoice)
        - in: query
          name: payment_status
          schema:
            type: string
          description: Filter by payment status
        - in: query
          name: approval_status
          schema:
            type: string
          description: Filter by approval status
        - in: query
          name: customer_po_number
          schema:
            type: string
          description: Filter by customer PO number
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by tag name
        - in: query
          name: order_date
          schema:
            type: string
            format: date
          description: Filter by order date (YYYY-MM-DD)
        - in: query
          name: ship_by_date
          schema:
            type: string
            format: date
          description: Filter by ship by date (YYYY-MM-DD)
        - in: query
          name: due_date
          schema:
            type: string
            format: date
          description: Filter by due date (YYYY-MM-DD)
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: total_qty
          schema:
            type: number
          description: Filter by total quantity
        - in: query
          name: total
          schema:
            type: number
          description: Filter by invoice total amount
        - in: query
          name: total_shipping
          schema:
            type: number
          description: Filter by shipping amount
        - in: query
          name: total_discount
          schema:
            type: number
          description: Filter by discount amount
        - in: query
          name: total_paid
          schema:
            type: number
          description: Filter by amount paid
        - in: query
          name: total_due
          schema:
            type: number
          description: Filter by amount due
        - in: query
          name: custom_fields
          schema:
            type: object
          description: Filter by custom fields
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the invoice
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the invoice was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the invoice was last updated
                        status:
                          type: string
                          description: Current status of the invoice
                        payment_status:
                          type: string
                          description: Payment status of the invoice
                        order_date:
                          type: string
                          format: date-time
                          description: Date when the invoice was created
                        ship_by_date:
                          type: string
                          format: date-time
                          description: Required ship by date
                        approval_status:
                          type: string
                          description: Approval status of the invoice
                        customer_po_number:
                          type: string
                          description: Customer PO number
                        payment_terms:
                          type: string
                          nullable: true
                          description: Payment terms for the invoice
                        public_note:
                          type: string
                          nullable: true
                          description: Public note visible to customer
                        private_note:
                          type: string
                          nullable: true
                          description: Private internal note
                        total_qty:
                          type: number
                          format: float
                          description: Total quantity of items
                        total_shipping:
                          type: number
                          format: float
                          description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total_discount:
                          type: number
                          format: float
                          description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total:
                          type: number
                          format: float
                          description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                        total_paid:
                          type: number
                          format: float
                          description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total_due:
                          type: number
                          format: float
                          description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: Associated warehouse ID
                        ship_to:
                          type: object
                          properties:
                            address_1:
                              type: string
                              nullable: true
                            address_2:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                            state:
                              type: string
                              nullable: true
                            zip:
                              type: string
                              nullable: true
                            country:
                              type: string
                              nullable: true
                          description: Shipping address details
                        quickbooks_invoice_id:
                          type: string
                          nullable: true
                          description: QuickBooks invoice ID
                        quickbooks_message:
                          type: string
                          description: Message from QuickBooks integration
                        customer:
                          description: Customer information
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the customer
                            name:
                              type: string
                              description: Business name
                            address_1:
                              type: string
                              nullable: true
                              description: Primary address
                            address_2:
                              type: string
                              nullable: true
                              description: Secondary address
                            city:
                              type: string
                              nullable: true
                              description: City
                            state:
                              type: string
                              nullable: true
                              description: State/Province
                            zip:
                              type: string
                              nullable: true
                              description: Postal code
                            country:
                              type: string
                              nullable: true
                              description: Country
                            phone:
                              type: string
                              nullable: true
                              description: Phone number
                            email:
                              type: string
                              nullable: true
                              description: Email address
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when customer was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when customer was last updated
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the line item
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was last updated
                              sku:
                                type: string
                                description: Product SKU
                              name:
                                type: string
                                description: Product name
                              product_id:
                                type: integer
                                description: Product identifier
                              qty:
                                type: number
                                format: float
                                description: Quantity ordered
                              unit_price:
                                type: number
                                format: float
                                description: Price per unit
                              discount:
                                type: number
                                format: float
                                nullable: true
                                description: Discount amount
                              total:
                                type: number
                                format: float
                                description: Total line item amount
                              taxable:
                                type: boolean
                                description: Whether the line item is subject to sales tax. Defaults to true when not set.
                          description: Line items in the invoice
                        payments:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the payment
                              invoice_id:
                                type: integer
                                description: Associated invoice ID
                              gateway:
                                type: string
                                description: Payment gateway used
                              type:
                                type: string
                                description: Payment type
                              charge_type:
                                type: string
                                description: Type of charge
                              amount:
                                type: number
                                format: float
                                description: Payment amount
                              date:
                                type: string
                                format: date-time
                                description: Payment date
                              status:
                                type: string
                                description: Payment status
                              external_id:
                                type: string
                                nullable: true
                                description: External payment identifier
                              notes:
                                type: string
                                nullable: true
                                description: Payment notes
                              reference_id:
                                type: string
                                nullable: true
                                description: Reference identifier
                              gateway_response:
                                type: object
                                properties:
                                  status:
                                    type: string
                                    description: Gateway response status
                                  code:
                                    type: string
                                    description: Response code
                                  message:
                                    type: string
                                    description: Response message
                                  metadata:
                                    type: string
                                    description: Additional metadata
                                description: Payment gateway response details
                              created_by:
                                type: integer
                                nullable: true
                                description: User who created the payment
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when payment was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when payment was last updated
                              deleted_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: Soft delete timestamp
                          description: Payment records for the invoice
                        sales_order:
                          type: object
                          nullable: true
                          description: Sales order associated with the invoice (if any)
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the sales order
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the order was last updated
                            status:
                              type: string
                              description: Current status of the order
                            order_id:
                              type: string
                              description: External order identifier
                            order_number:
                              type: string
                              description: Order number
                            order_date:
                              type: string
                              format: date
                              description: Date when the order was placed
                            payment_date:
                              type: string
                              format: date
                              description: Date when payment was received
                            ship_by_date:
                              type: string
                              format: date
                              description: Required ship by date
                            age:
                              type: integer
                              description: Age of the order in days
                            order_status:
                              type: string
                              description: Status of the order
                            customer_id:
                              type: string
                              description: Customer identifier
                            customer_username:
                              type: string
                              description: Customer's username
                            customer_email:
                              type: string
                              description: Customer's email address
                            bill_to:
                              type: object
                              description: Billing information
                            ship_to:
                              type: object
                              description: Shipping information
                            requested_shipping_service:
                              type: string
                              nullable: true
                              description: What shipping service to use when shipping this order
                            total:
                              type: number
                              format: float
                              description: Total order amount
                            total_paid:
                              type: number
                              format: float
                              description: Amount paid
                            total_tax:
                              type: number
                              format: float
                              description: Total tax amount
                            total_shipping:
                              type: number
                              format: float
                              description: Total shipping amount
                            customer_notes:
                              type: string
                              description: Notes from the customer
                            internal_notes:
                              type: string
                              description: Internal notes
                            ship_date:
                              type: string
                              format: date
                              description: Date when order was shipped
                            hold_until_date:
                              type: string
                              format: date
                              description: Hold until date
                            user_id:
                              type: integer
                              description: User ID associated with the order
                            externally_fulfilled:
                              type: boolean
                              description: Whether the order is fulfilled externally
                            externally_fulfilled_by:
                              type: string
                              description: Entity fulfilling the order externally
                            is_posted:
                              type: boolean
                              description: Whether the order is posted
                            posted_by:
                              type: string
                              description: User who posted the order
                            not_sync:
                              type: boolean
                              description: Sync status
                            sales_posted:
                              type: boolean
                              description: Sales posting status
                            split_order:
                              type: boolean
                              description: Whether the order is split
                            skip_inventory:
                              type: boolean
                              description: Whether to skip inventory
                            skip_sales_report:
                              type: boolean
                              description: Whether to skip sales report
                            channel_id:
                              type: integer
                              description: Channel identifier
                            total_order_cost:
                              type: number
                              format: float
                              description: Total cost of order
                            total_order_quantity:
                              type: number
                              format: float
                              description: Total quantity of items
                            order_cost_details:
                              type: object
                              description: Detailed order cost information
                            source:
                              type: string
                              description: Order source
                            shipstation_order_id:
                              type: string
                              description: ShipStation order identifier
                            type:
                              type: string
                              description: Order type
                            parent_id:
                              type: integer
                              description: Parent order ID if applicable
                            shipping_revenue:
                              type: number
                              format: float
                              description: Revenue from shipping
                            product_total:
                              type: number
                              format: float
                              description: Total product amount
                            total_discount:
                              type: number
                              format: float
                              description: Total discount amount
                            picking_status:
                              type: string
                              description: Status of picking process
                            starred_description:
                              type: string
                              description: Description for starred orders
                            customer_po_number:
                              type: string
                              description: Customer PO number
                        custom_fields:
                          type: object
                          description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          example:
                            Field Name 1: Some Value
                        tags:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the tag
                              name:
                                type: string
                                description: Name of the tag
                              description:
                                type: string
                                nullable: true
                                description: Description of the tag
                              icon:
                                type: string
                                nullable: true
                                description: Icon identifier or URL for the tag
                              color:
                                type: string
                                nullable: true
                                description: Color code for the tag
                            required:
                              - id
                              - name
                          description: Tags associated with the invoice
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  '/estimates/{estimateId}':
    get:
      operationId: getEstimate
      tags:
        - Invoices
      summary: Single estimate
      description: |
        Get one estimate by ID. Same shape as `GET /invoices/{id}`. Returns a 404 when the ID belongs
        to an invoice that is not an estimate.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: estimateId
          required: true
          schema:
            type: integer
          description: ID of the estimate (its invoice ID)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the invoice
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the invoice was last updated
                      status:
                        type: string
                        description: Current status of the invoice
                      payment_status:
                        type: string
                        description: Payment status of the invoice
                      order_date:
                        type: string
                        format: date-time
                        description: Date when the invoice was created
                      ship_by_date:
                        type: string
                        format: date-time
                        description: Required ship by date
                      approval_status:
                        type: string
                        description: Approval status of the invoice
                      customer_po_number:
                        type: string
                        description: Customer PO number
                      payment_terms:
                        type: string
                        nullable: true
                        description: Payment terms for the invoice
                      public_note:
                        type: string
                        nullable: true
                        description: Public note visible to customer
                      private_note:
                        type: string
                        nullable: true
                        description: Private internal note
                      total_qty:
                        type: number
                        format: float
                        description: Total quantity of items
                      total_shipping:
                        type: number
                        format: float
                        description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_discount:
                        type: number
                        format: float
                        description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total:
                        type: number
                        format: float
                        description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                      total_paid:
                        type: number
                        format: float
                        description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                      total_due:
                        type: number
                        format: float
                        description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: Associated warehouse ID
                      ship_to:
                        type: object
                        properties:
                          address_1:
                            type: string
                            nullable: true
                          address_2:
                            type: string
                            nullable: true
                          city:
                            type: string
                            nullable: true
                          state:
                            type: string
                            nullable: true
                          zip:
                            type: string
                            nullable: true
                          country:
                            type: string
                            nullable: true
                        description: Shipping address details
                      quickbooks_invoice_id:
                        type: string
                        nullable: true
                        description: QuickBooks invoice ID
                      quickbooks_message:
                        type: string
                        description: Message from QuickBooks integration
                      customer:
                        description: Customer information
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the customer
                          name:
                            type: string
                            description: Business name
                          address_1:
                            type: string
                            nullable: true
                            description: Primary address
                          address_2:
                            type: string
                            nullable: true
                            description: Secondary address
                          city:
                            type: string
                            nullable: true
                            description: City
                          state:
                            type: string
                            nullable: true
                            description: State/Province
                          zip:
                            type: string
                            nullable: true
                            description: Postal code
                          country:
                            type: string
                            nullable: true
                            description: Country
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                          email:
                            type: string
                            nullable: true
                            description: Email address
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when customer was last updated
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the line item
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                            sku:
                              type: string
                              description: Product SKU
                            name:
                              type: string
                              description: Product name
                            product_id:
                              type: integer
                              description: Product identifier
                            qty:
                              type: number
                              format: float
                              description: Quantity ordered
                            unit_price:
                              type: number
                              format: float
                              description: Price per unit
                            discount:
                              type: number
                              format: float
                              nullable: true
                              description: Discount amount
                            total:
                              type: number
                              format: float
                              description: Total line item amount
                            taxable:
                              type: boolean
                              description: Whether the line item is subject to sales tax. Defaults to true when not set.
                        description: Line items in the invoice
                      payments:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the payment
                            invoice_id:
                              type: integer
                              description: Associated invoice ID
                            gateway:
                              type: string
                              description: Payment gateway used
                            type:
                              type: string
                              description: Payment type
                            charge_type:
                              type: string
                              description: Type of charge
                            amount:
                              type: number
                              format: float
                              description: Payment amount
                            date:
                              type: string
                              format: date-time
                              description: Payment date
                            status:
                              type: string
                              description: Payment status
                            external_id:
                              type: string
                              nullable: true
                              description: External payment identifier
                            notes:
                              type: string
                              nullable: true
                              description: Payment notes
                            reference_id:
                              type: string
                              nullable: true
                              description: Reference identifier
                            gateway_response:
                              type: object
                              properties:
                                status:
                                  type: string
                                  description: Gateway response status
                                code:
                                  type: string
                                  description: Response code
                                message:
                                  type: string
                                  description: Response message
                                metadata:
                                  type: string
                                  description: Additional metadata
                              description: Payment gateway response details
                            created_by:
                              type: integer
                              nullable: true
                              description: User who created the payment
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when payment was last updated
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Soft delete timestamp
                        description: Payment records for the invoice
                      sales_order:
                        type: object
                        nullable: true
                        description: Sales order associated with the invoice (if any)
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the sales order
                          created_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was created
                          updated_at:
                            type: string
                            format: date-time
                            description: Timestamp when the order was last updated
                          status:
                            type: string
                            description: Current status of the order
                          order_id:
                            type: string
                            description: External order identifier
                          order_number:
                            type: string
                            description: Order number
                          order_date:
                            type: string
                            format: date
                            description: Date when the order was placed
                          payment_date:
                            type: string
                            format: date
                            description: Date when payment was received
                          ship_by_date:
                            type: string
                            format: date
                            description: Required ship by date
                          age:
                            type: integer
                            description: Age of the order in days
                          order_status:
                            type: string
                            description: Status of the order
                          customer_id:
                            type: string
                            description: Customer identifier
                          customer_username:
                            type: string
                            description: Customer's username
                          customer_email:
                            type: string
                            description: Customer's email address
                          bill_to:
                            type: object
                            description: Billing information
                          ship_to:
                            type: object
                            description: Shipping information
                          requested_shipping_service:
                            type: string
                            nullable: true
                            description: What shipping service to use when shipping this order
                          total:
                            type: number
                            format: float
                            description: Total order amount
                          total_paid:
                            type: number
                            format: float
                            description: Amount paid
                          total_tax:
                            type: number
                            format: float
                            description: Total tax amount
                          total_shipping:
                            type: number
                            format: float
                            description: Total shipping amount
                          customer_notes:
                            type: string
                            description: Notes from the customer
                          internal_notes:
                            type: string
                            description: Internal notes
                          ship_date:
                            type: string
                            format: date
                            description: Date when order was shipped
                          hold_until_date:
                            type: string
                            format: date
                            description: Hold until date
                          user_id:
                            type: integer
                            description: User ID associated with the order
                          externally_fulfilled:
                            type: boolean
                            description: Whether the order is fulfilled externally
                          externally_fulfilled_by:
                            type: string
                            description: Entity fulfilling the order externally
                          is_posted:
                            type: boolean
                            description: Whether the order is posted
                          posted_by:
                            type: string
                            description: User who posted the order
                          not_sync:
                            type: boolean
                            description: Sync status
                          sales_posted:
                            type: boolean
                            description: Sales posting status
                          split_order:
                            type: boolean
                            description: Whether the order is split
                          skip_inventory:
                            type: boolean
                            description: Whether to skip inventory
                          skip_sales_report:
                            type: boolean
                            description: Whether to skip sales report
                          channel_id:
                            type: integer
                            description: Channel identifier
                          total_order_cost:
                            type: number
                            format: float
                            description: Total cost of order
                          total_order_quantity:
                            type: number
                            format: float
                            description: Total quantity of items
                          order_cost_details:
                            type: object
                            description: Detailed order cost information
                          source:
                            type: string
                            description: Order source
                          shipstation_order_id:
                            type: string
                            description: ShipStation order identifier
                          type:
                            type: string
                            description: Order type
                          parent_id:
                            type: integer
                            description: Parent order ID if applicable
                          shipping_revenue:
                            type: number
                            format: float
                            description: Revenue from shipping
                          product_total:
                            type: number
                            format: float
                            description: Total product amount
                          total_discount:
                            type: number
                            format: float
                            description: Total discount amount
                          picking_status:
                            type: string
                            description: Status of picking process
                          starred_description:
                            type: string
                            description: Description for starred orders
                          customer_po_number:
                            type: string
                            description: Customer PO number
                      custom_fields:
                        type: object
                        description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Field Name 1: Some Value
                      tags:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                        description: Tags associated with the invoice
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: 'Not found, or the invoice is not an estimate'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /returns:
    get:
      operationId: listReturns
      tags:
        - Customer Returns
      summary: List customer returns
      description: |
        Paginated list of customer return orders, newest first (`id` descending).

        Soft-deleted returns are excluded by default. Pass `include_deleted=true` (alias `with_deleted`)
        to include them, or `only_deleted=true` to list only them; deleted returns carry `is_deleted: true`.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### Enum Filters
        - `status`: `Pending` or `Received`. Any other value returns `422`.

        ### Boolean Filters
        - `restock`: Whether receiving the return restocks inventory

        ### Integer Filters
        - `sales_order_id`: Originating sales order — matches returns linked directly to the sales order or through a refund order

        ### DateTime Filters
        - `created_at`: When the return was created
        - `updated_at`: When the return was last updated

        ## Examples
        ```
        # Pending returns for a sales order
        ?sales_order_id=12345&status=Pending

        # Returns created since a date, including soft-deleted ones
        ?created_at[gte]=2026-01-01&include_deleted=true
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 15
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 100
          description: 'Alias for `per_page`, used when `per_page` is not supplied.'
        - in: query
          name: status
          schema:
            type: string
            enum:
              - Pending
              - Received
          description: Filter by return status
        - in: query
          name: restock
          schema:
            type: boolean
          description: Filter by whether receiving the return restocks inventory
        - in: query
          name: sales_order_id
          schema:
            type: integer
          description: 'Filter by originating sales order (direct, or nested under a refund order)'
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: include_deleted
          schema:
            type: boolean
            default: false
          description: Include soft-deleted returns in the results. `with_deleted` is accepted as an alias.
        - in: query
          name: only_deleted
          schema:
            type: boolean
            default: false
          description: Return only soft-deleted returns. Takes precedence over `include_deleted`.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: 'A customer return for a sales order — return-only, refund-only, or return-and-refund. Status is `Pending` until received, then `Received`.'
                      properties:
                        id:
                          type: integer
                        sales_order_id:
                          type: integer
                          description: ID of the originating sales order. For return-and-refund flows the resolved sales order ID is read through the parent refund order.
                        status:
                          type: string
                          enum:
                            - Pending
                            - Received
                        restock:
                          type: boolean
                          description: 'When true, receiving the return puts stock back into inventory; false means stock is not adjusted (`skip_inventory` internally).'
                        order_date:
                          type: string
                          format: date
                          nullable: true
                        refund_amount:
                          type: number
                          description: 'Refund total stored on the return. Negative for returns created manually, positive for returns created from a channel refund. Stored value, not recalculated.'
                        refunded_shipping:
                          type: number
                          description: Shipping amount refunded on the return.
                        tax_amount:
                          type: number
                          description: Tax amount stored on the return.
                        amount_paid:
                          type: number
                          description: Amount paid stored on the return.
                        product_total:
                          type: number
                          description: Product total stored on the return.
                        refund_date:
                          type: string
                          format: date
                          nullable: true
                          description: Refund date. Same value as `order_date`.
                        transaction_type:
                          type: string
                          enum:
                            - return-only
                            - return-and-refund
                          description: Resolved from the parent order — return orders linked to a refund order surface as `return-and-refund`.
                        refund_id:
                          type: integer
                          nullable: true
                          description: 'ID of the refund order this return was created from (see `GET /refunds/{refundId}`). `null` on return-only returns.'
                        refund_total:
                          type: number
                          nullable: true
                          description: 'Total refunded on the linked refund order, as a positive number. Read from the refund order (the return''s own `refund_amount` is mostly `0` on channel returns). `null` on return-only returns.'
                        refund_tax:
                          type: number
                          nullable: true
                          description: 'Tax refunded on the linked refund order, as a positive number. `null` on return-only returns.'
                        refund_shipping:
                          type: number
                          nullable: true
                          description: 'Shipping refunded on the linked refund order. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                        refunded_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: 'When the channel recorded the linked refund. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                        is_deleted:
                          type: boolean
                          description: 'True when the return has been soft-deleted. Soft-deleted returns are hidden from `GET /returns` unless `include_deleted` or `only_deleted` is set, but remain readable via `GET /returns/{id}`.'
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        items:
                          type: array
                          description: Present when `orderItems` is loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              sales_order_item_id:
                                type: integer
                                description: Originating sales order line ID.
                              sku:
                                type: string
                                nullable: true
                              quantity:
                                type: number
                              unit_price:
                                type: number
                                description: Refund price stored on the return line. There is no separate line-total field.
                              refunded_shipping:
                                type: number
                                description: Shipping amount refunded on this line.
                              tax_amount:
                                type: number
                                description: Tax amount on this line.
                              discount:
                                type: number
                                description: Discount on this line.
                              refund_date:
                                type: string
                                format: date
                                nullable: true
                                description: Refund date of the return (same as the return's `order_date`).
                              refund_amount:
                                type: number
                                nullable: true
                                description: 'Money refunded for this line, from the matching line of the linked refund order (quantity × unit price, positive, rounded to cents). Matched by the channel line ID, or by SKU for lines without one. `null` on return-only returns or when no refund line matches.'
                              location_id:
                                type: integer
                                nullable: true
                              lot_id:
                                type: integer
                                nullable: true
                              external_restock_location_id:
                                type: string
                                nullable: true
                                description: 'Restock location chosen in the sales channel (e.g. the Shopify location ID) when the refund or return line was synced. This is the channel''s own location identifier, not a Luminous `location_id`, and is informational only — it does not determine where the item is restocked. `null` for returns created without a channel restock location.'
                              lot_number:
                                type: string
                                nullable: true
                                description: 'Lot number for the returned item (used on create when the product has lot tracking enabled; resolved to an existing lot, or created if missing).'
                              lot_name:
                                type: string
                                nullable: true
                                description: Alias for `lot_number`.
                  meta:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Invalid filter value (e.g. an unknown `status`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createReturn
      tags:
        - Customer Returns
      summary: Create customer return
      description: |
        Create a new customer return against an existing sales order. Use `transaction_type` to control whether a
        refund order is generated alongside the return:

        - `return-only` (default): just the return order
        - `refund-only`: refund only, no return order
        - `return-and-refund`: both, linked

        Returns are created in `Pending` status. Call `PATCH /returns/{id}/receive` to mark them received and
        (optionally) restock inventory.

        ## Retries and idempotency
        This endpoint accepts an optional `Idempotency-Key` request header, so a client that retries
        after a network timeout does not create the same return twice. Without the header, the request
        behaves as normal.
        - **Same key, same body**: the first response is replayed as-is (status, body, and an
          `Idempotent-Replay: true` response header). Only one return is created, however many
          times the request is resent.
        - **Same key, different body**: `409` with `code: idempotency_conflict`. Nothing is created.
        - **Same key, first request still in progress**: `409` until the first request finishes.

        Keys are kept for 24 hours and are scoped to your API token. The stored response is replayed
        whatever its status, including a `422`. After you fix a rejected request, resend it with a
        **new** key; reusing the old key returns the stored failure. Use one key per logical create
        (for example, your source system's order number) and keep it the same across retries.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: |
            Optional idempotency token. A retry with the same key and body replays the original
            stored response (with an `Idempotent-Replay: true` header) instead of creating a second
            return. Reusing the key with a different body returns `409`. Omit it to disable the guard.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sales_order_id
                - items
              properties:
                sales_order_id:
                  type: integer
                order_date:
                  type: string
                  format: date
                  nullable: true
                is_posted:
                  type: integer
                  enum:
                    - 0
                    - 1
                  nullable: true
                  description: 'Optional. When `1`, the return is created already received.'
                restock:
                  type: boolean
                  nullable: true
                  description: 'When true, inventory is restocked on receive (default behavior).'
                transaction_type:
                  type: string
                  enum:
                    - return-only
                    - refund-only
                    - return-and-refund
                  nullable: true
                items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - sales_order_item_id
                      - quantity
                    properties:
                      sales_order_item_id:
                        type: integer
                      quantity:
                        type: number
                        minimum: 0.001
                      uom_id:
                        type: integer
                        nullable: true
                      location_id:
                        type: integer
                        nullable: true
                      lot_id:
                        type: integer
                        nullable: true
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number for the returned item (used when the product has lot tracking enabled).
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A customer return for a sales order — return-only, refund-only, or return-and-refund. Status is `Pending` until received, then `Received`.'
                    properties:
                      id:
                        type: integer
                      sales_order_id:
                        type: integer
                        description: ID of the originating sales order. For return-and-refund flows the resolved sales order ID is read through the parent refund order.
                      status:
                        type: string
                        enum:
                          - Pending
                          - Received
                      restock:
                        type: boolean
                        description: 'When true, receiving the return puts stock back into inventory; false means stock is not adjusted (`skip_inventory` internally).'
                      order_date:
                        type: string
                        format: date
                        nullable: true
                      refund_amount:
                        type: number
                        description: 'Refund total stored on the return. Negative for returns created manually, positive for returns created from a channel refund. Stored value, not recalculated.'
                      refunded_shipping:
                        type: number
                        description: Shipping amount refunded on the return.
                      tax_amount:
                        type: number
                        description: Tax amount stored on the return.
                      amount_paid:
                        type: number
                        description: Amount paid stored on the return.
                      product_total:
                        type: number
                        description: Product total stored on the return.
                      refund_date:
                        type: string
                        format: date
                        nullable: true
                        description: Refund date. Same value as `order_date`.
                      transaction_type:
                        type: string
                        enum:
                          - return-only
                          - return-and-refund
                        description: Resolved from the parent order — return orders linked to a refund order surface as `return-and-refund`.
                      refund_id:
                        type: integer
                        nullable: true
                        description: 'ID of the refund order this return was created from (see `GET /refunds/{refundId}`). `null` on return-only returns.'
                      refund_total:
                        type: number
                        nullable: true
                        description: 'Total refunded on the linked refund order, as a positive number. Read from the refund order (the return''s own `refund_amount` is mostly `0` on channel returns). `null` on return-only returns.'
                      refund_tax:
                        type: number
                        nullable: true
                        description: 'Tax refunded on the linked refund order, as a positive number. `null` on return-only returns.'
                      refund_shipping:
                        type: number
                        nullable: true
                        description: 'Shipping refunded on the linked refund order. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                      refunded_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: 'When the channel recorded the linked refund. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                      is_deleted:
                        type: boolean
                        description: 'True when the return has been soft-deleted. Soft-deleted returns are hidden from `GET /returns` unless `include_deleted` or `only_deleted` is set, but remain readable via `GET /returns/{id}`.'
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      items:
                        type: array
                        description: Present when `orderItems` is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sales_order_item_id:
                              type: integer
                              description: Originating sales order line ID.
                            sku:
                              type: string
                              nullable: true
                            quantity:
                              type: number
                            unit_price:
                              type: number
                              description: Refund price stored on the return line. There is no separate line-total field.
                            refunded_shipping:
                              type: number
                              description: Shipping amount refunded on this line.
                            tax_amount:
                              type: number
                              description: Tax amount on this line.
                            discount:
                              type: number
                              description: Discount on this line.
                            refund_date:
                              type: string
                              format: date
                              nullable: true
                              description: Refund date of the return (same as the return's `order_date`).
                            refund_amount:
                              type: number
                              nullable: true
                              description: 'Money refunded for this line, from the matching line of the linked refund order (quantity × unit price, positive, rounded to cents). Matched by the channel line ID, or by SKU for lines without one. `null` on return-only returns or when no refund line matches.'
                            location_id:
                              type: integer
                              nullable: true
                            lot_id:
                              type: integer
                              nullable: true
                            external_restock_location_id:
                              type: string
                              nullable: true
                              description: 'Restock location chosen in the sales channel (e.g. the Shopify location ID) when the refund or return line was synced. This is the channel''s own location identifier, not a Luminous `location_id`, and is informational only — it does not determine where the item is restocked. `null` for returns created without a channel restock location.'
                            lot_number:
                              type: string
                              nullable: true
                              description: 'Lot number for the returned item (used on create when the product has lot tracking enabled; resolved to an existing lot, or created if missing).'
                            lot_name:
                              type: string
                              nullable: true
                              description: Alias for `lot_number`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: |
            Idempotency conflict: the `Idempotency-Key` is still being processed by an in-flight
            request, or was already used with a different request body. The body carries
            `code: idempotency_conflict` alongside `message`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Human-readable explanation of the conflict
                  code:
                    type: string
                    enum:
                      - idempotency_conflict
                    description: Machine-readable conflict code
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/returns/{id}':
    get:
      operationId: getReturn
      tags:
        - Customer Returns
      summary: Single customer return
      description: Retrieve a customer return by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Return order ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A customer return for a sales order — return-only, refund-only, or return-and-refund. Status is `Pending` until received, then `Received`.'
                    properties:
                      id:
                        type: integer
                      sales_order_id:
                        type: integer
                        description: ID of the originating sales order. For return-and-refund flows the resolved sales order ID is read through the parent refund order.
                      status:
                        type: string
                        enum:
                          - Pending
                          - Received
                      restock:
                        type: boolean
                        description: 'When true, receiving the return puts stock back into inventory; false means stock is not adjusted (`skip_inventory` internally).'
                      order_date:
                        type: string
                        format: date
                        nullable: true
                      refund_amount:
                        type: number
                        description: 'Refund total stored on the return. Negative for returns created manually, positive for returns created from a channel refund. Stored value, not recalculated.'
                      refunded_shipping:
                        type: number
                        description: Shipping amount refunded on the return.
                      tax_amount:
                        type: number
                        description: Tax amount stored on the return.
                      amount_paid:
                        type: number
                        description: Amount paid stored on the return.
                      product_total:
                        type: number
                        description: Product total stored on the return.
                      refund_date:
                        type: string
                        format: date
                        nullable: true
                        description: Refund date. Same value as `order_date`.
                      transaction_type:
                        type: string
                        enum:
                          - return-only
                          - return-and-refund
                        description: Resolved from the parent order — return orders linked to a refund order surface as `return-and-refund`.
                      refund_id:
                        type: integer
                        nullable: true
                        description: 'ID of the refund order this return was created from (see `GET /refunds/{refundId}`). `null` on return-only returns.'
                      refund_total:
                        type: number
                        nullable: true
                        description: 'Total refunded on the linked refund order, as a positive number. Read from the refund order (the return''s own `refund_amount` is mostly `0` on channel returns). `null` on return-only returns.'
                      refund_tax:
                        type: number
                        nullable: true
                        description: 'Tax refunded on the linked refund order, as a positive number. `null` on return-only returns.'
                      refund_shipping:
                        type: number
                        nullable: true
                        description: 'Shipping refunded on the linked refund order. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                      refunded_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: 'When the channel recorded the linked refund. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                      is_deleted:
                        type: boolean
                        description: 'True when the return has been soft-deleted. Soft-deleted returns are hidden from `GET /returns` unless `include_deleted` or `only_deleted` is set, but remain readable via `GET /returns/{id}`.'
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      items:
                        type: array
                        description: Present when `orderItems` is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sales_order_item_id:
                              type: integer
                              description: Originating sales order line ID.
                            sku:
                              type: string
                              nullable: true
                            quantity:
                              type: number
                            unit_price:
                              type: number
                              description: Refund price stored on the return line. There is no separate line-total field.
                            refunded_shipping:
                              type: number
                              description: Shipping amount refunded on this line.
                            tax_amount:
                              type: number
                              description: Tax amount on this line.
                            discount:
                              type: number
                              description: Discount on this line.
                            refund_date:
                              type: string
                              format: date
                              nullable: true
                              description: Refund date of the return (same as the return's `order_date`).
                            refund_amount:
                              type: number
                              nullable: true
                              description: 'Money refunded for this line, from the matching line of the linked refund order (quantity × unit price, positive, rounded to cents). Matched by the channel line ID, or by SKU for lines without one. `null` on return-only returns or when no refund line matches.'
                            location_id:
                              type: integer
                              nullable: true
                            lot_id:
                              type: integer
                              nullable: true
                            external_restock_location_id:
                              type: string
                              nullable: true
                              description: 'Restock location chosen in the sales channel (e.g. the Shopify location ID) when the refund or return line was synced. This is the channel''s own location identifier, not a Luminous `location_id`, and is informational only — it does not determine where the item is restocked. `null` for returns created without a channel restock location.'
                            lot_number:
                              type: string
                              nullable: true
                              description: 'Lot number for the returned item (used on create when the product has lot tracking enabled; resolved to an existing lot, or created if missing).'
                            lot_name:
                              type: string
                              nullable: true
                              description: Alias for `lot_number`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Return not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteReturn
      tags:
        - Customer Returns
      summary: Delete customer return
      description: Delete a return order. Reverses any inventory effect from a previously received return when applicable. Deleting a return that is already deleted returns `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Return order deleted successfully
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Return not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Return already deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/returns/{id}/receive':
    patch:
      operationId: receiveReturn
      tags:
        - Customer Returns
      summary: Mark return received
      description: |
        Transition a return from `Pending` to `Received`. If `restock` is true on the return, inventory is put back
        into stock at this point (using each line's `location_id`/`lot_id`, falling back to the originating
        fulfillment line's warehouse). If `restock` is false, no inventory adjustment is made.

        A deleted return cannot be received and returns `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Return order ID
      responses:
        '200':
          description: Received
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A customer return for a sales order — return-only, refund-only, or return-and-refund. Status is `Pending` until received, then `Received`.'
                    properties:
                      id:
                        type: integer
                      sales_order_id:
                        type: integer
                        description: ID of the originating sales order. For return-and-refund flows the resolved sales order ID is read through the parent refund order.
                      status:
                        type: string
                        enum:
                          - Pending
                          - Received
                      restock:
                        type: boolean
                        description: 'When true, receiving the return puts stock back into inventory; false means stock is not adjusted (`skip_inventory` internally).'
                      order_date:
                        type: string
                        format: date
                        nullable: true
                      refund_amount:
                        type: number
                        description: 'Refund total stored on the return. Negative for returns created manually, positive for returns created from a channel refund. Stored value, not recalculated.'
                      refunded_shipping:
                        type: number
                        description: Shipping amount refunded on the return.
                      tax_amount:
                        type: number
                        description: Tax amount stored on the return.
                      amount_paid:
                        type: number
                        description: Amount paid stored on the return.
                      product_total:
                        type: number
                        description: Product total stored on the return.
                      refund_date:
                        type: string
                        format: date
                        nullable: true
                        description: Refund date. Same value as `order_date`.
                      transaction_type:
                        type: string
                        enum:
                          - return-only
                          - return-and-refund
                        description: Resolved from the parent order — return orders linked to a refund order surface as `return-and-refund`.
                      refund_id:
                        type: integer
                        nullable: true
                        description: 'ID of the refund order this return was created from (see `GET /refunds/{refundId}`). `null` on return-only returns.'
                      refund_total:
                        type: number
                        nullable: true
                        description: 'Total refunded on the linked refund order, as a positive number. Read from the refund order (the return''s own `refund_amount` is mostly `0` on channel returns). `null` on return-only returns.'
                      refund_tax:
                        type: number
                        nullable: true
                        description: 'Tax refunded on the linked refund order, as a positive number. `null` on return-only returns.'
                      refund_shipping:
                        type: number
                        nullable: true
                        description: 'Shipping refunded on the linked refund order. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                      refunded_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: 'When the channel recorded the linked refund. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                      is_deleted:
                        type: boolean
                        description: 'True when the return has been soft-deleted. Soft-deleted returns are hidden from `GET /returns` unless `include_deleted` or `only_deleted` is set, but remain readable via `GET /returns/{id}`.'
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      items:
                        type: array
                        description: Present when `orderItems` is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sales_order_item_id:
                              type: integer
                              description: Originating sales order line ID.
                            sku:
                              type: string
                              nullable: true
                            quantity:
                              type: number
                            unit_price:
                              type: number
                              description: Refund price stored on the return line. There is no separate line-total field.
                            refunded_shipping:
                              type: number
                              description: Shipping amount refunded on this line.
                            tax_amount:
                              type: number
                              description: Tax amount on this line.
                            discount:
                              type: number
                              description: Discount on this line.
                            refund_date:
                              type: string
                              format: date
                              nullable: true
                              description: Refund date of the return (same as the return's `order_date`).
                            refund_amount:
                              type: number
                              nullable: true
                              description: 'Money refunded for this line, from the matching line of the linked refund order (quantity × unit price, positive, rounded to cents). Matched by the channel line ID, or by SKU for lines without one. `null` on return-only returns or when no refund line matches.'
                            location_id:
                              type: integer
                              nullable: true
                            lot_id:
                              type: integer
                              nullable: true
                            external_restock_location_id:
                              type: string
                              nullable: true
                              description: 'Restock location chosen in the sales channel (e.g. the Shopify location ID) when the refund or return line was synced. This is the channel''s own location identifier, not a Luminous `location_id`, and is informational only — it does not determine where the item is restocked. `null` for returns created without a channel restock location.'
                            lot_number:
                              type: string
                              nullable: true
                              description: 'Lot number for the returned item (used on create when the product has lot tracking enabled; resolved to an existing lot, or created if missing).'
                            lot_name:
                              type: string
                              nullable: true
                              description: Alias for `lot_number`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Return not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Cannot receive (e.g. already received, or the return has been deleted)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/returns/{id}/restock':
    patch:
      operationId: updateReturnRestockFlag
      tags:
        - Customer Returns
      summary: Update return restock flag
      description: |
        Toggle whether receiving this return will restock inventory. `restock=true` means stock is put back on
        receive; `restock=false` means it is not (`skip_inventory` internally).

        A deleted return cannot be updated and returns `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Return order ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - restock
              properties:
                restock:
                  type: boolean
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A customer return for a sales order — return-only, refund-only, or return-and-refund. Status is `Pending` until received, then `Received`.'
                    properties:
                      id:
                        type: integer
                      sales_order_id:
                        type: integer
                        description: ID of the originating sales order. For return-and-refund flows the resolved sales order ID is read through the parent refund order.
                      status:
                        type: string
                        enum:
                          - Pending
                          - Received
                      restock:
                        type: boolean
                        description: 'When true, receiving the return puts stock back into inventory; false means stock is not adjusted (`skip_inventory` internally).'
                      order_date:
                        type: string
                        format: date
                        nullable: true
                      refund_amount:
                        type: number
                        description: 'Refund total stored on the return. Negative for returns created manually, positive for returns created from a channel refund. Stored value, not recalculated.'
                      refunded_shipping:
                        type: number
                        description: Shipping amount refunded on the return.
                      tax_amount:
                        type: number
                        description: Tax amount stored on the return.
                      amount_paid:
                        type: number
                        description: Amount paid stored on the return.
                      product_total:
                        type: number
                        description: Product total stored on the return.
                      refund_date:
                        type: string
                        format: date
                        nullable: true
                        description: Refund date. Same value as `order_date`.
                      transaction_type:
                        type: string
                        enum:
                          - return-only
                          - return-and-refund
                        description: Resolved from the parent order — return orders linked to a refund order surface as `return-and-refund`.
                      refund_id:
                        type: integer
                        nullable: true
                        description: 'ID of the refund order this return was created from (see `GET /refunds/{refundId}`). `null` on return-only returns.'
                      refund_total:
                        type: number
                        nullable: true
                        description: 'Total refunded on the linked refund order, as a positive number. Read from the refund order (the return''s own `refund_amount` is mostly `0` on channel returns). `null` on return-only returns.'
                      refund_tax:
                        type: number
                        nullable: true
                        description: 'Tax refunded on the linked refund order, as a positive number. `null` on return-only returns.'
                      refund_shipping:
                        type: number
                        nullable: true
                        description: 'Shipping refunded on the linked refund order. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                      refunded_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: 'When the channel recorded the linked refund. `null` on return-only returns, and for refunds synced before refund capture was enabled for the tenant.'
                      is_deleted:
                        type: boolean
                        description: 'True when the return has been soft-deleted. Soft-deleted returns are hidden from `GET /returns` unless `include_deleted` or `only_deleted` is set, but remain readable via `GET /returns/{id}`.'
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      items:
                        type: array
                        description: Present when `orderItems` is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sales_order_item_id:
                              type: integer
                              description: Originating sales order line ID.
                            sku:
                              type: string
                              nullable: true
                            quantity:
                              type: number
                            unit_price:
                              type: number
                              description: Refund price stored on the return line. There is no separate line-total field.
                            refunded_shipping:
                              type: number
                              description: Shipping amount refunded on this line.
                            tax_amount:
                              type: number
                              description: Tax amount on this line.
                            discount:
                              type: number
                              description: Discount on this line.
                            refund_date:
                              type: string
                              format: date
                              nullable: true
                              description: Refund date of the return (same as the return's `order_date`).
                            refund_amount:
                              type: number
                              nullable: true
                              description: 'Money refunded for this line, from the matching line of the linked refund order (quantity × unit price, positive, rounded to cents). Matched by the channel line ID, or by SKU for lines without one. `null` on return-only returns or when no refund line matches.'
                            location_id:
                              type: integer
                              nullable: true
                            lot_id:
                              type: integer
                              nullable: true
                            external_restock_location_id:
                              type: string
                              nullable: true
                              description: 'Restock location chosen in the sales channel (e.g. the Shopify location ID) when the refund or return line was synced. This is the channel''s own location identifier, not a Luminous `location_id`, and is informational only — it does not determine where the item is restocked. `null` for returns created without a channel restock location.'
                            lot_number:
                              type: string
                              nullable: true
                              description: 'Lot number for the returned item (used on create when the product has lot tracking enabled; resolved to an existing lot, or created if missing).'
                            lot_name:
                              type: string
                              nullable: true
                              description: Alias for `lot_number`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Return not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or the return has been deleted'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /refunds:
    get:
      operationId: listRefunds
      tags:
        - Customer Returns
      summary: List refunds
      description: |
        Paginated list of refund orders, newest first (`id` descending). A refund order is the money side of a
        channel (e.g. Shopify) or manual refund under a sales order: total refunded, tax, shipping, the refund
        date and the refunded lines. Refunds that have no customer return (for example a shipping-only refund)
        are included.

        Each refund carries `return_ids`, the customer returns created from it; the matching returns in
        `GET /returns` carry `refund_id` and the same money fields. Superseded copies of a refund (Luminous
        rebuilds the refund-order row whenever the channel changes the refund) are excluded.

        `refund_shipping` and `refunded_at` are `null` for refunds synced before refund capture was enabled for
        the tenant.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### Integer Filters
        - `sales_order_id`: The sales order the refund belongs to

        ### DateTime Filters
        - `refunded_at`: When the channel recorded the refund
        - `created_at`: When the refund order was created in Luminous
        - `updated_at`: When the refund order was last updated

        ## Examples
        ```
        # Refunds for a sales order
        ?sales_order_id=12345

        # Refunds recorded since a date
        ?refunded_at[gte]=2026-01-01
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 15
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 100
          description: 'Alias for `per_page`, used when `per_page` is not supplied.'
        - in: query
          name: sales_order_id
          schema:
            type: integer
          description: Filter by the sales order the refund belongs to
        - in: query
          name: refunded_at
          schema:
            type: string
            format: date-time
          description: Filter by refund date
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A refund order under a sales order — a channel (e.g. Shopify) or manual refund, with or without a
                        linked customer return. Money fields are the amount refunded, as positive numbers.
                      properties:
                        id:
                          type: integer
                          description: 'Refund order ID. Luminous rebuilds the refund-order row whenever the channel changes the refund, so this can change; use `external_refund_id` as the stable key.'
                        sales_order_id:
                          type: integer
                          description: ID of the sales order the refund belongs to.
                        order_number:
                          type: string
                          nullable: true
                          description: Order number carried on the refund order (the sales order's number).
                        external_refund_id:
                          type: string
                          nullable: true
                          description: The source system's refund identifier (e.g. the Shopify refund ID). Stable across rebuilds of the refund-order row.
                        order_status:
                          type: string
                          nullable: true
                        refund_total:
                          type: number
                          description: 'Total amount refunded, as a positive number.'
                        refund_tax:
                          type: number
                          description: 'Tax refunded, as a positive number.'
                        refund_shipping:
                          type: number
                          nullable: true
                          description: Shipping refunded. `null` for refunds synced before refund capture was enabled for the tenant.
                        refunded_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: When the channel recorded the refund. `null` for refunds synced before refund capture was enabled for the tenant.
                        currency_code:
                          type: string
                          nullable: true
                        return_ids:
                          type: array
                          description: IDs of the active customer returns created from this refund. Empty for a refund with no return.
                          items:
                            type: integer
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        items:
                          type: array
                          description: Refunded lines. A refund that moves money without lines (e.g. a shipping-only refund) has an empty array.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              sales_order_item_id:
                                type: integer
                                nullable: true
                                description: 'The sales-order line this refund line was matched to, or `null` when unmatched.'
                              sku:
                                type: string
                                nullable: true
                              quantity:
                                type: number
                              refund_amount:
                                type: number
                                description: 'Money refunded for this line (quantity × unit price), as a positive number rounded to cents.'
                              tax_amount:
                                type: number
                                description: 'Tax refunded on this line, as a positive number.'
                  meta:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/refunds/{refundId}':
    get:
      operationId: getRefund
      tags:
        - Customer Returns
      summary: Single refund
      description: |
        Retrieve a refund order by ID, with its money fields and refunded lines. Superseded copies of a refund
        are not returned (`404`); list `GET /refunds` for the current row, or match on `external_refund_id`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: refundId
          required: true
          schema:
            type: integer
          description: Refund order ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A refund order under a sales order — a channel (e.g. Shopify) or manual refund, with or without a
                      linked customer return. Money fields are the amount refunded, as positive numbers.
                    properties:
                      id:
                        type: integer
                        description: 'Refund order ID. Luminous rebuilds the refund-order row whenever the channel changes the refund, so this can change; use `external_refund_id` as the stable key.'
                      sales_order_id:
                        type: integer
                        description: ID of the sales order the refund belongs to.
                      order_number:
                        type: string
                        nullable: true
                        description: Order number carried on the refund order (the sales order's number).
                      external_refund_id:
                        type: string
                        nullable: true
                        description: The source system's refund identifier (e.g. the Shopify refund ID). Stable across rebuilds of the refund-order row.
                      order_status:
                        type: string
                        nullable: true
                      refund_total:
                        type: number
                        description: 'Total amount refunded, as a positive number.'
                      refund_tax:
                        type: number
                        description: 'Tax refunded, as a positive number.'
                      refund_shipping:
                        type: number
                        nullable: true
                        description: Shipping refunded. `null` for refunds synced before refund capture was enabled for the tenant.
                      refunded_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When the channel recorded the refund. `null` for refunds synced before refund capture was enabled for the tenant.
                      currency_code:
                        type: string
                        nullable: true
                      return_ids:
                        type: array
                        description: IDs of the active customer returns created from this refund. Empty for a refund with no return.
                        items:
                          type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      items:
                        type: array
                        description: Refunded lines. A refund that moves money without lines (e.g. a shipping-only refund) has an empty array.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'The sales-order line this refund line was matched to, or `null` when unmatched.'
                            sku:
                              type: string
                              nullable: true
                            quantity:
                              type: number
                            refund_amount:
                              type: number
                              description: 'Money refunded for this line (quantity × unit price), as a positive number rounded to cents.'
                            tax_amount:
                              type: number
                              description: 'Tax refunded on this line, as a positive number.'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Refund not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: Refund not found.
  '/{recordType}/{recordId}/tags':
    get:
      operationId: getRecordTags
      tags:
        - Tags
      summary: Get tags for a record
      description: |
        Retrieve all tags associated with a specific record.
        Supported record types: `sales-orders`,`sales-order-items`,`invoices`,`products`
        For `products`, any SKU type works, including kits and non-inventory SKUs.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: recordType
          required: true
          schema:
            type: string
            enum:
              - sales-orders
              - sales-order-items
              - invoices
              - products
          description: Type of record to get tags for
        - in: path
          name: recordId
          required: true
          schema:
            type: integer
          description: ID of the record
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the tag
                        name:
                          type: string
                          description: Name of the tag
                        description:
                          type: string
                          nullable: true
                          description: Description of the tag
                        icon:
                          type: string
                          nullable: true
                          description: Icon identifier or URL for the tag
                        color:
                          type: string
                          nullable: true
                          description: Color code for the tag
                      required:
                        - id
                        - name
        '400':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: attachTag
      tags:
        - Tags
      summary: Attach tags to a record
      description: |
        Attach one or more tags to a specific record.
        Supported record types: `sales-orders`,`sales-order-items`,`invoices`,`products`
        For `products`, any SKU type works, including kits and non-inventory SKUs.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: recordType
          required: true
          schema:
            type: string
            enum:
              - sales-orders
              - sales-order-items
              - invoices
              - products
          description: Type of record to attach tags to
        - in: path
          name: recordId
          required: true
          schema:
            type: integer
          description: ID of the record
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              oneOf:
                - required:
                    - tag
                  properties:
                    tag:
                      type: string
                      description: Single tag to attach
                - required:
                    - tags
                  properties:
                    tags:
                      type: array
                      items:
                        type: string
                      description: Multiple tags to attach
      responses:
        '201':
          description: Tag(s) attached successfully
        '400':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: replaceTags
      tags:
        - Tags
      summary: Replace all tags on a record
      description: |
        Replace all existing tags on a record with a new set of tags.
        Supported record types: `sales-orders`,`sales-order-items`,`invoices`,`products`
        For `products`, any SKU type works, including kits and non-inventory SKUs.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: recordType
          required: true
          schema:
            type: string
            enum:
              - sales-orders
              - sales-order-items
              - invoices
              - products
          description: Type of record to replace tags on
        - in: path
          name: recordId
          required: true
          schema:
            type: integer
          description: ID of the record
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - tags
              properties:
                tags:
                  type: array
                  items:
                    type: string
                  description: New set of tags to replace existing ones with
      responses:
        '200':
          description: Tags replaced successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Tags replaced successfully
                  tags:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the tag
                        name:
                          type: string
                          description: Name of the tag
                        description:
                          type: string
                          nullable: true
                          description: Description of the tag
                        icon:
                          type: string
                          nullable: true
                          description: Icon identifier or URL for the tag
                        color:
                          type: string
                          nullable: true
                          description: Color code for the tag
                      required:
                        - id
                        - name
        '400':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/{recordType}/{recordId}/tags/{id}':
    delete:
      operationId: detachTag
      tags:
        - Tags
      summary: Detach a tag from a record
      description: |
        Remove a specific tag from a record.
        Supported record types: `sales-orders`,`sales-order-items`,`invoices`,`products`
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: recordType
          required: true
          schema:
            type: string
            enum:
              - sales-orders
              - sales-order-items
              - invoices
              - products
          description: Type of record to detach tag from
        - in: path
          name: recordId
          required: true
          schema:
            type: integer
          description: ID of the record
        - in: path
          name: id
          required: true
          schema:
            oneOf:
              - type: string
              - type: integer
          description: Tag name or ID to detach
      responses:
        '204':
          description: Tag detached successfully
        '400':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /account:
    get:
      operationId: getAccount
      tags:
        - Account
      summary: Account company profile
      description: |
        Get your Luminous account's own company details: the company name, address, phone number and
        logo set under **Settings > My Profile** (what prints on your invoices and purchase orders).
        These are not customer companies; use `GET /companies` for those.

        Read-only. Blank fields come back as `null`. Other profile settings (such as accounting email
        or payment link) are not returned.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Company profile
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      company_name:
                        type: string
                        nullable: true
                        description: 'Company name, or `null` when not set'
                        example: Acme Outdoor Co.
                      address:
                        type: string
                        nullable: true
                        description: 'Company address as entered (may contain line breaks), or `null` when not set'
                        example: |-
                          123 Main St
                          Denver, CO 80202
                      phone:
                        type: string
                        nullable: true
                        description: 'Company phone number, or `null` when not set'
                        example: (303) 555-0142
                      logo_url:
                        type: string
                        format: uri
                        nullable: true
                        description: |
                          Signed URL for the company logo, valid for 60 minutes. Request the endpoint
                          again for a fresh URL. `null` when no logo is set or the URL cannot be generated.
                        example: 'https://example-bucket.s3.amazonaws.com/company-logo/1234_logo.png?X-Amz-Signature=...'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /users:
    get:
      operationId: getUsers
      tags:
        - Users
      summary: Users
      description: |
        List the staff users on your Luminous account, sorted by first and last name. Use it to
        resolve user IDs that appear elsewhere in the API (for example `picked_by_user` on picklists)
        to a name, email and role.

        Returns active users by default; pass `status=inactive` or `status=all` to include
        deactivated and removed users. The internal Luminous support user is never listed.

        Read-only. Passwords, one-time codes and API tokens are never returned. The list is not
        paginated. Requires the staff read (`staff.read`) permission; tokens without it get `403`.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: status
          required: false
          schema:
            type: string
            enum:
              - active
              - inactive
              - all
            default: active
          description: |
            `active` (default) returns users with status `1`. `inactive` returns every other status,
            removed users included. `all` returns both.
      responses:
        '200':
          description: List of users
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        name:
                          type: string
                          description: Full name
                        first_name:
                          type: string
                          nullable: true
                        last_name:
                          type: string
                          nullable: true
                        email:
                          type: string
                          nullable: true
                          description: Email address. `null` when the API token is restricted from personal data (PII).
                        role:
                          type: string
                          description: Base account role
                          enum:
                            - Super Admin
                            - Admin
                            - Factory Admin
                            - Sales
                            - Staff
                        roles:
                          type: array
                          description: Names of the permission roles assigned to the user
                          items:
                            type: string
                        status:
                          type: integer
                          description: 'Account status code. `1` is active; any other value (including `-1`, removed) is inactive.'
                        last_login_at:
                          type: string
                          nullable: true
                          description: 'When the user last logged in, or `null` if never'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's user lacks the staff read permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Invalid `status` value
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/users/{userId}':
    get:
      operationId: getUser
      tags:
        - Users
      summary: User
      description: |
        Get one staff user by ID, in any status (active, inactive or removed). Same fields as
        `GET /users`. Requires the staff read (`staff.read`) permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: userId
          required: true
          schema:
            type: integer
          description: The user ID
      responses:
        '200':
          description: The user
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      name:
                        type: string
                        description: Full name
                      first_name:
                        type: string
                        nullable: true
                      last_name:
                        type: string
                        nullable: true
                      email:
                        type: string
                        nullable: true
                        description: Email address. `null` when the API token is restricted from personal data (PII).
                      role:
                        type: string
                        description: Base account role
                        enum:
                          - Super Admin
                          - Admin
                          - Factory Admin
                          - Sales
                          - Staff
                      roles:
                        type: array
                        description: Names of the permission roles assigned to the user
                        items:
                          type: string
                      status:
                        type: integer
                        description: 'Account status code. `1` is active; any other value (including `-1`, removed) is inactive.'
                      last_login_at:
                        type: string
                        nullable: true
                        description: 'When the user last logged in, or `null` if never'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's user lacks the staff read permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: No user with that ID
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /notification-settings:
    get:
      operationId: getNotificationSettings
      tags:
        - Notification Settings
      summary: Get notification settings
      description: |
        Returns the staff users who receive the daily Low Quantity Products Notification email
        (products below their Low Stock Alert Quantity). This is the same setting as
        **Settings › Notifications** in the app, so recipients set there show here and the reverse.

        Each recipient has the same shape as a user from `GET /users`. Requires the staff read
        (`staff.read`) permission; tokens without it get `403`.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Current notification settings
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      low_quantity_recipients:
                        type: array
                        description: Staff users who receive the daily Low Quantity Products Notification email
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              description: Full name
                            first_name:
                              type: string
                              nullable: true
                            last_name:
                              type: string
                              nullable: true
                            email:
                              type: string
                              nullable: true
                              description: Email address. `null` when the API token is restricted from personal data (PII).
                            role:
                              type: string
                              description: Base account role
                              enum:
                                - Super Admin
                                - Admin
                                - Factory Admin
                                - Sales
                                - Staff
                            roles:
                              type: array
                              description: Names of the permission roles assigned to the user
                              items:
                                type: string
                            status:
                              type: integer
                              description: 'Account status code. `1` is active; any other value (including `-1`, removed) is inactive.'
                            last_login_at:
                              type: string
                              nullable: true
                              description: 'When the user last logged in, or `null` if never'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's user lacks the staff read permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateNotificationSettings
      tags:
        - Notification Settings
      summary: Update notification settings
      description: |
        Partial update: only the fields you send are written, and no other account setting changes.
        Returns the saved settings.

        `low_quantity_recipients` replaces the whole recipient list. Give each recipient as a user
        `id` or `email` from `GET /users`. Every recipient must be an active staff user. An unknown
        or inactive recipient, a `null` list, or any field other than `low_quantity_recipients`
        returns `422` and nothing is saved. Send `[]` to clear the list.

        Requires the staff read (`staff.read`) permission; tokens without it get `403`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                low_quantity_recipients:
                  type: array
                  description: |
                    The complete new list of low-stock email recipients, each a user id (integer) or
                    email address. Duplicates are saved once.
                  items:
                    oneOf:
                      - type: integer
                      - type: string
                        format: email
                  example:
                    - 12
                    - jane@example.com
      responses:
        '200':
          description: The saved notification settings
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      low_quantity_recipients:
                        type: array
                        description: Staff users who receive the daily Low Quantity Products Notification email
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              description: Full name
                            first_name:
                              type: string
                              nullable: true
                            last_name:
                              type: string
                              nullable: true
                            email:
                              type: string
                              nullable: true
                              description: Email address. `null` when the API token is restricted from personal data (PII).
                            role:
                              type: string
                              description: Base account role
                              enum:
                                - Super Admin
                                - Admin
                                - Factory Admin
                                - Sales
                                - Staff
                            roles:
                              type: array
                              description: Names of the permission roles assigned to the user
                              items:
                                type: string
                            status:
                              type: integer
                              description: 'Account status code. `1` is active; any other value (including `-1`, removed) is inactive.'
                            last_login_at:
                              type: string
                              nullable: true
                              description: 'When the user last logged in, or `null` if never'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's user lacks the staff read permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            A recipient is not an active staff user (error key `low_quantity_recipients.<index>`),
            `low_quantity_recipients` is not an array, or an unknown field was sent. Nothing is saved.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /custom-fields:
    get:
      operationId: getCustomFieldDefinitions
      tags:
        - Custom Fields
      summary: Get custom field definitions
      description: |
        List all custom field definitions (schema). Optionally filter to only the
        fields applicable to a specific entity type.

        This endpoint returns the **schema** of custom fields (label, type, options,
        which entity types they apply to). To read or write **values** on a specific
        record, use `/{recordType}/{recordId}/custom-fields`.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: object_type
          required: false
          schema:
            type: string
          description: |
            Return only fields linked to this entity type (e.g. `sales-orders`,
            `products`, `companies`). Accepts logical names as well as morph-map
            aliases. For products, `product`, `products` and `rfq` are equivalent.
            If omitted, returns all definitions.
      responses:
        '200':
          description: A list of custom field definitions
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the custom field definition
                          example: 123
                        label:
                          type: string
                          description: Display label for the custom field (unique across definitions)
                          example: Industry
                        type:
                          type: string
                          description: |
                            Data type of the custom field. `multi_dropdown` allows selecting multiple
                            values from the `choices` list (values are stored and returned as an array).
                          enum:
                            - number
                            - date
                            - string
                            - dropdown
                            - multi_dropdown
                          example: dropdown
                        options:
                          type: object
                          nullable: true
                          description: |
                            Optional configuration for the field. Common keys:
                            - `choices` (array, required for `type: dropdown` and `type: multi_dropdown`) — the selectable values
                            - `minLength` (integer) — minimum length for string input
                            - `maxLength` (integer) — maximum length for string input
                            - `helpText` (string, max 500) — help text shown in the UI
                            - `pattern` (string, max 500) — regular expression (no delimiters) that non-blank `string` values must match
                            - `patternHint` (string, max 500) — error message returned when a value does not match `pattern`
                          properties:
                            choices:
                              type: array
                              description: Selectable values for `dropdown` and `multi_dropdown` fields
                              items:
                                oneOf:
                                  - type: string
                                  - type: number
                              example:
                                - Retail
                                - Wholesale
                                - DTC
                            minLength:
                              type: integer
                              minimum: 0
                              example: 0
                            maxLength:
                              type: integer
                              minimum: 1
                              example: 255
                            helpText:
                              type: string
                              maxLength: 500
                              example: Choose the primary sales channel
                            pattern:
                              type: string
                              nullable: true
                              maxLength: 500
                              description: |
                                `string` fields only. Regular expression (written without delimiters,
                                e.g. `^[A-Z]{3}-\d{4}$`) that non-blank values must match. An invalid
                                regular expression is rejected with `422` when the definition is saved.
                                Values that do not match are rejected with `422` when written to a record.
                              example: '^[A-Z]{3}-\d{4}$'
                            patternHint:
                              type: string
                              nullable: true
                              maxLength: 500
                              description: |
                                Error message returned when a value does not match `pattern`. Defaults to
                                "Field '<label>' does not match the required pattern".
                              example: 'Use three capital letters, a dash, and four digits (e.g. ABC-1234)'
                          additionalProperties: true
                        category:
                          type: string
                          nullable: true
                          description: |
                            Optional free-text category label used to group custom field definitions
                            (e.g. for SKU grouping in the UI). `null` when unset.
                          example: Merchandising
                        object_types:
                          type: array
                          description: 'Entity types this custom field applies to (e.g. `sales-orders`, `products`)'
                          items:
                            type: string
                          example:
                            - companies
                            - products
                        created_at:
                          type: string
                          format: date-time
                          example: '2026-04-20T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          example: '2026-04-20T14:30:00Z'
                      required:
                        - id
                        - label
                        - type
                        - object_types
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '422':
          description: Invalid `object_type` filter
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createCustomFieldDefinition
      tags:
        - Custom Fields
      summary: Create a custom field definition
      description: |
        Create a new custom field definition.

        Dropdown fields (`type: dropdown` or `type: multi_dropdown`) require a
        non-empty `options.choices` array. A `multi_dropdown` field accepts multiple
        selected values (stored and returned as an array); a `dropdown` accepts a
        single value.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                  maxLength: 255
                  description: Display label for the custom field. Must be unique across definitions.
                  example: Industry
                type:
                  type: string
                  description: |
                    Data type of the custom field. `multi_dropdown` allows selecting multiple
                    values from the `choices` list (values are stored as an array).
                  enum:
                    - number
                    - date
                    - string
                    - dropdown
                    - multi_dropdown
                  example: dropdown
                options:
                  type: object
                  nullable: true
                  description: |
                    Optional configuration for the field. Required when `type` is `dropdown`
                    or `multi_dropdown` (must include a non-empty `choices` array).
                  properties:
                    choices:
                      type: array
                      description: Selectable values; required when `type` is `dropdown` or `multi_dropdown`
                      items:
                        oneOf:
                          - type: string
                          - type: number
                      example:
                        - Retail
                        - Wholesale
                        - DTC
                    minLength:
                      type: integer
                      minimum: 0
                      example: 0
                    maxLength:
                      type: integer
                      minimum: 1
                      example: 255
                    helpText:
                      type: string
                      maxLength: 500
                      example: Choose the primary sales channel
                    pattern:
                      type: string
                      nullable: true
                      maxLength: 500
                      description: |
                        `string` fields only. Regular expression (written without delimiters,
                        e.g. `^[A-Z]{3}-\d{4}$`) that non-blank values must match. An invalid
                        regular expression is rejected with `422` when the definition is saved.
                        Values that do not match are rejected with `422` when written to a record.
                      example: '^[A-Z]{3}-\d{4}$'
                    patternHint:
                      type: string
                      nullable: true
                      maxLength: 500
                      description: |
                        Error message returned when a value does not match `pattern`. Defaults to
                        "Field '<label>' does not match the required pattern".
                      example: 'Use three capital letters, a dash, and four digits (e.g. ABC-1234)'
                  additionalProperties: true
                category:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: |
                    Optional free-text category label used to group custom field definitions
                    (e.g. for SKU grouping in the UI).
                  example: Merchandising
                object_types:
                  type: array
                  description: |
                    Entity types this custom field applies to. On update this field is
                    required — pass an empty array to unlink all entity types.
                    Accepted values include logical names like `sales-orders`, `sales-order-items`,
                    `invoices`, `products`, `companies`, `purchase-orders`, etc. (matches the set
                    accepted by the internal morph-type resolver). For products, `product`,
                    `products` and `rfq` are equivalent and all link the field to products.
                  items:
                    type: string
                  example:
                    - companies
                    - products
              required:
                - label
                - type
      responses:
        '201':
          description: Custom field definition successfully created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the custom field definition
                        example: 123
                      label:
                        type: string
                        description: Display label for the custom field (unique across definitions)
                        example: Industry
                      type:
                        type: string
                        description: |
                          Data type of the custom field. `multi_dropdown` allows selecting multiple
                          values from the `choices` list (values are stored and returned as an array).
                        enum:
                          - number
                          - date
                          - string
                          - dropdown
                          - multi_dropdown
                        example: dropdown
                      options:
                        type: object
                        nullable: true
                        description: |
                          Optional configuration for the field. Common keys:
                          - `choices` (array, required for `type: dropdown` and `type: multi_dropdown`) — the selectable values
                          - `minLength` (integer) — minimum length for string input
                          - `maxLength` (integer) — maximum length for string input
                          - `helpText` (string, max 500) — help text shown in the UI
                          - `pattern` (string, max 500) — regular expression (no delimiters) that non-blank `string` values must match
                          - `patternHint` (string, max 500) — error message returned when a value does not match `pattern`
                        properties:
                          choices:
                            type: array
                            description: Selectable values for `dropdown` and `multi_dropdown` fields
                            items:
                              oneOf:
                                - type: string
                                - type: number
                            example:
                              - Retail
                              - Wholesale
                              - DTC
                          minLength:
                            type: integer
                            minimum: 0
                            example: 0
                          maxLength:
                            type: integer
                            minimum: 1
                            example: 255
                          helpText:
                            type: string
                            maxLength: 500
                            example: Choose the primary sales channel
                          pattern:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              `string` fields only. Regular expression (written without delimiters,
                              e.g. `^[A-Z]{3}-\d{4}$`) that non-blank values must match. An invalid
                              regular expression is rejected with `422` when the definition is saved.
                              Values that do not match are rejected with `422` when written to a record.
                            example: '^[A-Z]{3}-\d{4}$'
                          patternHint:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              Error message returned when a value does not match `pattern`. Defaults to
                              "Field '<label>' does not match the required pattern".
                            example: 'Use three capital letters, a dash, and four digits (e.g. ABC-1234)'
                        additionalProperties: true
                      category:
                        type: string
                        nullable: true
                        description: |
                          Optional free-text category label used to group custom field definitions
                          (e.g. for SKU grouping in the UI). `null` when unset.
                        example: Merchandising
                      object_types:
                        type: array
                        description: 'Entity types this custom field applies to (e.g. `sales-orders`, `products`)'
                        items:
                          type: string
                        example:
                          - companies
                          - products
                      created_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                    required:
                      - id
                      - label
                      - type
                      - object_types
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/custom-fields/{customFieldId}/choices':
    patch:
      operationId: patchCustomFieldDefinitionChoices
      tags:
        - Custom Fields
      summary: Add or remove dropdown choices
      description: |
        Safely add and/or remove dropdown choices on a `dropdown` or `multi_dropdown`
        custom field without resending the entire choice list. Only applies to fields
        whose `type` is `dropdown` or `multi_dropdown`.

        At least one of `add` or `remove` must be provided with at least one value.
        Strings in `add` that already exist are ignored; strings in `remove` that
        are not present are ignored.
      security:
        - BearerAuth: []
      parameters:
        - name: customFieldId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the custom field definition
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                add:
                  type: array
                  description: Choice values to append (deduplicated against existing).
                  items:
                    type: string
                  example:
                    - Enterprise
                remove:
                  type: array
                  description: Choice values to remove from the list.
                  items:
                    type: string
                  example:
                    - Legacy
      responses:
        '200':
          description: Choices successfully updated; returns the full field definition
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the custom field definition
                        example: 123
                      label:
                        type: string
                        description: Display label for the custom field (unique across definitions)
                        example: Industry
                      type:
                        type: string
                        description: |
                          Data type of the custom field. `multi_dropdown` allows selecting multiple
                          values from the `choices` list (values are stored and returned as an array).
                        enum:
                          - number
                          - date
                          - string
                          - dropdown
                          - multi_dropdown
                        example: dropdown
                      options:
                        type: object
                        nullable: true
                        description: |
                          Optional configuration for the field. Common keys:
                          - `choices` (array, required for `type: dropdown` and `type: multi_dropdown`) — the selectable values
                          - `minLength` (integer) — minimum length for string input
                          - `maxLength` (integer) — maximum length for string input
                          - `helpText` (string, max 500) — help text shown in the UI
                          - `pattern` (string, max 500) — regular expression (no delimiters) that non-blank `string` values must match
                          - `patternHint` (string, max 500) — error message returned when a value does not match `pattern`
                        properties:
                          choices:
                            type: array
                            description: Selectable values for `dropdown` and `multi_dropdown` fields
                            items:
                              oneOf:
                                - type: string
                                - type: number
                            example:
                              - Retail
                              - Wholesale
                              - DTC
                          minLength:
                            type: integer
                            minimum: 0
                            example: 0
                          maxLength:
                            type: integer
                            minimum: 1
                            example: 255
                          helpText:
                            type: string
                            maxLength: 500
                            example: Choose the primary sales channel
                          pattern:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              `string` fields only. Regular expression (written without delimiters,
                              e.g. `^[A-Z]{3}-\d{4}$`) that non-blank values must match. An invalid
                              regular expression is rejected with `422` when the definition is saved.
                              Values that do not match are rejected with `422` when written to a record.
                            example: '^[A-Z]{3}-\d{4}$'
                          patternHint:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              Error message returned when a value does not match `pattern`. Defaults to
                              "Field '<label>' does not match the required pattern".
                            example: 'Use three capital letters, a dash, and four digits (e.g. ABC-1234)'
                        additionalProperties: true
                      category:
                        type: string
                        nullable: true
                        description: |
                          Optional free-text category label used to group custom field definitions
                          (e.g. for SKU grouping in the UI). `null` when unset.
                        example: Merchandising
                      object_types:
                        type: array
                        description: 'Entity types this custom field applies to (e.g. `sales-orders`, `products`)'
                        items:
                          type: string
                        example:
                          - companies
                          - products
                      created_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                    required:
                      - id
                      - label
                      - type
                      - object_types
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: |
            Validation error. Returned when neither `add` nor `remove` provides any
            value, or when the target field is not of type `dropdown` or `multi_dropdown`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/custom-fields/{customFieldId}':
    get:
      operationId: getCustomFieldDefinition
      tags:
        - Custom Fields
      summary: Get a custom field definition
      description: Retrieve a single custom field definition by ID.
      security:
        - BearerAuth: []
      parameters:
        - name: customFieldId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the custom field definition
      responses:
        '200':
          description: Custom field definition
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the custom field definition
                        example: 123
                      label:
                        type: string
                        description: Display label for the custom field (unique across definitions)
                        example: Industry
                      type:
                        type: string
                        description: |
                          Data type of the custom field. `multi_dropdown` allows selecting multiple
                          values from the `choices` list (values are stored and returned as an array).
                        enum:
                          - number
                          - date
                          - string
                          - dropdown
                          - multi_dropdown
                        example: dropdown
                      options:
                        type: object
                        nullable: true
                        description: |
                          Optional configuration for the field. Common keys:
                          - `choices` (array, required for `type: dropdown` and `type: multi_dropdown`) — the selectable values
                          - `minLength` (integer) — minimum length for string input
                          - `maxLength` (integer) — maximum length for string input
                          - `helpText` (string, max 500) — help text shown in the UI
                          - `pattern` (string, max 500) — regular expression (no delimiters) that non-blank `string` values must match
                          - `patternHint` (string, max 500) — error message returned when a value does not match `pattern`
                        properties:
                          choices:
                            type: array
                            description: Selectable values for `dropdown` and `multi_dropdown` fields
                            items:
                              oneOf:
                                - type: string
                                - type: number
                            example:
                              - Retail
                              - Wholesale
                              - DTC
                          minLength:
                            type: integer
                            minimum: 0
                            example: 0
                          maxLength:
                            type: integer
                            minimum: 1
                            example: 255
                          helpText:
                            type: string
                            maxLength: 500
                            example: Choose the primary sales channel
                          pattern:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              `string` fields only. Regular expression (written without delimiters,
                              e.g. `^[A-Z]{3}-\d{4}$`) that non-blank values must match. An invalid
                              regular expression is rejected with `422` when the definition is saved.
                              Values that do not match are rejected with `422` when written to a record.
                            example: '^[A-Z]{3}-\d{4}$'
                          patternHint:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              Error message returned when a value does not match `pattern`. Defaults to
                              "Field '<label>' does not match the required pattern".
                            example: 'Use three capital letters, a dash, and four digits (e.g. ABC-1234)'
                        additionalProperties: true
                      category:
                        type: string
                        nullable: true
                        description: |
                          Optional free-text category label used to group custom field definitions
                          (e.g. for SKU grouping in the UI). `null` when unset.
                        example: Merchandising
                      object_types:
                        type: array
                        description: 'Entity types this custom field applies to (e.g. `sales-orders`, `products`)'
                        items:
                          type: string
                        example:
                          - companies
                          - products
                      created_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                    required:
                      - id
                      - label
                      - type
                      - object_types
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    put:
      operationId: updateCustomFieldDefinition
      tags:
        - Custom Fields
      summary: Update a custom field definition
      description: |
        Update a custom field definition's label, type, options, and linked entity
        types. `object_types` is required on update — pass an empty array to unlink
        the field from all entity types.

        For partial updates that don't replace `object_types`, use `PATCH` instead.
      security:
        - BearerAuth: []
      parameters:
        - name: customFieldId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the custom field definition
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  properties:
                    label:
                      type: string
                      maxLength: 255
                      description: Display label for the custom field. Must be unique across definitions.
                      example: Industry
                    type:
                      type: string
                      description: |
                        Data type of the custom field. `multi_dropdown` allows selecting multiple
                        values from the `choices` list (values are stored as an array).
                      enum:
                        - number
                        - date
                        - string
                        - dropdown
                        - multi_dropdown
                      example: dropdown
                    options:
                      type: object
                      nullable: true
                      description: |
                        Optional configuration for the field. Required when `type` is `dropdown`
                        or `multi_dropdown` (must include a non-empty `choices` array).
                      properties:
                        choices:
                          type: array
                          description: Selectable values; required when `type` is `dropdown` or `multi_dropdown`
                          items:
                            oneOf:
                              - type: string
                              - type: number
                          example:
                            - Retail
                            - Wholesale
                            - DTC
                        minLength:
                          type: integer
                          minimum: 0
                          example: 0
                        maxLength:
                          type: integer
                          minimum: 1
                          example: 255
                        helpText:
                          type: string
                          maxLength: 500
                          example: Choose the primary sales channel
                        pattern:
                          type: string
                          nullable: true
                          maxLength: 500
                          description: |
                            `string` fields only. Regular expression (written without delimiters,
                            e.g. `^[A-Z]{3}-\d{4}$`) that non-blank values must match. An invalid
                            regular expression is rejected with `422` when the definition is saved.
                            Values that do not match are rejected with `422` when written to a record.
                          example: '^[A-Z]{3}-\d{4}$'
                        patternHint:
                          type: string
                          nullable: true
                          maxLength: 500
                          description: |
                            Error message returned when a value does not match `pattern`. Defaults to
                            "Field '<label>' does not match the required pattern".
                          example: 'Use three capital letters, a dash, and four digits (e.g. ABC-1234)'
                      additionalProperties: true
                    category:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: |
                        Optional free-text category label used to group custom field definitions
                        (e.g. for SKU grouping in the UI).
                      example: Merchandising
                    object_types:
                      type: array
                      description: |
                        Entity types this custom field applies to. On update this field is
                        required — pass an empty array to unlink all entity types.
                        Accepted values include logical names like `sales-orders`, `sales-order-items`,
                        `invoices`, `products`, `companies`, `purchase-orders`, etc. (matches the set
                        accepted by the internal morph-type resolver). For products, `product`,
                        `products` and `rfq` are equivalent and all link the field to products.
                      items:
                        type: string
                      example:
                        - companies
                        - products
                  required:
                    - label
                    - type
                - type: object
                  required:
                    - object_types
      responses:
        '200':
          description: Custom field definition successfully updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the custom field definition
                        example: 123
                      label:
                        type: string
                        description: Display label for the custom field (unique across definitions)
                        example: Industry
                      type:
                        type: string
                        description: |
                          Data type of the custom field. `multi_dropdown` allows selecting multiple
                          values from the `choices` list (values are stored and returned as an array).
                        enum:
                          - number
                          - date
                          - string
                          - dropdown
                          - multi_dropdown
                        example: dropdown
                      options:
                        type: object
                        nullable: true
                        description: |
                          Optional configuration for the field. Common keys:
                          - `choices` (array, required for `type: dropdown` and `type: multi_dropdown`) — the selectable values
                          - `minLength` (integer) — minimum length for string input
                          - `maxLength` (integer) — maximum length for string input
                          - `helpText` (string, max 500) — help text shown in the UI
                          - `pattern` (string, max 500) — regular expression (no delimiters) that non-blank `string` values must match
                          - `patternHint` (string, max 500) — error message returned when a value does not match `pattern`
                        properties:
                          choices:
                            type: array
                            description: Selectable values for `dropdown` and `multi_dropdown` fields
                            items:
                              oneOf:
                                - type: string
                                - type: number
                            example:
                              - Retail
                              - Wholesale
                              - DTC
                          minLength:
                            type: integer
                            minimum: 0
                            example: 0
                          maxLength:
                            type: integer
                            minimum: 1
                            example: 255
                          helpText:
                            type: string
                            maxLength: 500
                            example: Choose the primary sales channel
                          pattern:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              `string` fields only. Regular expression (written without delimiters,
                              e.g. `^[A-Z]{3}-\d{4}$`) that non-blank values must match. An invalid
                              regular expression is rejected with `422` when the definition is saved.
                              Values that do not match are rejected with `422` when written to a record.
                            example: '^[A-Z]{3}-\d{4}$'
                          patternHint:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              Error message returned when a value does not match `pattern`. Defaults to
                              "Field '<label>' does not match the required pattern".
                            example: 'Use three capital letters, a dash, and four digits (e.g. ABC-1234)'
                        additionalProperties: true
                      category:
                        type: string
                        nullable: true
                        description: |
                          Optional free-text category label used to group custom field definitions
                          (e.g. for SKU grouping in the UI). `null` when unset.
                        example: Merchandising
                      object_types:
                        type: array
                        description: 'Entity types this custom field applies to (e.g. `sales-orders`, `products`)'
                        items:
                          type: string
                        example:
                          - companies
                          - products
                      created_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                    required:
                      - id
                      - label
                      - type
                      - object_types
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    patch:
      operationId: patchCustomFieldDefinition
      tags:
        - Custom Fields
      summary: Partially update a custom field definition
      description: |
        Patch one or more attributes of a custom field definition without resending
        the full record. Only the keys you include are touched; omitted keys keep
        their current value. To clear `options`, send `"options": null`.

        Useful for renaming a label, adjusting `options.helpText`, or relinking
        `object_types` without resubmitting the entire definition.

        To add or remove dropdown choices on a `dropdown` field, prefer
        `PATCH /custom-fields/{customFieldId}/choices` — it performs a safe
        additive/subtractive update against the existing choice list.
      security:
        - BearerAuth: []
      parameters:
        - name: customFieldId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the custom field definition
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Any subset of the writable custom field fields. All keys are optional;
                include only what you want to change.
              properties:
                label:
                  type: string
                  maxLength: 255
                  description: New display label (must remain unique across definitions).
                  example: Industry Segment
                type:
                  type: string
                  description: |
                    Data type of the custom field. Changing `type` may require also
                    sending `options` (e.g. switching to `dropdown` or `multi_dropdown`
                    requires a non-empty `choices` array).
                  enum:
                    - number
                    - date
                    - string
                    - dropdown
                    - multi_dropdown
                  example: dropdown
                options:
                  type: object
                  nullable: true
                  description: |
                    Replace the options blob. Send `null` to clear. For dropdown
                    fields, prefer the `/choices` PATCH endpoint to add/remove
                    individual choices without resending the whole list.
                  properties:
                    choices:
                      type: array
                      items:
                        oneOf:
                          - type: string
                          - type: number
                      example:
                        - Retail
                        - Wholesale
                    minLength:
                      type: integer
                      minimum: 0
                    maxLength:
                      type: integer
                      minimum: 1
                    helpText:
                      type: string
                      maxLength: 500
                    pattern:
                      type: string
                      nullable: true
                      maxLength: 500
                      description: |
                        `string` fields only. Regular expression (no delimiters) that
                        non-blank values must match. Invalid patterns return `422`.
                    patternHint:
                      type: string
                      nullable: true
                      maxLength: 500
                      description: Error message returned when a value does not match `pattern`.
                  additionalProperties: true
                category:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: |
                    Optional free-text category label used to group custom field
                    definitions. Send `null` to clear.
                  example: Merchandising
                object_types:
                  type: array
                  description: |
                    Replace the list of linked entity types. Pass an empty array to
                    unlink from all entity types. Omit the key entirely to leave the
                    current linkage untouched.
                  items:
                    type: string
                  example:
                    - companies
                    - products
      responses:
        '200':
          description: Custom field definition successfully patched
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the custom field definition
                        example: 123
                      label:
                        type: string
                        description: Display label for the custom field (unique across definitions)
                        example: Industry
                      type:
                        type: string
                        description: |
                          Data type of the custom field. `multi_dropdown` allows selecting multiple
                          values from the `choices` list (values are stored and returned as an array).
                        enum:
                          - number
                          - date
                          - string
                          - dropdown
                          - multi_dropdown
                        example: dropdown
                      options:
                        type: object
                        nullable: true
                        description: |
                          Optional configuration for the field. Common keys:
                          - `choices` (array, required for `type: dropdown` and `type: multi_dropdown`) — the selectable values
                          - `minLength` (integer) — minimum length for string input
                          - `maxLength` (integer) — maximum length for string input
                          - `helpText` (string, max 500) — help text shown in the UI
                          - `pattern` (string, max 500) — regular expression (no delimiters) that non-blank `string` values must match
                          - `patternHint` (string, max 500) — error message returned when a value does not match `pattern`
                        properties:
                          choices:
                            type: array
                            description: Selectable values for `dropdown` and `multi_dropdown` fields
                            items:
                              oneOf:
                                - type: string
                                - type: number
                            example:
                              - Retail
                              - Wholesale
                              - DTC
                          minLength:
                            type: integer
                            minimum: 0
                            example: 0
                          maxLength:
                            type: integer
                            minimum: 1
                            example: 255
                          helpText:
                            type: string
                            maxLength: 500
                            example: Choose the primary sales channel
                          pattern:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              `string` fields only. Regular expression (written without delimiters,
                              e.g. `^[A-Z]{3}-\d{4}$`) that non-blank values must match. An invalid
                              regular expression is rejected with `422` when the definition is saved.
                              Values that do not match are rejected with `422` when written to a record.
                            example: '^[A-Z]{3}-\d{4}$'
                          patternHint:
                            type: string
                            nullable: true
                            maxLength: 500
                            description: |
                              Error message returned when a value does not match `pattern`. Defaults to
                              "Field '<label>' does not match the required pattern".
                            example: 'Use three capital letters, a dash, and four digits (e.g. ABC-1234)'
                        additionalProperties: true
                      category:
                        type: string
                        nullable: true
                        description: |
                          Optional free-text category label used to group custom field definitions
                          (e.g. for SKU grouping in the UI). `null` when unset.
                        example: Merchandising
                      object_types:
                        type: array
                        description: 'Entity types this custom field applies to (e.g. `sales-orders`, `products`)'
                        items:
                          type: string
                        example:
                          - companies
                          - products
                      created_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        example: '2026-04-20T14:30:00Z'
                    required:
                      - id
                      - label
                      - type
                      - object_types
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteCustomFieldDefinition
      tags:
        - Custom Fields
      summary: Delete a custom field definition
      description: |
        Delete a custom field definition by ID. Fields that are already in use on
        records cannot be deleted and will return a 422.
      security:
        - BearerAuth: []
      parameters:
        - name: customFieldId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the custom field definition
      responses:
        '204':
          description: Custom field definition successfully deleted
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Field is in use and cannot be deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/{recordType}/{recordId}/custom-fields':
    get:
      operationId: getCustomFields
      tags:
        - Custom Fields
      summary: Get custom field values
      description: |
        Retrieve all custom field values for a specific record.
        Supported record types: `sales-orders`,`sales-order-items`,`invoices`,`products`,`purchase-orders`,`purchase-order-shipments`,`transfer-orders`

        Custom fields must be set up in Luminous before they can be updated or retrieved. 
        Log into your Luminous account, then 
        via the left navigation select Manage > Custom Fields.

        For every record type, the response lists every custom field defined for that
        record type, keyed by label, with `null` for fields that have no value on this
        record. Fields defined for other record types are not included, and a record type
        with no custom fields of its own returns an empty object (`{}`). For
        `purchase-orders`, `purchase-order-shipments` and `transfer-orders`, a token restricted from PII
        returns an empty object.

        Number-type custom fields come back as numbers (the stored numeric value, or stored
        numeric text converted to a number); a number field holding non-numeric text returns `null`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: recordType
          required: true
          schema:
            type: string
            enum:
              - sales-orders
              - sales-order-items
              - invoices
              - products
              - purchase-orders
              - purchase-order-shipments
              - transfer-orders
          description: Type of record to get custom fields for
        - in: path
          name: recordId
          required: true
          schema:
            type: integer
          description: ID of the record
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  oneOf:
                    - type: string
                    - type: number
                    - type: array
                      description: Selected values for a `multi_dropdown` custom field
                      items:
                        oneOf:
                          - type: string
                          - type: number
                example:
                  Customer PO: PO-98765
                  Expected Delivery: '2024-12-25'
                  Priority Level: High
                  Item Count: 42
                  Sales Channels:
                    - Retail
                    - Wholesale
        '400':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateCustomFields
      tags:
        - Custom Fields
      summary: Update custom field values
      description: |
        Update custom field values for a specific record.
        Supported record types: `sales-orders`,`sales-order-items`,`invoices`,`products`,`purchase-orders`,`purchase-order-shipments`,`transfer-orders`
        Values must match the field type (string, number, date, dropdown, or multi_dropdown).
        For a `multi_dropdown` field, pass an array of values (each must be one of the
        field's defined choices).

        Custom fields must be set up in Luminous before they can be updated or retrieved. Log into your Luminous account, then 
        via the left navigation select Manage > Custom Fields.

        For `purchase-orders`, `purchase-order-shipments` and `transfer-orders`, the update
        is partial and validated against the custom fields defined for that record type
        (for `transfer-orders`, whatever the transfer order's status):
        - Only the labels sent are changed; other fields keep their values.
        - Labels are matched case-insensitively. A label that is not defined for the
          record type is rejected with a `422`; it is never created automatically.
        - Sending `null`, `""` or `[]` for a field clears it. Clearing a required field
          is rejected with a `422`.
        - Each value is checked against its field's type. If any entry is invalid, nothing
          is saved and the `422` lists every rejected entry under `custom_fields.{label}`.
        - An empty body is rejected with a `422`.

        For `sales-orders`, `sales-order-items`, `invoices` and `products`, each label is
        resolved against the custom fields defined for that record type, and the update is
        partial (labels not sent keep their values):
        - A label that is defined only for a different record type is rejected with a `422`
          naming the label; it is not silently ignored.
        - A label that is not defined for any record type is still auto-created as a new
          custom field for this record type, with its type detected from the value. This
          auto-creation is deprecated; define the field in Manage > Custom Fields first.
        - Sending `null`, `""` or `[]` for a field clears its value (dropdown fields
          included). Clearing a required field is rejected with a `422`. An empty value
          for a label that is not defined is ignored (no field is auto-created).
        - Each value is checked against its field's type (a dropdown choice, a string
          length, a single value where an array was sent). If any label is rejected, nothing
          is saved and the `422` lists every rejected label.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: recordType
          required: true
          schema:
            type: string
            enum:
              - sales-orders
              - sales-order-items
              - invoices
              - products
              - purchase-orders
              - purchase-order-shipments
              - transfer-orders
          description: Type of record to update custom fields for
        - in: path
          name: recordId
          required: true
          schema:
            type: integer
          description: ID of the record
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties:
                oneOf:
                  - type: string
                  - type: number
                  - type: array
                    description: Selected values for a `multi_dropdown` custom field
                    items:
                      oneOf:
                        - type: string
                        - type: number
              example:
                Customer PO: PO-98765
                Expected Delivery: '2024-12-25'
                Priority Level: High
                Item Count: 42
                Sales Channels:
                  - Retail
                  - Wholesale
      responses:
        '200':
          description: Custom fields updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Custom fields updated successfully
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /warehouses:
    get:
      operationId: getWarehouses
      tags:
        - Locations
      summary: Warehouses
      description: |
        Get a paginated list of warehouses with optional filtering.

        If the API user is assigned to specific warehouses (set per user in the app), only those
        warehouses are returned. Users with no warehouse assignment see every warehouse.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Warehouse name

        ## Examples
        ```
        # Find warehouses by name
        ?name[contains]=Main

        # Paginate results
        ?per_page=5&page=2
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: name
          schema:
            type: string
          description: Filter by warehouse name
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Warehouse ID
                        status:
                          type: string
                          nullable: true
                          description: 'Warehouse status (e.g. active, inactive)'
                        name:
                          type: string
                          description: Warehouse name
                        address:
                          type: string
                          nullable: true
                          description: Street address
                        street_address_1:
                          type: string
                          nullable: true
                          description: Street address line 1
                        street_address_2:
                          type: string
                          nullable: true
                          description: Street address line 2
                        city:
                          type: string
                          nullable: true
                          description: City
                        state:
                          type: string
                          nullable: true
                          description: State/province
                        zip:
                          type: string
                          nullable: true
                          description: Postal/ZIP code
                        country:
                          type: string
                          nullable: true
                          description: Country
                        is_pick_location:
                          type: boolean
                          description: Whether this warehouse is a pick location
                        return_name:
                          type: string
                          nullable: true
                          description: |
                            Return-address name/company.
                            Optional return address printed on carrier labels (currently ParcelPerform)
                            for orders shipped from this warehouse. The override applies when `return_name`
                            or `return_street_address_1` is set; any blank field falls back to the
                            ship-from address. A warehouse group's return address takes precedence.
                        return_street_address_1:
                          type: string
                          nullable: true
                          description: Return-address street line 1
                        return_street_address_2:
                          type: string
                          nullable: true
                          description: Return-address street line 2
                        return_city:
                          type: string
                          nullable: true
                          description: Return-address city
                        return_state:
                          type: string
                          nullable: true
                          description: Return-address state/province
                        return_zip:
                          type: string
                          nullable: true
                          description: Return-address postal/ZIP code
                        return_country:
                          type: string
                          nullable: true
                          description: Return-address country
                        return_phone:
                          type: string
                          nullable: true
                          description: Return-address phone
                        return_email:
                          type: string
                          nullable: true
                          format: email
                          description: Return-address email
                        created_at:
                          type: string
                          format: date-time
                          description: When the warehouse was created
                        updated_at:
                          type: string
                          format: date-time
                          description: When the warehouse was last updated
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createWarehouse
      tags:
        - Locations
      summary: Create warehouse
      description: |-
        Create a new warehouse (top-level location).

        The new warehouse is created with two bins, **Receiving** and **Shipping**, which are set as its default
        receiving and shipping locations (the same bins the New Warehouse form in the app creates), so stock
        imports and stock pulls into the warehouse have somewhere to land.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Warehouse name
                address:
                  type: string
                  nullable: true
                  description: Street address
                street_address_1:
                  type: string
                  nullable: true
                  description: Street address line 1
                street_address_2:
                  type: string
                  nullable: true
                  description: Street address line 2
                city:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: City
                state:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: State/province
                zip:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Postal/ZIP code
                country:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Country
                is_pick_location:
                  type: boolean
                  nullable: true
                  description: Whether this is a pick location
                return_name:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: |
                    Return-address name/company.
                    Optional return address printed on carrier labels (currently ParcelPerform)
                    for orders shipped from this warehouse. The override applies when `return_name`
                    or `return_street_address_1` is set; any blank field falls back to the
                    ship-from address. A warehouse group's return address takes precedence.
                return_street_address_1:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address street line 1
                return_street_address_2:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address street line 2
                return_city:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address city
                return_state:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address state/province
                return_zip:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address postal/ZIP code
                return_country:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address country
                return_phone:
                  type: string
                  nullable: true
                  maxLength: 50
                  description: Return-address phone
                return_email:
                  type: string
                  nullable: true
                  format: email
                  maxLength: 255
                  description: Return-address email
      responses:
        '201':
          description: Warehouse created
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Warehouse ID
                  status:
                    type: string
                    nullable: true
                    description: 'Warehouse status (e.g. active, inactive)'
                  name:
                    type: string
                    description: Warehouse name
                  address:
                    type: string
                    nullable: true
                    description: Street address
                  street_address_1:
                    type: string
                    nullable: true
                    description: Street address line 1
                  street_address_2:
                    type: string
                    nullable: true
                    description: Street address line 2
                  city:
                    type: string
                    nullable: true
                    description: City
                  state:
                    type: string
                    nullable: true
                    description: State/province
                  zip:
                    type: string
                    nullable: true
                    description: Postal/ZIP code
                  country:
                    type: string
                    nullable: true
                    description: Country
                  is_pick_location:
                    type: boolean
                    description: Whether this warehouse is a pick location
                  return_name:
                    type: string
                    nullable: true
                    description: |
                      Return-address name/company.
                      Optional return address printed on carrier labels (currently ParcelPerform)
                      for orders shipped from this warehouse. The override applies when `return_name`
                      or `return_street_address_1` is set; any blank field falls back to the
                      ship-from address. A warehouse group's return address takes precedence.
                  return_street_address_1:
                    type: string
                    nullable: true
                    description: Return-address street line 1
                  return_street_address_2:
                    type: string
                    nullable: true
                    description: Return-address street line 2
                  return_city:
                    type: string
                    nullable: true
                    description: Return-address city
                  return_state:
                    type: string
                    nullable: true
                    description: Return-address state/province
                  return_zip:
                    type: string
                    nullable: true
                    description: Return-address postal/ZIP code
                  return_country:
                    type: string
                    nullable: true
                    description: Return-address country
                  return_phone:
                    type: string
                    nullable: true
                    description: Return-address phone
                  return_email:
                    type: string
                    nullable: true
                    format: email
                    description: Return-address email
                  created_at:
                    type: string
                    format: date-time
                    description: When the warehouse was created
                  updated_at:
                    type: string
                    format: date-time
                    description: When the warehouse was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/warehouses/{warehouseId}':
    get:
      operationId: getWarehouseById
      tags:
        - Locations
      summary: Get warehouse by ID
      description: Retrieve a specific warehouse by its ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: warehouseId
          required: true
          schema:
            type: integer
          description: Warehouse ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Warehouse ID
                  status:
                    type: string
                    nullable: true
                    description: 'Warehouse status (e.g. active, inactive)'
                  name:
                    type: string
                    description: Warehouse name
                  address:
                    type: string
                    nullable: true
                    description: Street address
                  street_address_1:
                    type: string
                    nullable: true
                    description: Street address line 1
                  street_address_2:
                    type: string
                    nullable: true
                    description: Street address line 2
                  city:
                    type: string
                    nullable: true
                    description: City
                  state:
                    type: string
                    nullable: true
                    description: State/province
                  zip:
                    type: string
                    nullable: true
                    description: Postal/ZIP code
                  country:
                    type: string
                    nullable: true
                    description: Country
                  is_pick_location:
                    type: boolean
                    description: Whether this warehouse is a pick location
                  return_name:
                    type: string
                    nullable: true
                    description: |
                      Return-address name/company.
                      Optional return address printed on carrier labels (currently ParcelPerform)
                      for orders shipped from this warehouse. The override applies when `return_name`
                      or `return_street_address_1` is set; any blank field falls back to the
                      ship-from address. A warehouse group's return address takes precedence.
                  return_street_address_1:
                    type: string
                    nullable: true
                    description: Return-address street line 1
                  return_street_address_2:
                    type: string
                    nullable: true
                    description: Return-address street line 2
                  return_city:
                    type: string
                    nullable: true
                    description: Return-address city
                  return_state:
                    type: string
                    nullable: true
                    description: Return-address state/province
                  return_zip:
                    type: string
                    nullable: true
                    description: Return-address postal/ZIP code
                  return_country:
                    type: string
                    nullable: true
                    description: Return-address country
                  return_phone:
                    type: string
                    nullable: true
                    description: Return-address phone
                  return_email:
                    type: string
                    nullable: true
                    format: email
                    description: Return-address email
                  created_at:
                    type: string
                    format: date-time
                    description: When the warehouse was created
                  updated_at:
                    type: string
                    format: date-time
                    description: When the warehouse was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Warehouse not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateWarehouse
      tags:
        - Locations
      summary: Update warehouse
      description: Update an existing warehouse. All fields are optional.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: warehouseId
          required: true
          schema:
            type: integer
          description: Warehouse ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Warehouse name
                address:
                  type: string
                  nullable: true
                  description: Street address
                street_address_1:
                  type: string
                  nullable: true
                  description: Street address line 1
                street_address_2:
                  type: string
                  nullable: true
                  description: Street address line 2
                city:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: City
                state:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: State/province
                zip:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Postal/ZIP code
                country:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Country
                is_pick_location:
                  type: boolean
                  nullable: true
                  description: Whether this is a pick location
                return_name:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: |
                    Return-address name/company.
                    Optional return address printed on carrier labels (currently ParcelPerform)
                    for orders shipped from this warehouse. The override applies when `return_name`
                    or `return_street_address_1` is set; any blank field falls back to the
                    ship-from address. A warehouse group's return address takes precedence.
                return_street_address_1:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address street line 1
                return_street_address_2:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address street line 2
                return_city:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address city
                return_state:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address state/province
                return_zip:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address postal/ZIP code
                return_country:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address country
                return_phone:
                  type: string
                  nullable: true
                  maxLength: 50
                  description: Return-address phone
                return_email:
                  type: string
                  nullable: true
                  format: email
                  maxLength: 255
                  description: Return-address email
      responses:
        '200':
          description: Warehouse updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Warehouse ID
                  status:
                    type: string
                    nullable: true
                    description: 'Warehouse status (e.g. active, inactive)'
                  name:
                    type: string
                    description: Warehouse name
                  address:
                    type: string
                    nullable: true
                    description: Street address
                  street_address_1:
                    type: string
                    nullable: true
                    description: Street address line 1
                  street_address_2:
                    type: string
                    nullable: true
                    description: Street address line 2
                  city:
                    type: string
                    nullable: true
                    description: City
                  state:
                    type: string
                    nullable: true
                    description: State/province
                  zip:
                    type: string
                    nullable: true
                    description: Postal/ZIP code
                  country:
                    type: string
                    nullable: true
                    description: Country
                  is_pick_location:
                    type: boolean
                    description: Whether this warehouse is a pick location
                  return_name:
                    type: string
                    nullable: true
                    description: |
                      Return-address name/company.
                      Optional return address printed on carrier labels (currently ParcelPerform)
                      for orders shipped from this warehouse. The override applies when `return_name`
                      or `return_street_address_1` is set; any blank field falls back to the
                      ship-from address. A warehouse group's return address takes precedence.
                  return_street_address_1:
                    type: string
                    nullable: true
                    description: Return-address street line 1
                  return_street_address_2:
                    type: string
                    nullable: true
                    description: Return-address street line 2
                  return_city:
                    type: string
                    nullable: true
                    description: Return-address city
                  return_state:
                    type: string
                    nullable: true
                    description: Return-address state/province
                  return_zip:
                    type: string
                    nullable: true
                    description: Return-address postal/ZIP code
                  return_country:
                    type: string
                    nullable: true
                    description: Return-address country
                  return_phone:
                    type: string
                    nullable: true
                    description: Return-address phone
                  return_email:
                    type: string
                    nullable: true
                    format: email
                    description: Return-address email
                  created_at:
                    type: string
                    format: date-time
                    description: When the warehouse was created
                  updated_at:
                    type: string
                    format: date-time
                    description: When the warehouse was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Warehouse not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteWarehouse
      tags:
        - Locations
      summary: Delete warehouse
      description: |
        Soft-delete a warehouse by ID (sets `status = 0`).

        A warehouse whose bins still hold stock cannot be deleted. If any location
        under the warehouse has a stock row with a non-zero on-hand or reserved
        quantity, the request is refused with a `422`. Transfer or adjust the stock
        to zero first, then retry.

        A warehouse is also refused with a `422` when it, or any of its bins, is the
        default receiving bin, default assembly bin or default starting location of
        a SKU. The error message lists up to five of those SKUs; change their default
        locations first, then retry.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: warehouseId
          required: true
          schema:
            type: integer
          description: Warehouse ID
      responses:
        '204':
          description: Warehouse deleted
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Warehouse not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            The warehouse still holds stock. One or more of its bins has a non-zero
            on-hand or reserved quantity, so it cannot be deleted until the stock is
            transferred or adjusted to zero. Also returned when the warehouse or one
            of its bins is a SKU's default receiving, assembly or starting location.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /warehouse-groups:
    get:
      operationId: getWarehouseGroups
      tags:
        - Locations
      summary: Warehouse groups
      description: Get a paginated list of warehouse groups.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: name
          schema:
            type: string
          description: Filter by warehouse group name (partial match)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Warehouse group ID
                        uuid:
                          type: string
                          description: Warehouse group UUID
                        name:
                          type: string
                          description: Warehouse group name
                        description:
                          type: string
                          nullable: true
                          description: Warehouse group description
                        externally_managed:
                          type: boolean
                          description: |
                            Whether this warehouse group's inventory is managed by an external WMS
                            (e.g. a 3PL integration). When `true`, the related `externally_managed_*`
                            and `pull_*` fields drive the integration sync.
                        externally_managed_app_integration_account_id:
                          type: integer
                          nullable: true
                          description: |
                            ID of the app integration account that owns this warehouse group.
                            Required when `externally_managed` is `true`.
                        externally_managed_warehouse:
                          type: string
                          nullable: true
                          description: |
                            External WMS-side warehouse identifier (free-form string from the
                            integration partner).
                        app_integration_account_inventory_location_id:
                          type: integer
                          nullable: true
                          description: |
                            ID of the inventory location within the app integration account that
                            this warehouse group maps to.
                        pull_stocks:
                          type: boolean
                          description: |
                            Whether stock levels are pulled from the external WMS into Luminous.
                            Required to be set when `externally_managed` is `true`.
                        pull_shipments:
                          type: boolean
                          description: |
                            Whether shipments are pulled from the external WMS into Luminous.
                            Required to be set when `externally_managed` is `true`.
                        return_name:
                          type: string
                          nullable: true
                          description: |
                            Return-address name/company.
                            Optional return address printed on carrier labels (currently ParcelPerform)
                            for fulfillment orders shipped from this warehouse group. Takes precedence over
                            the default warehouse's return address. The override applies when `return_name`
                            or `return_street_address_1` is set; any blank field falls back to the ship-from address.
                        return_street_address_1:
                          type: string
                          nullable: true
                          description: Return-address street line 1
                        return_street_address_2:
                          type: string
                          nullable: true
                          description: Return-address street line 2
                        return_city:
                          type: string
                          nullable: true
                          description: Return-address city
                        return_state:
                          type: string
                          nullable: true
                          description: Return-address state/province
                        return_zip:
                          type: string
                          nullable: true
                          description: Return-address postal/ZIP code
                        return_country:
                          type: string
                          nullable: true
                          description: Return-address country
                        return_phone:
                          type: string
                          nullable: true
                          description: Return-address phone
                        return_email:
                          type: string
                          nullable: true
                          format: email
                          description: Return-address email
                        warehouses:
                          type: array
                          description: Warehouses belonging to this group
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Warehouse ID
                              status:
                                type: string
                                nullable: true
                                description: 'Warehouse status (e.g. active, inactive)'
                              name:
                                type: string
                                description: Warehouse name
                              address:
                                type: string
                                nullable: true
                                description: Street address
                              street_address_1:
                                type: string
                                nullable: true
                                description: Street address line 1
                              street_address_2:
                                type: string
                                nullable: true
                                description: Street address line 2
                              city:
                                type: string
                                nullable: true
                                description: City
                              state:
                                type: string
                                nullable: true
                                description: State/province
                              zip:
                                type: string
                                nullable: true
                                description: Postal/ZIP code
                              country:
                                type: string
                                nullable: true
                                description: Country
                              is_pick_location:
                                type: boolean
                                description: Whether this warehouse is a pick location
                              return_name:
                                type: string
                                nullable: true
                                description: |
                                  Return-address name/company.
                                  Optional return address printed on carrier labels (currently ParcelPerform)
                                  for orders shipped from this warehouse. The override applies when `return_name`
                                  or `return_street_address_1` is set; any blank field falls back to the
                                  ship-from address. A warehouse group's return address takes precedence.
                              return_street_address_1:
                                type: string
                                nullable: true
                                description: Return-address street line 1
                              return_street_address_2:
                                type: string
                                nullable: true
                                description: Return-address street line 2
                              return_city:
                                type: string
                                nullable: true
                                description: Return-address city
                              return_state:
                                type: string
                                nullable: true
                                description: Return-address state/province
                              return_zip:
                                type: string
                                nullable: true
                                description: Return-address postal/ZIP code
                              return_country:
                                type: string
                                nullable: true
                                description: Return-address country
                              return_phone:
                                type: string
                                nullable: true
                                description: Return-address phone
                              return_email:
                                type: string
                                nullable: true
                                format: email
                                description: Return-address email
                              created_at:
                                type: string
                                format: date-time
                                description: When the warehouse was created
                              updated_at:
                                type: string
                                format: date-time
                                description: When the warehouse was last updated
                        default_warehouse:
                          description: The default warehouse for this group
                          nullable: true
                          allOf:
                            - type: object
                              properties:
                                id:
                                  type: integer
                                  description: Warehouse ID
                                status:
                                  type: string
                                  nullable: true
                                  description: 'Warehouse status (e.g. active, inactive)'
                                name:
                                  type: string
                                  description: Warehouse name
                                address:
                                  type: string
                                  nullable: true
                                  description: Street address
                                street_address_1:
                                  type: string
                                  nullable: true
                                  description: Street address line 1
                                street_address_2:
                                  type: string
                                  nullable: true
                                  description: Street address line 2
                                city:
                                  type: string
                                  nullable: true
                                  description: City
                                state:
                                  type: string
                                  nullable: true
                                  description: State/province
                                zip:
                                  type: string
                                  nullable: true
                                  description: Postal/ZIP code
                                country:
                                  type: string
                                  nullable: true
                                  description: Country
                                is_pick_location:
                                  type: boolean
                                  description: Whether this warehouse is a pick location
                                return_name:
                                  type: string
                                  nullable: true
                                  description: |
                                    Return-address name/company.
                                    Optional return address printed on carrier labels (currently ParcelPerform)
                                    for orders shipped from this warehouse. The override applies when `return_name`
                                    or `return_street_address_1` is set; any blank field falls back to the
                                    ship-from address. A warehouse group's return address takes precedence.
                                return_street_address_1:
                                  type: string
                                  nullable: true
                                  description: Return-address street line 1
                                return_street_address_2:
                                  type: string
                                  nullable: true
                                  description: Return-address street line 2
                                return_city:
                                  type: string
                                  nullable: true
                                  description: Return-address city
                                return_state:
                                  type: string
                                  nullable: true
                                  description: Return-address state/province
                                return_zip:
                                  type: string
                                  nullable: true
                                  description: Return-address postal/ZIP code
                                return_country:
                                  type: string
                                  nullable: true
                                  description: Return-address country
                                return_phone:
                                  type: string
                                  nullable: true
                                  description: Return-address phone
                                return_email:
                                  type: string
                                  nullable: true
                                  format: email
                                  description: Return-address email
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the warehouse was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the warehouse was last updated
                        created_at:
                          type: string
                          format: date-time
                          description: When the warehouse group was created
                        updated_at:
                          type: string
                          format: date-time
                          description: When the warehouse group was last updated
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createWarehouseGroup
      tags:
        - Locations
      summary: Create warehouse group
      description: Create a new warehouse group with optional warehouse assignments.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Warehouse group name
                description:
                  type: string
                  nullable: true
                  description: Warehouse group description
                warehouse_ids:
                  type: array
                  nullable: true
                  description: IDs of warehouses to assign to this group
                  items:
                    type: integer
                default_warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the default warehouse for this group
                externally_managed:
                  type: boolean
                  nullable: true
                  description: |
                    Set to `true` to mark this warehouse group as managed by an
                    external WMS integration. When `true`,
                    `externally_managed_app_integration_account_id`, `pull_stocks`,
                    and `pull_shipments` become required.
                externally_managed_app_integration_account_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the app integration account that owns this group.
                    Required when `externally_managed` is `true`.
                externally_managed_warehouse:
                  type: string
                  nullable: true
                  description: External WMS-side warehouse identifier.
                app_integration_account_inventory_location_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the inventory location within the app integration account
                    that this group maps to. Each external warehouse location may be
                    mapped to at most one externally-managed warehouse group — setting
                    this to a location already held by another such group returns `422`.
                pull_stocks:
                  type: boolean
                  nullable: true
                  description: |
                    Whether to pull stock levels from the external WMS.
                    Required when `externally_managed` is `true`.
                pull_shipments:
                  type: boolean
                  nullable: true
                  description: |
                    Whether to pull shipments from the external WMS.
                    Required when `externally_managed` is `true`.
                return_name:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: |
                    Return-address name/company.
                    Optional return address printed on carrier labels (currently ParcelPerform)
                    for fulfillment orders shipped from this warehouse group. Takes precedence over
                    the default warehouse's return address. The override applies when `return_name`
                    or `return_street_address_1` is set; any blank field falls back to the ship-from address.
                return_street_address_1:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address street line 1
                return_street_address_2:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address street line 2
                return_city:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address city
                return_state:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address state/province
                return_zip:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address postal/ZIP code
                return_country:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address country
                return_phone:
                  type: string
                  nullable: true
                  maxLength: 50
                  description: Return-address phone
                return_email:
                  type: string
                  nullable: true
                  format: email
                  maxLength: 255
                  description: Return-address email
      responses:
        '201':
          description: Warehouse group created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Warehouse group ID
                      uuid:
                        type: string
                        description: Warehouse group UUID
                      name:
                        type: string
                        description: Warehouse group name
                      description:
                        type: string
                        nullable: true
                        description: Warehouse group description
                      externally_managed:
                        type: boolean
                        description: |
                          Whether this warehouse group's inventory is managed by an external WMS
                          (e.g. a 3PL integration). When `true`, the related `externally_managed_*`
                          and `pull_*` fields drive the integration sync.
                      externally_managed_app_integration_account_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the app integration account that owns this warehouse group.
                          Required when `externally_managed` is `true`.
                      externally_managed_warehouse:
                        type: string
                        nullable: true
                        description: |
                          External WMS-side warehouse identifier (free-form string from the
                          integration partner).
                      app_integration_account_inventory_location_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the inventory location within the app integration account that
                          this warehouse group maps to.
                      pull_stocks:
                        type: boolean
                        description: |
                          Whether stock levels are pulled from the external WMS into Luminous.
                          Required to be set when `externally_managed` is `true`.
                      pull_shipments:
                        type: boolean
                        description: |
                          Whether shipments are pulled from the external WMS into Luminous.
                          Required to be set when `externally_managed` is `true`.
                      return_name:
                        type: string
                        nullable: true
                        description: |
                          Return-address name/company.
                          Optional return address printed on carrier labels (currently ParcelPerform)
                          for fulfillment orders shipped from this warehouse group. Takes precedence over
                          the default warehouse's return address. The override applies when `return_name`
                          or `return_street_address_1` is set; any blank field falls back to the ship-from address.
                      return_street_address_1:
                        type: string
                        nullable: true
                        description: Return-address street line 1
                      return_street_address_2:
                        type: string
                        nullable: true
                        description: Return-address street line 2
                      return_city:
                        type: string
                        nullable: true
                        description: Return-address city
                      return_state:
                        type: string
                        nullable: true
                        description: Return-address state/province
                      return_zip:
                        type: string
                        nullable: true
                        description: Return-address postal/ZIP code
                      return_country:
                        type: string
                        nullable: true
                        description: Return-address country
                      return_phone:
                        type: string
                        nullable: true
                        description: Return-address phone
                      return_email:
                        type: string
                        nullable: true
                        format: email
                        description: Return-address email
                      warehouses:
                        type: array
                        description: Warehouses belonging to this group
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Warehouse ID
                            status:
                              type: string
                              nullable: true
                              description: 'Warehouse status (e.g. active, inactive)'
                            name:
                              type: string
                              description: Warehouse name
                            address:
                              type: string
                              nullable: true
                              description: Street address
                            street_address_1:
                              type: string
                              nullable: true
                              description: Street address line 1
                            street_address_2:
                              type: string
                              nullable: true
                              description: Street address line 2
                            city:
                              type: string
                              nullable: true
                              description: City
                            state:
                              type: string
                              nullable: true
                              description: State/province
                            zip:
                              type: string
                              nullable: true
                              description: Postal/ZIP code
                            country:
                              type: string
                              nullable: true
                              description: Country
                            is_pick_location:
                              type: boolean
                              description: Whether this warehouse is a pick location
                            return_name:
                              type: string
                              nullable: true
                              description: |
                                Return-address name/company.
                                Optional return address printed on carrier labels (currently ParcelPerform)
                                for orders shipped from this warehouse. The override applies when `return_name`
                                or `return_street_address_1` is set; any blank field falls back to the
                                ship-from address. A warehouse group's return address takes precedence.
                            return_street_address_1:
                              type: string
                              nullable: true
                              description: Return-address street line 1
                            return_street_address_2:
                              type: string
                              nullable: true
                              description: Return-address street line 2
                            return_city:
                              type: string
                              nullable: true
                              description: Return-address city
                            return_state:
                              type: string
                              nullable: true
                              description: Return-address state/province
                            return_zip:
                              type: string
                              nullable: true
                              description: Return-address postal/ZIP code
                            return_country:
                              type: string
                              nullable: true
                              description: Return-address country
                            return_phone:
                              type: string
                              nullable: true
                              description: Return-address phone
                            return_email:
                              type: string
                              nullable: true
                              format: email
                              description: Return-address email
                            created_at:
                              type: string
                              format: date-time
                              description: When the warehouse was created
                            updated_at:
                              type: string
                              format: date-time
                              description: When the warehouse was last updated
                      default_warehouse:
                        description: The default warehouse for this group
                        nullable: true
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                                description: Warehouse ID
                              status:
                                type: string
                                nullable: true
                                description: 'Warehouse status (e.g. active, inactive)'
                              name:
                                type: string
                                description: Warehouse name
                              address:
                                type: string
                                nullable: true
                                description: Street address
                              street_address_1:
                                type: string
                                nullable: true
                                description: Street address line 1
                              street_address_2:
                                type: string
                                nullable: true
                                description: Street address line 2
                              city:
                                type: string
                                nullable: true
                                description: City
                              state:
                                type: string
                                nullable: true
                                description: State/province
                              zip:
                                type: string
                                nullable: true
                                description: Postal/ZIP code
                              country:
                                type: string
                                nullable: true
                                description: Country
                              is_pick_location:
                                type: boolean
                                description: Whether this warehouse is a pick location
                              return_name:
                                type: string
                                nullable: true
                                description: |
                                  Return-address name/company.
                                  Optional return address printed on carrier labels (currently ParcelPerform)
                                  for orders shipped from this warehouse. The override applies when `return_name`
                                  or `return_street_address_1` is set; any blank field falls back to the
                                  ship-from address. A warehouse group's return address takes precedence.
                              return_street_address_1:
                                type: string
                                nullable: true
                                description: Return-address street line 1
                              return_street_address_2:
                                type: string
                                nullable: true
                                description: Return-address street line 2
                              return_city:
                                type: string
                                nullable: true
                                description: Return-address city
                              return_state:
                                type: string
                                nullable: true
                                description: Return-address state/province
                              return_zip:
                                type: string
                                nullable: true
                                description: Return-address postal/ZIP code
                              return_country:
                                type: string
                                nullable: true
                                description: Return-address country
                              return_phone:
                                type: string
                                nullable: true
                                description: Return-address phone
                              return_email:
                                type: string
                                nullable: true
                                format: email
                                description: Return-address email
                              created_at:
                                type: string
                                format: date-time
                                description: When the warehouse was created
                              updated_at:
                                type: string
                                format: date-time
                                description: When the warehouse was last updated
                      created_at:
                        type: string
                        format: date-time
                        description: When the warehouse group was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the warehouse group was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/warehouse-groups/{id}':
    get:
      operationId: getWarehouseGroupById
      tags:
        - Locations
      summary: Get warehouse group by ID
      description: Retrieve a specific warehouse group by its ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Warehouse group ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Warehouse group ID
                      uuid:
                        type: string
                        description: Warehouse group UUID
                      name:
                        type: string
                        description: Warehouse group name
                      description:
                        type: string
                        nullable: true
                        description: Warehouse group description
                      externally_managed:
                        type: boolean
                        description: |
                          Whether this warehouse group's inventory is managed by an external WMS
                          (e.g. a 3PL integration). When `true`, the related `externally_managed_*`
                          and `pull_*` fields drive the integration sync.
                      externally_managed_app_integration_account_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the app integration account that owns this warehouse group.
                          Required when `externally_managed` is `true`.
                      externally_managed_warehouse:
                        type: string
                        nullable: true
                        description: |
                          External WMS-side warehouse identifier (free-form string from the
                          integration partner).
                      app_integration_account_inventory_location_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the inventory location within the app integration account that
                          this warehouse group maps to.
                      pull_stocks:
                        type: boolean
                        description: |
                          Whether stock levels are pulled from the external WMS into Luminous.
                          Required to be set when `externally_managed` is `true`.
                      pull_shipments:
                        type: boolean
                        description: |
                          Whether shipments are pulled from the external WMS into Luminous.
                          Required to be set when `externally_managed` is `true`.
                      return_name:
                        type: string
                        nullable: true
                        description: |
                          Return-address name/company.
                          Optional return address printed on carrier labels (currently ParcelPerform)
                          for fulfillment orders shipped from this warehouse group. Takes precedence over
                          the default warehouse's return address. The override applies when `return_name`
                          or `return_street_address_1` is set; any blank field falls back to the ship-from address.
                      return_street_address_1:
                        type: string
                        nullable: true
                        description: Return-address street line 1
                      return_street_address_2:
                        type: string
                        nullable: true
                        description: Return-address street line 2
                      return_city:
                        type: string
                        nullable: true
                        description: Return-address city
                      return_state:
                        type: string
                        nullable: true
                        description: Return-address state/province
                      return_zip:
                        type: string
                        nullable: true
                        description: Return-address postal/ZIP code
                      return_country:
                        type: string
                        nullable: true
                        description: Return-address country
                      return_phone:
                        type: string
                        nullable: true
                        description: Return-address phone
                      return_email:
                        type: string
                        nullable: true
                        format: email
                        description: Return-address email
                      warehouses:
                        type: array
                        description: Warehouses belonging to this group
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Warehouse ID
                            status:
                              type: string
                              nullable: true
                              description: 'Warehouse status (e.g. active, inactive)'
                            name:
                              type: string
                              description: Warehouse name
                            address:
                              type: string
                              nullable: true
                              description: Street address
                            street_address_1:
                              type: string
                              nullable: true
                              description: Street address line 1
                            street_address_2:
                              type: string
                              nullable: true
                              description: Street address line 2
                            city:
                              type: string
                              nullable: true
                              description: City
                            state:
                              type: string
                              nullable: true
                              description: State/province
                            zip:
                              type: string
                              nullable: true
                              description: Postal/ZIP code
                            country:
                              type: string
                              nullable: true
                              description: Country
                            is_pick_location:
                              type: boolean
                              description: Whether this warehouse is a pick location
                            return_name:
                              type: string
                              nullable: true
                              description: |
                                Return-address name/company.
                                Optional return address printed on carrier labels (currently ParcelPerform)
                                for orders shipped from this warehouse. The override applies when `return_name`
                                or `return_street_address_1` is set; any blank field falls back to the
                                ship-from address. A warehouse group's return address takes precedence.
                            return_street_address_1:
                              type: string
                              nullable: true
                              description: Return-address street line 1
                            return_street_address_2:
                              type: string
                              nullable: true
                              description: Return-address street line 2
                            return_city:
                              type: string
                              nullable: true
                              description: Return-address city
                            return_state:
                              type: string
                              nullable: true
                              description: Return-address state/province
                            return_zip:
                              type: string
                              nullable: true
                              description: Return-address postal/ZIP code
                            return_country:
                              type: string
                              nullable: true
                              description: Return-address country
                            return_phone:
                              type: string
                              nullable: true
                              description: Return-address phone
                            return_email:
                              type: string
                              nullable: true
                              format: email
                              description: Return-address email
                            created_at:
                              type: string
                              format: date-time
                              description: When the warehouse was created
                            updated_at:
                              type: string
                              format: date-time
                              description: When the warehouse was last updated
                      default_warehouse:
                        description: The default warehouse for this group
                        nullable: true
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                                description: Warehouse ID
                              status:
                                type: string
                                nullable: true
                                description: 'Warehouse status (e.g. active, inactive)'
                              name:
                                type: string
                                description: Warehouse name
                              address:
                                type: string
                                nullable: true
                                description: Street address
                              street_address_1:
                                type: string
                                nullable: true
                                description: Street address line 1
                              street_address_2:
                                type: string
                                nullable: true
                                description: Street address line 2
                              city:
                                type: string
                                nullable: true
                                description: City
                              state:
                                type: string
                                nullable: true
                                description: State/province
                              zip:
                                type: string
                                nullable: true
                                description: Postal/ZIP code
                              country:
                                type: string
                                nullable: true
                                description: Country
                              is_pick_location:
                                type: boolean
                                description: Whether this warehouse is a pick location
                              return_name:
                                type: string
                                nullable: true
                                description: |
                                  Return-address name/company.
                                  Optional return address printed on carrier labels (currently ParcelPerform)
                                  for orders shipped from this warehouse. The override applies when `return_name`
                                  or `return_street_address_1` is set; any blank field falls back to the
                                  ship-from address. A warehouse group's return address takes precedence.
                              return_street_address_1:
                                type: string
                                nullable: true
                                description: Return-address street line 1
                              return_street_address_2:
                                type: string
                                nullable: true
                                description: Return-address street line 2
                              return_city:
                                type: string
                                nullable: true
                                description: Return-address city
                              return_state:
                                type: string
                                nullable: true
                                description: Return-address state/province
                              return_zip:
                                type: string
                                nullable: true
                                description: Return-address postal/ZIP code
                              return_country:
                                type: string
                                nullable: true
                                description: Return-address country
                              return_phone:
                                type: string
                                nullable: true
                                description: Return-address phone
                              return_email:
                                type: string
                                nullable: true
                                format: email
                                description: Return-address email
                              created_at:
                                type: string
                                format: date-time
                                description: When the warehouse was created
                              updated_at:
                                type: string
                                format: date-time
                                description: When the warehouse was last updated
                      created_at:
                        type: string
                        format: date-time
                        description: When the warehouse group was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the warehouse group was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Warehouse group not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateWarehouseGroup
      tags:
        - Locations
      summary: Update warehouse group
      description: Update an existing warehouse group. All fields are optional.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Warehouse group ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Warehouse group name
                description:
                  type: string
                  nullable: true
                  description: Warehouse group description
                warehouse_ids:
                  type: array
                  nullable: true
                  description: IDs of warehouses to assign to this group (replaces existing assignments)
                  items:
                    type: integer
                default_warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the default warehouse for this group
                externally_managed:
                  type: boolean
                  nullable: true
                  description: |
                    Toggle whether this group is managed by an external WMS.
                    Sending `true` makes
                    `externally_managed_app_integration_account_id`, `pull_stocks`,
                    and `pull_shipments` required in the same request.
                externally_managed_app_integration_account_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the app integration account that owns this group.
                    Required when `externally_managed` is `true`.
                externally_managed_warehouse:
                  type: string
                  nullable: true
                  description: External WMS-side warehouse identifier.
                app_integration_account_inventory_location_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the inventory location within the app integration account
                    that this group maps to. Each external warehouse location may be
                    mapped to at most one externally-managed warehouse group — setting
                    this to a location already held by another such group returns `422`.
                pull_stocks:
                  type: boolean
                  nullable: true
                  description: |
                    Whether to pull stock levels from the external WMS.
                    Required when `externally_managed` is `true`.
                pull_shipments:
                  type: boolean
                  nullable: true
                  description: |
                    Whether to pull shipments from the external WMS.
                    Required when `externally_managed` is `true`.
                return_name:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: |
                    Return-address name/company.
                    Optional return address printed on carrier labels (currently ParcelPerform)
                    for fulfillment orders shipped from this warehouse group. Takes precedence over
                    the default warehouse's return address. The override applies when `return_name`
                    or `return_street_address_1` is set; any blank field falls back to the ship-from address.
                return_street_address_1:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address street line 1
                return_street_address_2:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address street line 2
                return_city:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address city
                return_state:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address state/province
                return_zip:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address postal/ZIP code
                return_country:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Return-address country
                return_phone:
                  type: string
                  nullable: true
                  maxLength: 50
                  description: Return-address phone
                return_email:
                  type: string
                  nullable: true
                  format: email
                  maxLength: 255
                  description: Return-address email
      responses:
        '200':
          description: Warehouse group updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Warehouse group ID
                      uuid:
                        type: string
                        description: Warehouse group UUID
                      name:
                        type: string
                        description: Warehouse group name
                      description:
                        type: string
                        nullable: true
                        description: Warehouse group description
                      externally_managed:
                        type: boolean
                        description: |
                          Whether this warehouse group's inventory is managed by an external WMS
                          (e.g. a 3PL integration). When `true`, the related `externally_managed_*`
                          and `pull_*` fields drive the integration sync.
                      externally_managed_app_integration_account_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the app integration account that owns this warehouse group.
                          Required when `externally_managed` is `true`.
                      externally_managed_warehouse:
                        type: string
                        nullable: true
                        description: |
                          External WMS-side warehouse identifier (free-form string from the
                          integration partner).
                      app_integration_account_inventory_location_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the inventory location within the app integration account that
                          this warehouse group maps to.
                      pull_stocks:
                        type: boolean
                        description: |
                          Whether stock levels are pulled from the external WMS into Luminous.
                          Required to be set when `externally_managed` is `true`.
                      pull_shipments:
                        type: boolean
                        description: |
                          Whether shipments are pulled from the external WMS into Luminous.
                          Required to be set when `externally_managed` is `true`.
                      return_name:
                        type: string
                        nullable: true
                        description: |
                          Return-address name/company.
                          Optional return address printed on carrier labels (currently ParcelPerform)
                          for fulfillment orders shipped from this warehouse group. Takes precedence over
                          the default warehouse's return address. The override applies when `return_name`
                          or `return_street_address_1` is set; any blank field falls back to the ship-from address.
                      return_street_address_1:
                        type: string
                        nullable: true
                        description: Return-address street line 1
                      return_street_address_2:
                        type: string
                        nullable: true
                        description: Return-address street line 2
                      return_city:
                        type: string
                        nullable: true
                        description: Return-address city
                      return_state:
                        type: string
                        nullable: true
                        description: Return-address state/province
                      return_zip:
                        type: string
                        nullable: true
                        description: Return-address postal/ZIP code
                      return_country:
                        type: string
                        nullable: true
                        description: Return-address country
                      return_phone:
                        type: string
                        nullable: true
                        description: Return-address phone
                      return_email:
                        type: string
                        nullable: true
                        format: email
                        description: Return-address email
                      warehouses:
                        type: array
                        description: Warehouses belonging to this group
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Warehouse ID
                            status:
                              type: string
                              nullable: true
                              description: 'Warehouse status (e.g. active, inactive)'
                            name:
                              type: string
                              description: Warehouse name
                            address:
                              type: string
                              nullable: true
                              description: Street address
                            street_address_1:
                              type: string
                              nullable: true
                              description: Street address line 1
                            street_address_2:
                              type: string
                              nullable: true
                              description: Street address line 2
                            city:
                              type: string
                              nullable: true
                              description: City
                            state:
                              type: string
                              nullable: true
                              description: State/province
                            zip:
                              type: string
                              nullable: true
                              description: Postal/ZIP code
                            country:
                              type: string
                              nullable: true
                              description: Country
                            is_pick_location:
                              type: boolean
                              description: Whether this warehouse is a pick location
                            return_name:
                              type: string
                              nullable: true
                              description: |
                                Return-address name/company.
                                Optional return address printed on carrier labels (currently ParcelPerform)
                                for orders shipped from this warehouse. The override applies when `return_name`
                                or `return_street_address_1` is set; any blank field falls back to the
                                ship-from address. A warehouse group's return address takes precedence.
                            return_street_address_1:
                              type: string
                              nullable: true
                              description: Return-address street line 1
                            return_street_address_2:
                              type: string
                              nullable: true
                              description: Return-address street line 2
                            return_city:
                              type: string
                              nullable: true
                              description: Return-address city
                            return_state:
                              type: string
                              nullable: true
                              description: Return-address state/province
                            return_zip:
                              type: string
                              nullable: true
                              description: Return-address postal/ZIP code
                            return_country:
                              type: string
                              nullable: true
                              description: Return-address country
                            return_phone:
                              type: string
                              nullable: true
                              description: Return-address phone
                            return_email:
                              type: string
                              nullable: true
                              format: email
                              description: Return-address email
                            created_at:
                              type: string
                              format: date-time
                              description: When the warehouse was created
                            updated_at:
                              type: string
                              format: date-time
                              description: When the warehouse was last updated
                      default_warehouse:
                        description: The default warehouse for this group
                        nullable: true
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                                description: Warehouse ID
                              status:
                                type: string
                                nullable: true
                                description: 'Warehouse status (e.g. active, inactive)'
                              name:
                                type: string
                                description: Warehouse name
                              address:
                                type: string
                                nullable: true
                                description: Street address
                              street_address_1:
                                type: string
                                nullable: true
                                description: Street address line 1
                              street_address_2:
                                type: string
                                nullable: true
                                description: Street address line 2
                              city:
                                type: string
                                nullable: true
                                description: City
                              state:
                                type: string
                                nullable: true
                                description: State/province
                              zip:
                                type: string
                                nullable: true
                                description: Postal/ZIP code
                              country:
                                type: string
                                nullable: true
                                description: Country
                              is_pick_location:
                                type: boolean
                                description: Whether this warehouse is a pick location
                              return_name:
                                type: string
                                nullable: true
                                description: |
                                  Return-address name/company.
                                  Optional return address printed on carrier labels (currently ParcelPerform)
                                  for orders shipped from this warehouse. The override applies when `return_name`
                                  or `return_street_address_1` is set; any blank field falls back to the
                                  ship-from address. A warehouse group's return address takes precedence.
                              return_street_address_1:
                                type: string
                                nullable: true
                                description: Return-address street line 1
                              return_street_address_2:
                                type: string
                                nullable: true
                                description: Return-address street line 2
                              return_city:
                                type: string
                                nullable: true
                                description: Return-address city
                              return_state:
                                type: string
                                nullable: true
                                description: Return-address state/province
                              return_zip:
                                type: string
                                nullable: true
                                description: Return-address postal/ZIP code
                              return_country:
                                type: string
                                nullable: true
                                description: Return-address country
                              return_phone:
                                type: string
                                nullable: true
                                description: Return-address phone
                              return_email:
                                type: string
                                nullable: true
                                format: email
                                description: Return-address email
                              created_at:
                                type: string
                                format: date-time
                                description: When the warehouse was created
                              updated_at:
                                type: string
                                format: date-time
                                description: When the warehouse was last updated
                      created_at:
                        type: string
                        format: date-time
                        description: When the warehouse group was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the warehouse group was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Warehouse group not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteWarehouseGroup
      tags:
        - Locations
      summary: Delete warehouse group
      description: Delete a warehouse group by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Warehouse group ID
      responses:
        '204':
          description: Warehouse group deleted
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Warehouse group not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /locations:
    get:
      operationId: getLocations
      tags:
        - Locations
      summary: Locations
      description: |
        Get a paginated list of locations with optional filtering.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Location name

        ### Integer Filters
        - `parent_id`: Warehouse ID (limits the list to one warehouse's bins)

        ### Boolean Filters
        - `is_pick_location`: Filter pick locations

        ## Examples
        ```
        # Find locations by name
        ?name[contains]=Aisle

        # Find pick locations
        ?is_pick_location[eq]=true

        # Bins in warehouse 3
        ?parent_id[eq]=3

        # Paginate results
        ?per_page=5&page=2
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: name
          schema:
            type: string
          description: Filter by location name
        - in: query
          name: is_pick_location
          schema:
            type: boolean
          description: Filter by pick location status
        - in: query
          name: parent_id
          schema:
            type: integer
          description: 'Filter by warehouse ID (the bin''s parent location). Supports integer operators, e.g. `parent_id[eq]=3`.'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        status:
                          type: string
                        name:
                          type: string
                        parent_id:
                          type: integer
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createLocation
      tags:
        - Locations
      summary: Create location
      description: |
        Create a new location (a child of an existing warehouse, e.g. a bin or aisle).

        Locations always sit one level below a warehouse — nesting a location under
        another location is not supported. To create a top-level warehouse, use
        `POST /warehouses` instead.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - parent_id
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Location name
                parent_id:
                  type: integer
                  description: |
                    ID of the parent warehouse. Must reference an existing warehouse
                    (an `mt_locations` row with `parent_id = 0`). Locations cannot be
                    nested under other locations.
                address:
                  type: string
                  nullable: true
                  description: Street address
                street_address_1:
                  type: string
                  nullable: true
                  description: Street address line 1
                street_address_2:
                  type: string
                  nullable: true
                  description: Street address line 2
                city:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: City
                state:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: State/province
                zip:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Postal/ZIP code
                country:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Country
                is_pick_location:
                  type: boolean
                  nullable: true
                  description: Whether this is a pick location
      responses:
        '201':
          description: Location created
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  status:
                    type: string
                  name:
                    type: string
                  parent_id:
                    type: integer
                    nullable: true
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/locations/{locationId}':
    get:
      operationId: getLocationById
      tags:
        - Locations
      summary: Get location by ID
      description: Retrieve a specific location by its ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: locationId
          required: true
          schema:
            type: integer
          description: Location ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  status:
                    type: string
                  name:
                    type: string
                  parent_id:
                    type: integer
                    nullable: true
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Location not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    patch:
      operationId: updateLocation
      tags:
        - Locations
      summary: Update location
      description: Update an existing location. All fields are optional.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: locationId
          required: true
          schema:
            type: integer
          description: Location ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Location name
                parent_id:
                  type: integer
                  description: |
                    ID of the parent warehouse. When supplied, must reference an existing
                    warehouse (an `mt_locations` row with `parent_id = 0`). Locations
                    cannot be nested under other locations.
                address:
                  type: string
                  nullable: true
                  description: Street address
                street_address_1:
                  type: string
                  nullable: true
                  description: Street address line 1
                street_address_2:
                  type: string
                  nullable: true
                  description: Street address line 2
                city:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: City
                state:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: State/province
                zip:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Postal/ZIP code
                country:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Country
                is_pick_location:
                  type: boolean
                  nullable: true
                  description: Whether this is a pick location
      responses:
        '200':
          description: Location updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  status:
                    type: string
                  name:
                    type: string
                  parent_id:
                    type: integer
                    nullable: true
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Location not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteLocation
      tags:
        - Locations
      summary: Delete location
      description: |
        Soft-delete a location (sets `status = 0`). Only non-warehouse locations may
        be deleted via this endpoint — i.e. rows whose `parent_id` is not null and
        not zero. To delete a top-level warehouse, use `DELETE /warehouses/{id}`.

        A location that still holds stock cannot be deleted. If any stock row on the
        location has a non-zero on-hand or reserved quantity, the request is refused
        with a `422`. Transfer or adjust the stock to zero first, then retry.

        A location is also refused with a `422` when it is the default receiving
        bin, default assembly bin or default starting location of a SKU. The error
        message lists up to five of those SKUs; change their default locations
        first, then retry.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: locationId
          required: true
          schema:
            type: integer
          description: Location ID
      responses:
        '204':
          description: Location deleted
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Location not found or is not a sub-location
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            The location still holds stock. Its on-hand or reserved quantity is
            non-zero, so it cannot be deleted until the stock is transferred or
            adjusted to zero. Also returned when the location is a SKU's default
            receiving, assembly or starting location.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /companies:
    get:
      operationId: getCompanies
      tags:
        - Companies
      summary: Companies
      description: |
        Get a paginated list of companies with optional filtering and sorting.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Sort Fields

        - `id` - Sort by company ID
        - `created_at` - Sort by creation date (default: `updated_at:desc`)
        - `updated_at` - Sort by last update date (default: `updated_at:desc`)

        Sort format: `field:direction` where direction is `asc` (ascending) or `desc` (descending).

        Examples:
        - `?sort=id:asc` - Sort by ID ascending
        - `?sort=created_at:desc` - Sort by creation date descending
        - `?sort=updated_at:asc` - Sort by update date ascending

        ## Available Filters
        ### String Filters
        - `name`: Company name
        - `type`: Type of business
        - `city`: City
        - `state`: State
        - `country`: Country
        - `zip`: ZIP/Postal code
        - `phone`: Phone number
        - `payment_term`: Payment term
        - `status`: Company status
        - `tag`: Filter by tag name

        ### DateTime Filters
        - `created_at`: When the company was created
        - `updated_at`: When the company was last updated

        ### Custom Field Filters
        Custom fields can be filtered using their field names. Custom field filters are dynamically 
        generated based on the custom fields defined for companies in your system.

        Custom field filters use the format `custom_fields.{field_label}` where `{field_label}` is 
        the exact label of the custom field as defined in your system. The available operators depend 
        on the custom field type:

        - **String/Dropdown fields**: `eq`, `neq`, `contains`, `notcontains`, `in`, `notin`, `set`, `notset`
        - **Number fields**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `notin`, `set`, `notset`
        - **Date fields**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `set`, `notset`

        **Note**: Custom field labels may contain spaces or special characters. When using them in URLs, 
        ensure proper URL encoding (e.g., spaces become `%20` or `+`).

        ## Examples
        ```
        # Find companies by name
        ?name[eq]=Acme Corp

        # Find companies in a specific state
        ?state[eq]=CA

        # Find companies with a specific payment term
        ?payment_term[eq]=Net 30

        # Find companies by tag
        ?tag[eq]=VIP

        # Find companies by status
        ?status[eq]=active

        # Filter by custom field (string) - exact match
        ?custom_fields.Industry[eq]=Manufacturing

        # Filter by custom field (string) - contains
        ?custom_fields.Region[contains]=West

        # Filter by custom field (number) - greater than
        ?custom_fields.Annual Revenue[gt]=1000000

        # Filter by custom field (number) - range
        ?custom_fields.Employee Count[gte]=50&custom_fields.Employee Count[lte]=200

        # Filter by custom field (date) - after date
        ?custom_fields.Contract Start Date[gte]=2024-01-01

        # Filter by custom field (dropdown) - multiple values
        ?custom_fields.Customer Tier[in]=Premium,Enterprise

        # Filter by custom field - has value set
        ?custom_fields.Industry[set]=true

        # Filter by custom field - no value set
        ?custom_fields.Notes[notset]=true

        # Combine custom field filter with other filters
        ?state[eq]=CA&custom_fields.Industry[eq]=Retail&tag[eq]=VIP
        ```
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: sort
          schema:
            type: string
            default: 'updated_at:desc'
          description: |
            Sort results by field and direction. Format: `field:direction`

            Available sort fields:
            - `id` - Company ID
            - `created_at` - Creation date
            - `updated_at` - Last update date (default)

            Examples:
            - `id:asc` - Sort by ID ascending
            - `created_at:desc` - Sort by creation date descending
            - `updated_at:asc` - Sort by update date ascending
        - in: query
          name: fields
          schema:
            type: string
          description: 'Comma-separated list of fields to include in each returned company (field projection). When omitted, the full company object is returned. Example: `fields=id,name,status`.'
        - in: query
          name: name
          schema:
            type: string
          description: Filter by company name
        - in: query
          name: type
          schema:
            type: string
          description: Filter by business type
        - in: query
          name: phone
          schema:
            type: string
          description: Filter by phone number
        - in: query
          name: city
          schema:
            type: string
          description: Filter by city
        - in: query
          name: state
          schema:
            type: string
          description: Filter by state
        - in: query
          name: country
          schema:
            type: string
          description: Filter by country
        - in: query
          name: zip
          schema:
            type: string
          description: Filter by ZIP/Postal code
        - in: query
          name: payment_term
          schema:
            type: string
          description: Filter by payment term
        - in: query
          name: status
          schema:
            type: string
          description: Filter by company status
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by tag name
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
      responses:
        '200':
          description: A list of companies
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the company
                          example: 123456
                        created_at:
                          type: string
                          format: date-time
                          description: When the company was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the company was last updated
                          example: '2023-03-15T14:30:00Z'
                        status:
                          type: string
                          description: Status of the company
                          enum:
                            - active
                            - inactive
                          example: active
                        name:
                          type: string
                          description: Company name
                          example: Acme Corporation
                        type:
                          type: string
                          nullable: true
                          description: Type of business
                          example: Retail
                        phone:
                          type: string
                          nullable: true
                          description: Primary phone number for the company
                          example: 555-123-4567
                        address:
                          type: string
                          nullable: true
                          description: Street address for the company
                          example: 123 Main St
                        address_line_2:
                          type: string
                          nullable: true
                          description: Additional address information
                          example: Suite 500
                        city:
                          type: string
                          nullable: true
                          description: City
                          example: Austin
                        state:
                          type: string
                          nullable: true
                          description: State/province
                          example: TX
                        postal_code:
                          type: string
                          nullable: true
                          description: Postal/ZIP code
                          example: '78701'
                        country:
                          type: string
                          nullable: true
                          description: Country
                          example: USA
                        full_address:
                          type: string
                          nullable: true
                          description: Complete formatted address
                          example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                        shipping_first_name:
                          type: string
                          nullable: true
                          description: First name for shipping contact (legacy field)
                          example: John
                        shipping_last_name:
                          type: string
                          nullable: true
                          description: Last name for shipping contact (legacy field)
                          example: Doe
                        shipping_email:
                          type: string
                          format: email
                          nullable: true
                          description: Email for shipping contact (legacy field)
                          example: shipping@acmecorp.com
                        shipping_phone:
                          type: string
                          nullable: true
                          description: Phone number for shipping contact (legacy field)
                          example: 555-987-6543
                        shipping_address:
                          type: string
                          nullable: true
                          description: Shipping street address (legacy field)
                          example: 456 Warehouse Blvd
                        shipping_city:
                          type: string
                          nullable: true
                          description: Shipping city (legacy field)
                          example: Austin
                        shipping_state:
                          type: string
                          nullable: true
                          description: Shipping state/province (legacy field)
                          example: TX
                        shipping_postal_code:
                          type: string
                          nullable: true
                          description: Shipping postal/ZIP code (legacy field)
                          example: '78745'
                        shipping_country:
                          type: string
                          nullable: true
                          description: Shipping country (legacy field)
                          example: USA
                        shipping_full_address:
                          type: string
                          nullable: true
                          description: Complete formatted shipping address (legacy field)
                          example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                        payment_term:
                          type: string
                          nullable: true
                          description: Payment terms for the company
                          example: Net 30
                        tax_exempt:
                          type: boolean
                          nullable: true
                          description: Whether the company is exempt from taxes
                          example: false
                        tax_rate:
                          type: number
                          format: float
                          nullable: true
                          description: Tax rate applied to the company's orders
                          example: 8.25
                        due_date_days:
                          type: integer
                          nullable: true
                          description: Number of days until payment is due
                          example: 30
                        credit_limit:
                          type: number
                          format: float
                          nullable: true
                          description: Credit limit for the company. `null` means no limit is set.
                          example: 5000
                        header_discount_enabled:
                          type: boolean
                          description: Whether an order-header trade discount is applied by default for this company
                          example: false
                        header_discount_type:
                          type: string
                          nullable: true
                          enum:
                            - PERCENT
                            - FIXED_AMOUNT
                          description: How the header discount is calculated — a percentage of the order or a fixed amount
                          example: PERCENT
                        header_discount_value:
                          type: number
                          format: float
                          nullable: true
                          description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                          example: 5
                        header_discount_effective_from:
                          type: string
                          format: date
                          nullable: true
                          description: Date from which the header discount takes effect (YYYY-MM-DD)
                          example: '2026-01-01'
                        default_currency_code:
                          type: string
                          nullable: true
                          description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                          example: USD
                        price_level:
                          nullable: true
                          description: Price level associated with this company
                          type: object
                          properties:
                            id:
                              type: number
                              description: Unique identifier for the price level
                              example: 123
                            created_at:
                              type: string
                              format: date-time
                              description: When the price level was created
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              description: When the price level was last updated
                              example: '2023-03-15T14:30:00Z'
                            status:
                              type: string
                              description: Status of the price level
                              enum:
                                - active
                                - inactive
                              example: active
                            name:
                              type: string
                              description: Name of the price level
                              example: Wholesale
                            type:
                              type: string
                              description: Type of the price level
                              example: percentage
                            percent_increase:
                              type: number
                              format: float
                              description: Percentage increase (or decrease) for this price level
                              example: 15.5
                        notes:
                          type: string
                          nullable: true
                          description: Additional notes about the company
                          example: 'Key account, requires special handling'
                        fein:
                          type: string
                          nullable: true
                          description: Federal Employer Identification Number
                          example: 12-3456789
                        tags:
                          type: array
                          nullable: true
                          description: List of tags associated with the company
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the tag
                              name:
                                type: string
                                description: Name of the tag
                              description:
                                type: string
                                nullable: true
                                description: Description of the tag
                              icon:
                                type: string
                                nullable: true
                                description: Icon identifier or URL for the tag
                              color:
                                type: string
                                nullable: true
                                description: Color code for the tag
                            required:
                              - id
                              - name
                        default_shipping:
                          nullable: true
                          description: Default shipping address
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the shipping address
                              example: 789
                            created_at:
                              type: string
                              format: date-time
                              description: When the shipping address was created
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              description: When the shipping address was last updated
                              example: '2023-03-15T14:30:00Z'
                            company_id:
                              type: integer
                              description: ID of the company this shipping address belongs to
                              example: 123456
                            company_name:
                              type: string
                              nullable: true
                              description: Name of the company
                              example: Acme Corporation
                            address:
                              type: string
                              description: Street address
                              example: 456 Warehouse Blvd
                            address_line_2:
                              type: string
                              nullable: true
                              description: Additional address information
                              example: Building 2
                            city:
                              type: string
                              description: City
                              example: Austin
                            state:
                              type: string
                              description: State/province
                              example: TX
                            postal_code:
                              type: string
                              description: Postal/ZIP code
                              example: '78745'
                            country:
                              type: string
                              description: Country
                              example: USA
                            full_address:
                              type: string
                              description: Complete formatted address
                              example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                            full_name:
                              type: string
                              description: Full name of the contact person
                              example: John Doe
                            first_name:
                              type: string
                              nullable: true
                              description: First name of the contact person
                              example: John
                            last_name:
                              type: string
                              nullable: true
                              description: Last name of the contact person
                              example: Doe
                            phone:
                              type: string
                              nullable: true
                              description: Phone number
                              example: 555-987-6543
                            email:
                              type: string
                              format: email
                              nullable: true
                              description: Email address
                              example: shipping@acmecorp.com
                            is_default:
                              type: boolean
                              description: Whether this is the default shipping address
                              example: true
                          required:
                            - id
                            - company_id
                            - address
                            - city
                            - state
                            - postal_code
                            - country
                        shipping_addresses:
                          type: array
                          nullable: true
                          description: List of shipping addresses for the company
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the shipping address
                                example: 789
                              created_at:
                                type: string
                                format: date-time
                                description: When the shipping address was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the shipping address was last updated
                                example: '2023-03-15T14:30:00Z'
                              company_id:
                                type: integer
                                description: ID of the company this shipping address belongs to
                                example: 123456
                              company_name:
                                type: string
                                nullable: true
                                description: Name of the company
                                example: Acme Corporation
                              address:
                                type: string
                                description: Street address
                                example: 456 Warehouse Blvd
                              address_line_2:
                                type: string
                                nullable: true
                                description: Additional address information
                                example: Building 2
                              city:
                                type: string
                                description: City
                                example: Austin
                              state:
                                type: string
                                description: State/province
                                example: TX
                              postal_code:
                                type: string
                                description: Postal/ZIP code
                                example: '78745'
                              country:
                                type: string
                                description: Country
                                example: USA
                              full_address:
                                type: string
                                description: Complete formatted address
                                example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                              full_name:
                                type: string
                                description: Full name of the contact person
                                example: John Doe
                              first_name:
                                type: string
                                nullable: true
                                description: First name of the contact person
                                example: John
                              last_name:
                                type: string
                                nullable: true
                                description: Last name of the contact person
                                example: Doe
                              phone:
                                type: string
                                nullable: true
                                description: Phone number
                                example: 555-987-6543
                              email:
                                type: string
                                format: email
                                nullable: true
                                description: Email address
                                example: shipping@acmecorp.com
                              is_default:
                                type: boolean
                                description: Whether this is the default shipping address
                                example: true
                            required:
                              - id
                              - company_id
                              - address
                              - city
                              - state
                              - postal_code
                              - country
                        billing_info:
                          type: object
                          nullable: true
                          description: Billing information
                          properties:
                            id:
                              type: integer
                              example: 456
                            created_at:
                              type: string
                              format: date-time
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              example: '2023-03-15T14:30:00Z'
                            first_name:
                              type: string
                              nullable: true
                              example: Jane
                            last_name:
                              type: string
                              nullable: true
                              example: Smith
                            email:
                              type: string
                              format: email
                              nullable: true
                              example: accounting@acmecorp.com
                            receiving_bank_name:
                              type: string
                              nullable: true
                              example: First National Bank
                            receiving_bank_address:
                              type: string
                              nullable: true
                              example: '789 Finance Street, Austin, TX 78701'
                        client_type:
                          type: object
                          nullable: true
                          description: Type of client
                          properties:
                            id:
                              type: integer
                              example: 123
                            created_at:
                              type: string
                              format: date-time
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              example: '2023-03-15T14:30:00Z'
                            name:
                              type: string
                              example: Retail
                            description:
                              type: string
                              nullable: true
                              example: Retail business client
                        parent_company_id:
                          type: integer
                          nullable: true
                          description: ID of the parent company
                          example: 456
                        invoice_export_template_id:
                          type: integer
                          nullable: true
                          description: ID of the invoice export template
                          example: 789
                        custom_fields:
                          type: object
                          description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          example:
                            Industry: Manufacturing
                            Region: Southwest
                            Annual Revenue: $5M-$10M
                        assigned_sales_reps:
                          type: array
                          description: |
                            Sales rep users assigned to this company (Go Team members). Resolved from the company's
                            `goTeamMember.user` relation. Only present when the relation is loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: User ID of the assigned sales rep
                                example: 42
                              email:
                                type: string
                                description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                example: rep@example.com
                              first_name:
                                type: string
                                nullable: true
                                example: Jane
                              last_name:
                                type: string
                                nullable: true
                                example: Doe
                        sales_channel:
                          allOf:
                            - type: object
                              properties:
                                id:
                                  type: integer
                                  description: Sales channel ID.
                                status:
                                  type: string
                                  description: Sales channel status (e.g. active).
                                label:
                                  type: string
                                  nullable: true
                                  description: Human-readable channel label.
                                channel_type:
                                  type: string
                                  nullable: true
                                  description: Channel type (e.g. the integration/platform the channel represents).
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                          nullable: true
                          description: The company's default sales channel. Only present when the relation is loaded.
                      required:
                        - id
                        - name
                        - status
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
    post:
      operationId: createCompany
      tags:
        - Companies
      summary: Create a company
      description: 'Create a new company with optional tags, custom fields, and shipping addresses'
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Company name
                  example: Acme Corporation
                client_type:
                  type: object
                  nullable: true
                  description: 'Client type information. Can provide either id or name. If name is provided and type doesn''t exist, it will be created.'
                  properties:
                    id:
                      type: integer
                      description: ID of the client type
                      example: 123
                    name:
                      type: string
                      description: Name of the client type
                      example: Retail
                price_level:
                  type: object
                  nullable: true
                  description: |
                    Default price level to assign to the company. Provide either `id` or `name`;
                    `id` takes precedence. The price level must already exist and be active —
                    unlike `client_type`, price levels are never auto-created (they are
                    admin-configured entities with `percent_increase` values). A non-matching
                    `id` or `name` returns a `422`. Omit the field to leave it unchanged.
                  properties:
                    id:
                      type: integer
                      description: ID of an existing active price level (preferred when known)
                      example: 123
                    name:
                      type: string
                      description: Name of an existing active price level (used when `id` is not provided)
                      example: Wholesale
                parent_company_id:
                  type: integer
                  nullable: true
                  description: ID of the parent company
                  example: 456
                address:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Street address for the company
                  example: 123 Main St
                address_line_2:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Additional address information
                  example: Suite 500
                city:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: City
                  example: Austin
                state:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: State/province
                  example: TX
                postal_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Postal/ZIP code
                  example: '78701'
                country:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Country
                  example: USA
                phone:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Primary phone number for the company
                  example: 555-123-4567
                fein:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Federal Employer Identification Number
                  example: 12-3456789
                tax_exempt:
                  type: boolean
                  nullable: true
                  description: Whether the company is exempt from taxes
                  example: false
                notes:
                  type: string
                  nullable: true
                  description: Additional notes about the company
                  example: 'Key account, requires special handling'
                payment_term:
                  type: string
                  nullable: true
                  description: Payment terms label (e.g. "Net 30"). Must match a supported payment term.
                  example: Net 30
                due_date_days:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: Number of days until payment is due (used when payment_term is "Custom")
                  example: 45
                credit_limit:
                  type: number
                  nullable: true
                  minimum: 0
                  description: Credit limit for the company. Omit or send `null` for no limit.
                  example: 5000
                header_discount_enabled:
                  type: boolean
                  nullable: true
                  description: Whether to apply an order-header trade discount by default for this company
                  example: false
                header_discount_type:
                  type: string
                  nullable: true
                  enum:
                    - PERCENT
                    - FIXED_AMOUNT
                  description: How the header discount is calculated — a percentage of the order or a fixed amount
                  example: PERCENT
                header_discount_value:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                  example: 5
                header_discount_effective_from:
                  type: string
                  format: date
                  nullable: true
                  description: Date from which the header discount takes effect (YYYY-MM-DD)
                  example: '2026-01-01'
                default_currency_code:
                  type: string
                  nullable: true
                  minLength: 3
                  maxLength: 3
                  description: Default ISO 4217 currency code for this company (3 letters). Auto-applied to new orders created for the company. Must be exactly three letters; other 3-character values are rejected.
                  example: USD
                b2b_product_template_id:
                  type: integer
                  nullable: true
                  description: 'ID of the B2B Product Template (see `GET /b2b-product-templates`) assigned to this company, which controls the SKUs it sees on the B2B Portal. Must be an existing template.'
                  example: 12
                tags:
                  type: array
                  nullable: true
                  description: List of tags to associate with the company
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - wholesale
                    - preferred
                custom_fields:
                  type: object
                  nullable: true
                  description: Custom field values for the company
                  additionalProperties:
                    type: string
                  example:
                    Industry: Manufacturing
                    Region: Southwest
                shipping_addresses:
                  type: array
                  nullable: true
                  description: Array of shipping addresses to create for the company
                  items:
                    type: object
                    required:
                      - address_1
                      - city
                      - state
                      - country
                      - zip
                    properties:
                      address_1:
                        type: string
                        maxLength: 255
                        description: Street address
                        example: 456 Warehouse Blvd
                      address_2:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Additional address information
                        example: Building 2
                      city:
                        type: string
                        maxLength: 255
                        description: City
                        example: Austin
                      state:
                        type: string
                        maxLength: 255
                        description: State/province
                        example: TX
                      country:
                        type: string
                        maxLength: 255
                        description: Country
                        example: USA
                      zip:
                        type: string
                        maxLength: 255
                        description: Postal/ZIP code
                        example: '78745'
                      first_name:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: First name of the contact person
                        example: John
                      last_name:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Last name of the contact person
                        example: Doe
                      email:
                        type: string
                        format: email
                        maxLength: 255
                        nullable: true
                        description: Email address
                        example: shipping@acmecorp.com
                      phone:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Phone number
                        example: 555-987-6543
                      is_default:
                        type: boolean
                        nullable: true
                        description: Whether this is the default shipping address
                        example: true
                assigned_sales_reps:
                  type: array
                  nullable: true
                  description: |
                    Sales rep users (Go Team members) to assign to this company. Each entry must
                    include `id` or `email`. Passing this field syncs the list — entries not present
                    are removed. Pass an empty array to clear all assignments.
                  items:
                    type: object
                    properties:
                      id:
                        type: integer
                        nullable: true
                        description: User ID (preferred when known)
                        example: 42
                      email:
                        type: string
                        format: email
                        maxLength: 255
                        nullable: true
                        description: User email (used to look up the user when `id` is not provided)
                        example: rep@example.com
                sales_channel:
                  type: object
                  nullable: true
                  description: |
                    Set the company's default sales channel. Provide `id` or `label` to match an
                    existing active channel — `id` takes precedence. Channels are never auto-created.
                    Pass an explicit `null` to clear the assignment.
                  properties:
                    id:
                      type: integer
                      nullable: true
                      description: Sales channel ID (preferred when known).
                      example: 12
                    label:
                      type: string
                      nullable: true
                      description: Sales channel label (used to look up the channel when `id` is not provided).
                      example: Wholesale
      responses:
        '201':
          description: Company successfully created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the company
                        example: 123456
                      created_at:
                        type: string
                        format: date-time
                        description: When the company was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the company was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Status of the company
                        enum:
                          - active
                          - inactive
                        example: active
                      name:
                        type: string
                        description: Company name
                        example: Acme Corporation
                      type:
                        type: string
                        nullable: true
                        description: Type of business
                        example: Retail
                      phone:
                        type: string
                        nullable: true
                        description: Primary phone number for the company
                        example: 555-123-4567
                      address:
                        type: string
                        nullable: true
                        description: Street address for the company
                        example: 123 Main St
                      address_line_2:
                        type: string
                        nullable: true
                        description: Additional address information
                        example: Suite 500
                      city:
                        type: string
                        nullable: true
                        description: City
                        example: Austin
                      state:
                        type: string
                        nullable: true
                        description: State/province
                        example: TX
                      postal_code:
                        type: string
                        nullable: true
                        description: Postal/ZIP code
                        example: '78701'
                      country:
                        type: string
                        nullable: true
                        description: Country
                        example: USA
                      full_address:
                        type: string
                        nullable: true
                        description: Complete formatted address
                        example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                      shipping_first_name:
                        type: string
                        nullable: true
                        description: First name for shipping contact (legacy field)
                        example: John
                      shipping_last_name:
                        type: string
                        nullable: true
                        description: Last name for shipping contact (legacy field)
                        example: Doe
                      shipping_email:
                        type: string
                        format: email
                        nullable: true
                        description: Email for shipping contact (legacy field)
                        example: shipping@acmecorp.com
                      shipping_phone:
                        type: string
                        nullable: true
                        description: Phone number for shipping contact (legacy field)
                        example: 555-987-6543
                      shipping_address:
                        type: string
                        nullable: true
                        description: Shipping street address (legacy field)
                        example: 456 Warehouse Blvd
                      shipping_city:
                        type: string
                        nullable: true
                        description: Shipping city (legacy field)
                        example: Austin
                      shipping_state:
                        type: string
                        nullable: true
                        description: Shipping state/province (legacy field)
                        example: TX
                      shipping_postal_code:
                        type: string
                        nullable: true
                        description: Shipping postal/ZIP code (legacy field)
                        example: '78745'
                      shipping_country:
                        type: string
                        nullable: true
                        description: Shipping country (legacy field)
                        example: USA
                      shipping_full_address:
                        type: string
                        nullable: true
                        description: Complete formatted shipping address (legacy field)
                        example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                      payment_term:
                        type: string
                        nullable: true
                        description: Payment terms for the company
                        example: Net 30
                      tax_exempt:
                        type: boolean
                        nullable: true
                        description: Whether the company is exempt from taxes
                        example: false
                      tax_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Tax rate applied to the company's orders
                        example: 8.25
                      due_date_days:
                        type: integer
                        nullable: true
                        description: Number of days until payment is due
                        example: 30
                      credit_limit:
                        type: number
                        format: float
                        nullable: true
                        description: Credit limit for the company. `null` means no limit is set.
                        example: 5000
                      header_discount_enabled:
                        type: boolean
                        description: Whether an order-header trade discount is applied by default for this company
                        example: false
                      header_discount_type:
                        type: string
                        nullable: true
                        enum:
                          - PERCENT
                          - FIXED_AMOUNT
                        description: How the header discount is calculated — a percentage of the order or a fixed amount
                        example: PERCENT
                      header_discount_value:
                        type: number
                        format: float
                        nullable: true
                        description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                        example: 5
                      header_discount_effective_from:
                        type: string
                        format: date
                        nullable: true
                        description: Date from which the header discount takes effect (YYYY-MM-DD)
                        example: '2026-01-01'
                      default_currency_code:
                        type: string
                        nullable: true
                        description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                        example: USD
                      price_level:
                        nullable: true
                        description: Price level associated with this company
                        type: object
                        properties:
                          id:
                            type: number
                            description: Unique identifier for the price level
                            example: 123
                          created_at:
                            type: string
                            format: date-time
                            description: When the price level was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the price level was last updated
                            example: '2023-03-15T14:30:00Z'
                          status:
                            type: string
                            description: Status of the price level
                            enum:
                              - active
                              - inactive
                            example: active
                          name:
                            type: string
                            description: Name of the price level
                            example: Wholesale
                          type:
                            type: string
                            description: Type of the price level
                            example: percentage
                          percent_increase:
                            type: number
                            format: float
                            description: Percentage increase (or decrease) for this price level
                            example: 15.5
                      notes:
                        type: string
                        nullable: true
                        description: Additional notes about the company
                        example: 'Key account, requires special handling'
                      fein:
                        type: string
                        nullable: true
                        description: Federal Employer Identification Number
                        example: 12-3456789
                      tags:
                        type: array
                        nullable: true
                        description: List of tags associated with the company
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      default_shipping:
                        nullable: true
                        description: Default shipping address
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the shipping address
                            example: 789
                          created_at:
                            type: string
                            format: date-time
                            description: When the shipping address was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the shipping address was last updated
                            example: '2023-03-15T14:30:00Z'
                          company_id:
                            type: integer
                            description: ID of the company this shipping address belongs to
                            example: 123456
                          company_name:
                            type: string
                            nullable: true
                            description: Name of the company
                            example: Acme Corporation
                          address:
                            type: string
                            description: Street address
                            example: 456 Warehouse Blvd
                          address_line_2:
                            type: string
                            nullable: true
                            description: Additional address information
                            example: Building 2
                          city:
                            type: string
                            description: City
                            example: Austin
                          state:
                            type: string
                            description: State/province
                            example: TX
                          postal_code:
                            type: string
                            description: Postal/ZIP code
                            example: '78745'
                          country:
                            type: string
                            description: Country
                            example: USA
                          full_address:
                            type: string
                            description: Complete formatted address
                            example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                          full_name:
                            type: string
                            description: Full name of the contact person
                            example: John Doe
                          first_name:
                            type: string
                            nullable: true
                            description: First name of the contact person
                            example: John
                          last_name:
                            type: string
                            nullable: true
                            description: Last name of the contact person
                            example: Doe
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                            example: 555-987-6543
                          email:
                            type: string
                            format: email
                            nullable: true
                            description: Email address
                            example: shipping@acmecorp.com
                          is_default:
                            type: boolean
                            description: Whether this is the default shipping address
                            example: true
                        required:
                          - id
                          - company_id
                          - address
                          - city
                          - state
                          - postal_code
                          - country
                      shipping_addresses:
                        type: array
                        nullable: true
                        description: List of shipping addresses for the company
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the shipping address
                              example: 789
                            created_at:
                              type: string
                              format: date-time
                              description: When the shipping address was created
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              description: When the shipping address was last updated
                              example: '2023-03-15T14:30:00Z'
                            company_id:
                              type: integer
                              description: ID of the company this shipping address belongs to
                              example: 123456
                            company_name:
                              type: string
                              nullable: true
                              description: Name of the company
                              example: Acme Corporation
                            address:
                              type: string
                              description: Street address
                              example: 456 Warehouse Blvd
                            address_line_2:
                              type: string
                              nullable: true
                              description: Additional address information
                              example: Building 2
                            city:
                              type: string
                              description: City
                              example: Austin
                            state:
                              type: string
                              description: State/province
                              example: TX
                            postal_code:
                              type: string
                              description: Postal/ZIP code
                              example: '78745'
                            country:
                              type: string
                              description: Country
                              example: USA
                            full_address:
                              type: string
                              description: Complete formatted address
                              example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                            full_name:
                              type: string
                              description: Full name of the contact person
                              example: John Doe
                            first_name:
                              type: string
                              nullable: true
                              description: First name of the contact person
                              example: John
                            last_name:
                              type: string
                              nullable: true
                              description: Last name of the contact person
                              example: Doe
                            phone:
                              type: string
                              nullable: true
                              description: Phone number
                              example: 555-987-6543
                            email:
                              type: string
                              format: email
                              nullable: true
                              description: Email address
                              example: shipping@acmecorp.com
                            is_default:
                              type: boolean
                              description: Whether this is the default shipping address
                              example: true
                          required:
                            - id
                            - company_id
                            - address
                            - city
                            - state
                            - postal_code
                            - country
                      billing_info:
                        type: object
                        nullable: true
                        description: Billing information
                        properties:
                          id:
                            type: integer
                            example: 456
                          created_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          first_name:
                            type: string
                            nullable: true
                            example: Jane
                          last_name:
                            type: string
                            nullable: true
                            example: Smith
                          email:
                            type: string
                            format: email
                            nullable: true
                            example: accounting@acmecorp.com
                          receiving_bank_name:
                            type: string
                            nullable: true
                            example: First National Bank
                          receiving_bank_address:
                            type: string
                            nullable: true
                            example: '789 Finance Street, Austin, TX 78701'
                      client_type:
                        type: object
                        nullable: true
                        description: Type of client
                        properties:
                          id:
                            type: integer
                            example: 123
                          created_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          name:
                            type: string
                            example: Retail
                          description:
                            type: string
                            nullable: true
                            example: Retail business client
                      parent_company_id:
                        type: integer
                        nullable: true
                        description: ID of the parent company
                        example: 456
                      invoice_export_template_id:
                        type: integer
                        nullable: true
                        description: ID of the invoice export template
                        example: 789
                      custom_fields:
                        type: object
                        description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Industry: Manufacturing
                          Region: Southwest
                          Annual Revenue: $5M-$10M
                      assigned_sales_reps:
                        type: array
                        description: |
                          Sales rep users assigned to this company (Go Team members). Resolved from the company's
                          `goTeamMember.user` relation. Only present when the relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: User ID of the assigned sales rep
                              example: 42
                            email:
                              type: string
                              description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                              example: rep@example.com
                            first_name:
                              type: string
                              nullable: true
                              example: Jane
                            last_name:
                              type: string
                              nullable: true
                              example: Doe
                      sales_channel:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                                description: Sales channel ID.
                              status:
                                type: string
                                description: Sales channel status (e.g. active).
                              label:
                                type: string
                                nullable: true
                                description: Human-readable channel label.
                              channel_type:
                                type: string
                                nullable: true
                                description: Channel type (e.g. the integration/platform the channel represents).
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                        description: The company's default sales channel. Only present when the relation is loaded.
                    required:
                      - id
                      - name
                      - status
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/companies/{companyId}/shipping-addresses':
    get:
      operationId: getCompanyShippingAddresses
      tags:
        - Companies
      summary: List shipping addresses
      description: List all shipping addresses for a company.
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the shipping address
                          example: 789
                        created_at:
                          type: string
                          format: date-time
                          description: When the shipping address was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the shipping address was last updated
                          example: '2023-03-15T14:30:00Z'
                        company_id:
                          type: integer
                          description: ID of the company this shipping address belongs to
                          example: 123456
                        company_name:
                          type: string
                          nullable: true
                          description: Name of the company
                          example: Acme Corporation
                        address:
                          type: string
                          description: Street address
                          example: 456 Warehouse Blvd
                        address_line_2:
                          type: string
                          nullable: true
                          description: Additional address information
                          example: Building 2
                        city:
                          type: string
                          description: City
                          example: Austin
                        state:
                          type: string
                          description: State/province
                          example: TX
                        postal_code:
                          type: string
                          description: Postal/ZIP code
                          example: '78745'
                        country:
                          type: string
                          description: Country
                          example: USA
                        full_address:
                          type: string
                          description: Complete formatted address
                          example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                        full_name:
                          type: string
                          description: Full name of the contact person
                          example: John Doe
                        first_name:
                          type: string
                          nullable: true
                          description: First name of the contact person
                          example: John
                        last_name:
                          type: string
                          nullable: true
                          description: Last name of the contact person
                          example: Doe
                        phone:
                          type: string
                          nullable: true
                          description: Phone number
                          example: 555-987-6543
                        email:
                          type: string
                          format: email
                          nullable: true
                          description: Email address
                          example: shipping@acmecorp.com
                        is_default:
                          type: boolean
                          description: Whether this is the default shipping address
                          example: true
                      required:
                        - id
                        - company_id
                        - address
                        - city
                        - state
                        - postal_code
                        - country
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    post:
      operationId: createCompanyShippingAddress
      tags:
        - Companies
      summary: Create shipping address
      description: Create a new shipping address for a company
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - address_1
                - city
                - state
                - country
                - zip
              properties:
                address_1:
                  type: string
                  maxLength: 255
                  description: Street address
                  example: 456 Warehouse Blvd
                address_2:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Additional address information
                  example: Building 2
                city:
                  type: string
                  maxLength: 255
                  description: City
                  example: Austin
                state:
                  type: string
                  maxLength: 255
                  description: State/province
                  example: TX
                country:
                  type: string
                  maxLength: 255
                  description: Country
                  example: USA
                zip:
                  type: string
                  maxLength: 255
                  description: Postal/ZIP code
                  example: '78745'
                first_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: First name of the contact person
                  example: John
                last_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Last name of the contact person
                  example: Doe
                email:
                  type: string
                  format: email
                  maxLength: 255
                  nullable: true
                  description: Email address
                  example: shipping@acmecorp.com
                phone:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Phone number
                  example: 555-987-6543
                is_default:
                  type: boolean
                  nullable: true
                  description: 'Whether this is the default shipping address. If set to true, all other shipping addresses for this company will be set to non-default.'
                  example: true
      responses:
        '201':
          description: Shipping address successfully created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the shipping address
                        example: 789
                      created_at:
                        type: string
                        format: date-time
                        description: When the shipping address was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the shipping address was last updated
                        example: '2023-03-15T14:30:00Z'
                      company_id:
                        type: integer
                        description: ID of the company this shipping address belongs to
                        example: 123456
                      company_name:
                        type: string
                        nullable: true
                        description: Name of the company
                        example: Acme Corporation
                      address:
                        type: string
                        description: Street address
                        example: 456 Warehouse Blvd
                      address_line_2:
                        type: string
                        nullable: true
                        description: Additional address information
                        example: Building 2
                      city:
                        type: string
                        description: City
                        example: Austin
                      state:
                        type: string
                        description: State/province
                        example: TX
                      postal_code:
                        type: string
                        description: Postal/ZIP code
                        example: '78745'
                      country:
                        type: string
                        description: Country
                        example: USA
                      full_address:
                        type: string
                        description: Complete formatted address
                        example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                      full_name:
                        type: string
                        description: Full name of the contact person
                        example: John Doe
                      first_name:
                        type: string
                        nullable: true
                        description: First name of the contact person
                        example: John
                      last_name:
                        type: string
                        nullable: true
                        description: Last name of the contact person
                        example: Doe
                      phone:
                        type: string
                        nullable: true
                        description: Phone number
                        example: 555-987-6543
                      email:
                        type: string
                        format: email
                        nullable: true
                        description: Email address
                        example: shipping@acmecorp.com
                      is_default:
                        type: boolean
                        description: Whether this is the default shipping address
                        example: true
                    required:
                      - id
                      - company_id
                      - address
                      - city
                      - state
                      - postal_code
                      - country
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/companies/{companyId}/shipping-addresses/{shippingAddressId}':
    post:
      operationId: updateCompanyShippingAddress
      tags:
        - Companies
      summary: Update shipping address
      description: Update an existing shipping address for a company
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
        - name: shippingAddressId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the shipping address
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                address_1:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Street address
                  example: 456 Warehouse Blvd
                address_2:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Additional address information
                  example: Building 2
                city:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: City
                  example: Austin
                state:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: State/province
                  example: TX
                country:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Country
                  example: USA
                zip:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Postal/ZIP code
                  example: '78745'
                first_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: First name of the contact person
                  example: John
                last_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Last name of the contact person
                  example: Doe
                email:
                  type: string
                  format: email
                  maxLength: 255
                  nullable: true
                  description: Email address
                  example: shipping@acmecorp.com
                phone:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Phone number
                  example: 555-987-6543
                is_default:
                  type: boolean
                  nullable: true
                  description: 'Whether this is the default shipping address. If set to true, all other shipping addresses for this company will be set to non-default.'
                  example: true
      responses:
        '200':
          description: Shipping address successfully updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the shipping address
                        example: 789
                      created_at:
                        type: string
                        format: date-time
                        description: When the shipping address was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the shipping address was last updated
                        example: '2023-03-15T14:30:00Z'
                      company_id:
                        type: integer
                        description: ID of the company this shipping address belongs to
                        example: 123456
                      company_name:
                        type: string
                        nullable: true
                        description: Name of the company
                        example: Acme Corporation
                      address:
                        type: string
                        description: Street address
                        example: 456 Warehouse Blvd
                      address_line_2:
                        type: string
                        nullable: true
                        description: Additional address information
                        example: Building 2
                      city:
                        type: string
                        description: City
                        example: Austin
                      state:
                        type: string
                        description: State/province
                        example: TX
                      postal_code:
                        type: string
                        description: Postal/ZIP code
                        example: '78745'
                      country:
                        type: string
                        description: Country
                        example: USA
                      full_address:
                        type: string
                        description: Complete formatted address
                        example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                      full_name:
                        type: string
                        description: Full name of the contact person
                        example: John Doe
                      first_name:
                        type: string
                        nullable: true
                        description: First name of the contact person
                        example: John
                      last_name:
                        type: string
                        nullable: true
                        description: Last name of the contact person
                        example: Doe
                      phone:
                        type: string
                        nullable: true
                        description: Phone number
                        example: 555-987-6543
                      email:
                        type: string
                        format: email
                        nullable: true
                        description: Email address
                        example: shipping@acmecorp.com
                      is_default:
                        type: boolean
                        description: Whether this is the default shipping address
                        example: true
                    required:
                      - id
                      - company_id
                      - address
                      - city
                      - state
                      - postal_code
                      - country
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteCompanyShippingAddress
      tags:
        - Companies
      summary: Delete shipping address
      description: Delete a shipping address for a company
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
        - name: shippingAddressId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the shipping address
      responses:
        '204':
          description: Shipping address successfully deleted
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  '/companies/{companyId}':
    get:
      operationId: getCompany
      tags:
        - Companies
      summary: Company
      description: Get detailed information for a specific company
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      responses:
        '200':
          description: Company details
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the company
                        example: 123456
                      created_at:
                        type: string
                        format: date-time
                        description: When the company was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the company was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Status of the company
                        enum:
                          - active
                          - inactive
                        example: active
                      name:
                        type: string
                        description: Company name
                        example: Acme Corporation
                      type:
                        type: string
                        nullable: true
                        description: Type of business
                        example: Retail
                      phone:
                        type: string
                        nullable: true
                        description: Primary phone number for the company
                        example: 555-123-4567
                      address:
                        type: string
                        nullable: true
                        description: Street address for the company
                        example: 123 Main St
                      address_line_2:
                        type: string
                        nullable: true
                        description: Additional address information
                        example: Suite 500
                      city:
                        type: string
                        nullable: true
                        description: City
                        example: Austin
                      state:
                        type: string
                        nullable: true
                        description: State/province
                        example: TX
                      postal_code:
                        type: string
                        nullable: true
                        description: Postal/ZIP code
                        example: '78701'
                      country:
                        type: string
                        nullable: true
                        description: Country
                        example: USA
                      full_address:
                        type: string
                        nullable: true
                        description: Complete formatted address
                        example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                      shipping_first_name:
                        type: string
                        nullable: true
                        description: First name for shipping contact (legacy field)
                        example: John
                      shipping_last_name:
                        type: string
                        nullable: true
                        description: Last name for shipping contact (legacy field)
                        example: Doe
                      shipping_email:
                        type: string
                        format: email
                        nullable: true
                        description: Email for shipping contact (legacy field)
                        example: shipping@acmecorp.com
                      shipping_phone:
                        type: string
                        nullable: true
                        description: Phone number for shipping contact (legacy field)
                        example: 555-987-6543
                      shipping_address:
                        type: string
                        nullable: true
                        description: Shipping street address (legacy field)
                        example: 456 Warehouse Blvd
                      shipping_city:
                        type: string
                        nullable: true
                        description: Shipping city (legacy field)
                        example: Austin
                      shipping_state:
                        type: string
                        nullable: true
                        description: Shipping state/province (legacy field)
                        example: TX
                      shipping_postal_code:
                        type: string
                        nullable: true
                        description: Shipping postal/ZIP code (legacy field)
                        example: '78745'
                      shipping_country:
                        type: string
                        nullable: true
                        description: Shipping country (legacy field)
                        example: USA
                      shipping_full_address:
                        type: string
                        nullable: true
                        description: Complete formatted shipping address (legacy field)
                        example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                      payment_term:
                        type: string
                        nullable: true
                        description: Payment terms for the company
                        example: Net 30
                      tax_exempt:
                        type: boolean
                        nullable: true
                        description: Whether the company is exempt from taxes
                        example: false
                      tax_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Tax rate applied to the company's orders
                        example: 8.25
                      due_date_days:
                        type: integer
                        nullable: true
                        description: Number of days until payment is due
                        example: 30
                      credit_limit:
                        type: number
                        format: float
                        nullable: true
                        description: Credit limit for the company. `null` means no limit is set.
                        example: 5000
                      header_discount_enabled:
                        type: boolean
                        description: Whether an order-header trade discount is applied by default for this company
                        example: false
                      header_discount_type:
                        type: string
                        nullable: true
                        enum:
                          - PERCENT
                          - FIXED_AMOUNT
                        description: How the header discount is calculated — a percentage of the order or a fixed amount
                        example: PERCENT
                      header_discount_value:
                        type: number
                        format: float
                        nullable: true
                        description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                        example: 5
                      header_discount_effective_from:
                        type: string
                        format: date
                        nullable: true
                        description: Date from which the header discount takes effect (YYYY-MM-DD)
                        example: '2026-01-01'
                      default_currency_code:
                        type: string
                        nullable: true
                        description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                        example: USD
                      price_level:
                        nullable: true
                        description: Price level associated with this company
                        type: object
                        properties:
                          id:
                            type: number
                            description: Unique identifier for the price level
                            example: 123
                          created_at:
                            type: string
                            format: date-time
                            description: When the price level was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the price level was last updated
                            example: '2023-03-15T14:30:00Z'
                          status:
                            type: string
                            description: Status of the price level
                            enum:
                              - active
                              - inactive
                            example: active
                          name:
                            type: string
                            description: Name of the price level
                            example: Wholesale
                          type:
                            type: string
                            description: Type of the price level
                            example: percentage
                          percent_increase:
                            type: number
                            format: float
                            description: Percentage increase (or decrease) for this price level
                            example: 15.5
                      notes:
                        type: string
                        nullable: true
                        description: Additional notes about the company
                        example: 'Key account, requires special handling'
                      fein:
                        type: string
                        nullable: true
                        description: Federal Employer Identification Number
                        example: 12-3456789
                      tags:
                        type: array
                        nullable: true
                        description: List of tags associated with the company
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      default_shipping:
                        nullable: true
                        description: Default shipping address
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the shipping address
                            example: 789
                          created_at:
                            type: string
                            format: date-time
                            description: When the shipping address was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the shipping address was last updated
                            example: '2023-03-15T14:30:00Z'
                          company_id:
                            type: integer
                            description: ID of the company this shipping address belongs to
                            example: 123456
                          company_name:
                            type: string
                            nullable: true
                            description: Name of the company
                            example: Acme Corporation
                          address:
                            type: string
                            description: Street address
                            example: 456 Warehouse Blvd
                          address_line_2:
                            type: string
                            nullable: true
                            description: Additional address information
                            example: Building 2
                          city:
                            type: string
                            description: City
                            example: Austin
                          state:
                            type: string
                            description: State/province
                            example: TX
                          postal_code:
                            type: string
                            description: Postal/ZIP code
                            example: '78745'
                          country:
                            type: string
                            description: Country
                            example: USA
                          full_address:
                            type: string
                            description: Complete formatted address
                            example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                          full_name:
                            type: string
                            description: Full name of the contact person
                            example: John Doe
                          first_name:
                            type: string
                            nullable: true
                            description: First name of the contact person
                            example: John
                          last_name:
                            type: string
                            nullable: true
                            description: Last name of the contact person
                            example: Doe
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                            example: 555-987-6543
                          email:
                            type: string
                            format: email
                            nullable: true
                            description: Email address
                            example: shipping@acmecorp.com
                          is_default:
                            type: boolean
                            description: Whether this is the default shipping address
                            example: true
                        required:
                          - id
                          - company_id
                          - address
                          - city
                          - state
                          - postal_code
                          - country
                      shipping_addresses:
                        type: array
                        nullable: true
                        description: List of shipping addresses for the company
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the shipping address
                              example: 789
                            created_at:
                              type: string
                              format: date-time
                              description: When the shipping address was created
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              description: When the shipping address was last updated
                              example: '2023-03-15T14:30:00Z'
                            company_id:
                              type: integer
                              description: ID of the company this shipping address belongs to
                              example: 123456
                            company_name:
                              type: string
                              nullable: true
                              description: Name of the company
                              example: Acme Corporation
                            address:
                              type: string
                              description: Street address
                              example: 456 Warehouse Blvd
                            address_line_2:
                              type: string
                              nullable: true
                              description: Additional address information
                              example: Building 2
                            city:
                              type: string
                              description: City
                              example: Austin
                            state:
                              type: string
                              description: State/province
                              example: TX
                            postal_code:
                              type: string
                              description: Postal/ZIP code
                              example: '78745'
                            country:
                              type: string
                              description: Country
                              example: USA
                            full_address:
                              type: string
                              description: Complete formatted address
                              example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                            full_name:
                              type: string
                              description: Full name of the contact person
                              example: John Doe
                            first_name:
                              type: string
                              nullable: true
                              description: First name of the contact person
                              example: John
                            last_name:
                              type: string
                              nullable: true
                              description: Last name of the contact person
                              example: Doe
                            phone:
                              type: string
                              nullable: true
                              description: Phone number
                              example: 555-987-6543
                            email:
                              type: string
                              format: email
                              nullable: true
                              description: Email address
                              example: shipping@acmecorp.com
                            is_default:
                              type: boolean
                              description: Whether this is the default shipping address
                              example: true
                          required:
                            - id
                            - company_id
                            - address
                            - city
                            - state
                            - postal_code
                            - country
                      billing_info:
                        type: object
                        nullable: true
                        description: Billing information
                        properties:
                          id:
                            type: integer
                            example: 456
                          created_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          first_name:
                            type: string
                            nullable: true
                            example: Jane
                          last_name:
                            type: string
                            nullable: true
                            example: Smith
                          email:
                            type: string
                            format: email
                            nullable: true
                            example: accounting@acmecorp.com
                          receiving_bank_name:
                            type: string
                            nullable: true
                            example: First National Bank
                          receiving_bank_address:
                            type: string
                            nullable: true
                            example: '789 Finance Street, Austin, TX 78701'
                      client_type:
                        type: object
                        nullable: true
                        description: Type of client
                        properties:
                          id:
                            type: integer
                            example: 123
                          created_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          name:
                            type: string
                            example: Retail
                          description:
                            type: string
                            nullable: true
                            example: Retail business client
                      parent_company_id:
                        type: integer
                        nullable: true
                        description: ID of the parent company
                        example: 456
                      invoice_export_template_id:
                        type: integer
                        nullable: true
                        description: ID of the invoice export template
                        example: 789
                      custom_fields:
                        type: object
                        description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Industry: Manufacturing
                          Region: Southwest
                          Annual Revenue: $5M-$10M
                      assigned_sales_reps:
                        type: array
                        description: |
                          Sales rep users assigned to this company (Go Team members). Resolved from the company's
                          `goTeamMember.user` relation. Only present when the relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: User ID of the assigned sales rep
                              example: 42
                            email:
                              type: string
                              description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                              example: rep@example.com
                            first_name:
                              type: string
                              nullable: true
                              example: Jane
                            last_name:
                              type: string
                              nullable: true
                              example: Doe
                      sales_channel:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                                description: Sales channel ID.
                              status:
                                type: string
                                description: Sales channel status (e.g. active).
                              label:
                                type: string
                                nullable: true
                                description: Human-readable channel label.
                              channel_type:
                                type: string
                                nullable: true
                                description: Channel type (e.g. the integration/platform the channel represents).
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                        description: The company's default sales channel. Only present when the relation is loaded.
                    required:
                      - id
                      - name
                      - status
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    post:
      operationId: updateCompany
      tags:
        - Companies
      summary: Update a company
      description: Update an existing company's information
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Company name
                  example: Acme Corporation
                client_type:
                  type: object
                  nullable: true
                  description: 'Client type information. Can provide either id or name. If name is provided and type doesn''t exist, it will be created.'
                  properties:
                    id:
                      type: integer
                      description: ID of the client type
                      example: 123
                    name:
                      type: string
                      description: Name of the client type
                      example: Retail
                price_level:
                  type: object
                  nullable: true
                  description: |
                    Default price level to assign to the company. Provide either `id` or `name`;
                    `id` takes precedence. The price level must already exist and be active —
                    unlike `client_type`, price levels are never auto-created (they are
                    admin-configured entities with `percent_increase` values). A non-matching
                    `id` or `name` returns a `422`. Omit the field to leave it unchanged.
                  properties:
                    id:
                      type: integer
                      description: ID of an existing active price level (preferred when known)
                      example: 123
                    name:
                      type: string
                      description: Name of an existing active price level (used when `id` is not provided)
                      example: Wholesale
                parent_company_id:
                  type: integer
                  nullable: true
                  description: ID of the parent company
                  example: 456
                address:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Street address for the company
                  example: 123 Main St
                address_line_2:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Additional address information
                  example: Suite 500
                city:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: City
                  example: Austin
                state:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: State/province
                  example: TX
                postal_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Postal/ZIP code
                  example: '78701'
                country:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Country
                  example: USA
                phone:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Primary phone number for the company
                  example: 555-123-4567
                fein:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Federal Employer Identification Number
                  example: 12-3456789
                tax_exempt:
                  type: boolean
                  nullable: true
                  description: Whether the company is exempt from taxes
                  example: false
                notes:
                  type: string
                  nullable: true
                  description: Additional notes about the company
                  example: 'Key account, requires special handling'
                payment_term:
                  type: string
                  nullable: true
                  description: Payment terms label (e.g. "Net 30"). Must match a supported payment term.
                  example: Net 30
                due_date_days:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: Number of days until payment is due (used when payment_term is "Custom")
                  example: 45
                credit_limit:
                  type: number
                  nullable: true
                  minimum: 0
                  description: Credit limit for the company. Send `null` to clear the limit (no limit set).
                  example: 5000
                header_discount_enabled:
                  type: boolean
                  nullable: true
                  description: Whether to apply an order-header trade discount by default for this company
                  example: false
                header_discount_type:
                  type: string
                  nullable: true
                  enum:
                    - PERCENT
                    - FIXED_AMOUNT
                  description: How the header discount is calculated — a percentage of the order or a fixed amount
                  example: PERCENT
                header_discount_value:
                  type: number
                  format: float
                  nullable: true
                  minimum: 0
                  description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                  example: 5
                header_discount_effective_from:
                  type: string
                  format: date
                  nullable: true
                  description: Date from which the header discount takes effect (YYYY-MM-DD)
                  example: '2026-01-01'
                default_currency_code:
                  type: string
                  nullable: true
                  minLength: 3
                  maxLength: 3
                  description: Default ISO 4217 currency code for this company (3 letters). Auto-applied to new orders created for the company. Must be exactly three letters; other 3-character values are rejected. Omit to leave unchanged; pass `null` to clear.
                  example: USD
                b2b_product_template_id:
                  type: integer
                  nullable: true
                  description: 'ID of the B2B Product Template (see `GET /b2b-product-templates`) assigned to this company, which controls the SKUs it sees on the B2B Portal. Must be an existing template. Omit to leave unchanged; pass `null` to clear.'
                  example: 12
                tags:
                  type: array
                  nullable: true
                  description: List of tags to associate with the company
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - wholesale
                    - preferred
                custom_fields:
                  type: object
                  nullable: true
                  description: |
                    Custom field values for the company, keyed by label. Only the labels sent are changed. Sending `null`,
                    `""` or `[]` for a label clears that field's value (dropdown fields included);
                    an empty value for a label that is not defined is ignored.
                  additionalProperties:
                    type: string
                    nullable: true
                  example:
                    Industry: Manufacturing
                    Region: Southwest
                assigned_sales_reps:
                  type: array
                  nullable: true
                  description: |
                    Sales rep users (Go Team members) assigned to this company. Each entry must
                    include `id` or `email`. Passing this field syncs the list — entries not present
                    are removed. Pass an empty array to clear all assignments. Omit the field to
                    leave the current assignments unchanged.
                  items:
                    type: object
                    properties:
                      id:
                        type: integer
                        nullable: true
                        description: User ID (preferred when known)
                        example: 42
                      email:
                        type: string
                        format: email
                        maxLength: 255
                        nullable: true
                        description: User email (used to look up the user when `id` is not provided)
                        example: rep@example.com
                sales_channel:
                  type: object
                  nullable: true
                  description: |
                    Set the company's default sales channel. Provide `id` or `label` to match an
                    existing active channel — `id` takes precedence. Channels are never auto-created.
                    Pass an explicit `null` to clear the assignment.
                  properties:
                    id:
                      type: integer
                      nullable: true
                      description: Sales channel ID (preferred when known).
                      example: 12
                    label:
                      type: string
                      nullable: true
                      description: Sales channel label (used to look up the channel when `id` is not provided).
                      example: Wholesale
      responses:
        '200':
          description: Company successfully updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the company
                        example: 123456
                      created_at:
                        type: string
                        format: date-time
                        description: When the company was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the company was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Status of the company
                        enum:
                          - active
                          - inactive
                        example: active
                      name:
                        type: string
                        description: Company name
                        example: Acme Corporation
                      type:
                        type: string
                        nullable: true
                        description: Type of business
                        example: Retail
                      phone:
                        type: string
                        nullable: true
                        description: Primary phone number for the company
                        example: 555-123-4567
                      address:
                        type: string
                        nullable: true
                        description: Street address for the company
                        example: 123 Main St
                      address_line_2:
                        type: string
                        nullable: true
                        description: Additional address information
                        example: Suite 500
                      city:
                        type: string
                        nullable: true
                        description: City
                        example: Austin
                      state:
                        type: string
                        nullable: true
                        description: State/province
                        example: TX
                      postal_code:
                        type: string
                        nullable: true
                        description: Postal/ZIP code
                        example: '78701'
                      country:
                        type: string
                        nullable: true
                        description: Country
                        example: USA
                      full_address:
                        type: string
                        nullable: true
                        description: Complete formatted address
                        example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                      shipping_first_name:
                        type: string
                        nullable: true
                        description: First name for shipping contact (legacy field)
                        example: John
                      shipping_last_name:
                        type: string
                        nullable: true
                        description: Last name for shipping contact (legacy field)
                        example: Doe
                      shipping_email:
                        type: string
                        format: email
                        nullable: true
                        description: Email for shipping contact (legacy field)
                        example: shipping@acmecorp.com
                      shipping_phone:
                        type: string
                        nullable: true
                        description: Phone number for shipping contact (legacy field)
                        example: 555-987-6543
                      shipping_address:
                        type: string
                        nullable: true
                        description: Shipping street address (legacy field)
                        example: 456 Warehouse Blvd
                      shipping_city:
                        type: string
                        nullable: true
                        description: Shipping city (legacy field)
                        example: Austin
                      shipping_state:
                        type: string
                        nullable: true
                        description: Shipping state/province (legacy field)
                        example: TX
                      shipping_postal_code:
                        type: string
                        nullable: true
                        description: Shipping postal/ZIP code (legacy field)
                        example: '78745'
                      shipping_country:
                        type: string
                        nullable: true
                        description: Shipping country (legacy field)
                        example: USA
                      shipping_full_address:
                        type: string
                        nullable: true
                        description: Complete formatted shipping address (legacy field)
                        example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                      payment_term:
                        type: string
                        nullable: true
                        description: Payment terms for the company
                        example: Net 30
                      tax_exempt:
                        type: boolean
                        nullable: true
                        description: Whether the company is exempt from taxes
                        example: false
                      tax_rate:
                        type: number
                        format: float
                        nullable: true
                        description: Tax rate applied to the company's orders
                        example: 8.25
                      due_date_days:
                        type: integer
                        nullable: true
                        description: Number of days until payment is due
                        example: 30
                      credit_limit:
                        type: number
                        format: float
                        nullable: true
                        description: Credit limit for the company. `null` means no limit is set.
                        example: 5000
                      header_discount_enabled:
                        type: boolean
                        description: Whether an order-header trade discount is applied by default for this company
                        example: false
                      header_discount_type:
                        type: string
                        nullable: true
                        enum:
                          - PERCENT
                          - FIXED_AMOUNT
                        description: How the header discount is calculated — a percentage of the order or a fixed amount
                        example: PERCENT
                      header_discount_value:
                        type: number
                        format: float
                        nullable: true
                        description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                        example: 5
                      header_discount_effective_from:
                        type: string
                        format: date
                        nullable: true
                        description: Date from which the header discount takes effect (YYYY-MM-DD)
                        example: '2026-01-01'
                      default_currency_code:
                        type: string
                        nullable: true
                        description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                        example: USD
                      price_level:
                        nullable: true
                        description: Price level associated with this company
                        type: object
                        properties:
                          id:
                            type: number
                            description: Unique identifier for the price level
                            example: 123
                          created_at:
                            type: string
                            format: date-time
                            description: When the price level was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the price level was last updated
                            example: '2023-03-15T14:30:00Z'
                          status:
                            type: string
                            description: Status of the price level
                            enum:
                              - active
                              - inactive
                            example: active
                          name:
                            type: string
                            description: Name of the price level
                            example: Wholesale
                          type:
                            type: string
                            description: Type of the price level
                            example: percentage
                          percent_increase:
                            type: number
                            format: float
                            description: Percentage increase (or decrease) for this price level
                            example: 15.5
                      notes:
                        type: string
                        nullable: true
                        description: Additional notes about the company
                        example: 'Key account, requires special handling'
                      fein:
                        type: string
                        nullable: true
                        description: Federal Employer Identification Number
                        example: 12-3456789
                      tags:
                        type: array
                        nullable: true
                        description: List of tags associated with the company
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      default_shipping:
                        nullable: true
                        description: Default shipping address
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the shipping address
                            example: 789
                          created_at:
                            type: string
                            format: date-time
                            description: When the shipping address was created
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            description: When the shipping address was last updated
                            example: '2023-03-15T14:30:00Z'
                          company_id:
                            type: integer
                            description: ID of the company this shipping address belongs to
                            example: 123456
                          company_name:
                            type: string
                            nullable: true
                            description: Name of the company
                            example: Acme Corporation
                          address:
                            type: string
                            description: Street address
                            example: 456 Warehouse Blvd
                          address_line_2:
                            type: string
                            nullable: true
                            description: Additional address information
                            example: Building 2
                          city:
                            type: string
                            description: City
                            example: Austin
                          state:
                            type: string
                            description: State/province
                            example: TX
                          postal_code:
                            type: string
                            description: Postal/ZIP code
                            example: '78745'
                          country:
                            type: string
                            description: Country
                            example: USA
                          full_address:
                            type: string
                            description: Complete formatted address
                            example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                          full_name:
                            type: string
                            description: Full name of the contact person
                            example: John Doe
                          first_name:
                            type: string
                            nullable: true
                            description: First name of the contact person
                            example: John
                          last_name:
                            type: string
                            nullable: true
                            description: Last name of the contact person
                            example: Doe
                          phone:
                            type: string
                            nullable: true
                            description: Phone number
                            example: 555-987-6543
                          email:
                            type: string
                            format: email
                            nullable: true
                            description: Email address
                            example: shipping@acmecorp.com
                          is_default:
                            type: boolean
                            description: Whether this is the default shipping address
                            example: true
                        required:
                          - id
                          - company_id
                          - address
                          - city
                          - state
                          - postal_code
                          - country
                      shipping_addresses:
                        type: array
                        nullable: true
                        description: List of shipping addresses for the company
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the shipping address
                              example: 789
                            created_at:
                              type: string
                              format: date-time
                              description: When the shipping address was created
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              description: When the shipping address was last updated
                              example: '2023-03-15T14:30:00Z'
                            company_id:
                              type: integer
                              description: ID of the company this shipping address belongs to
                              example: 123456
                            company_name:
                              type: string
                              nullable: true
                              description: Name of the company
                              example: Acme Corporation
                            address:
                              type: string
                              description: Street address
                              example: 456 Warehouse Blvd
                            address_line_2:
                              type: string
                              nullable: true
                              description: Additional address information
                              example: Building 2
                            city:
                              type: string
                              description: City
                              example: Austin
                            state:
                              type: string
                              description: State/province
                              example: TX
                            postal_code:
                              type: string
                              description: Postal/ZIP code
                              example: '78745'
                            country:
                              type: string
                              description: Country
                              example: USA
                            full_address:
                              type: string
                              description: Complete formatted address
                              example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                            full_name:
                              type: string
                              description: Full name of the contact person
                              example: John Doe
                            first_name:
                              type: string
                              nullable: true
                              description: First name of the contact person
                              example: John
                            last_name:
                              type: string
                              nullable: true
                              description: Last name of the contact person
                              example: Doe
                            phone:
                              type: string
                              nullable: true
                              description: Phone number
                              example: 555-987-6543
                            email:
                              type: string
                              format: email
                              nullable: true
                              description: Email address
                              example: shipping@acmecorp.com
                            is_default:
                              type: boolean
                              description: Whether this is the default shipping address
                              example: true
                          required:
                            - id
                            - company_id
                            - address
                            - city
                            - state
                            - postal_code
                            - country
                      billing_info:
                        type: object
                        nullable: true
                        description: Billing information
                        properties:
                          id:
                            type: integer
                            example: 456
                          created_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          first_name:
                            type: string
                            nullable: true
                            example: Jane
                          last_name:
                            type: string
                            nullable: true
                            example: Smith
                          email:
                            type: string
                            format: email
                            nullable: true
                            example: accounting@acmecorp.com
                          receiving_bank_name:
                            type: string
                            nullable: true
                            example: First National Bank
                          receiving_bank_address:
                            type: string
                            nullable: true
                            example: '789 Finance Street, Austin, TX 78701'
                      client_type:
                        type: object
                        nullable: true
                        description: Type of client
                        properties:
                          id:
                            type: integer
                            example: 123
                          created_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          updated_at:
                            type: string
                            format: date-time
                            example: '2023-03-15T14:30:00Z'
                          name:
                            type: string
                            example: Retail
                          description:
                            type: string
                            nullable: true
                            example: Retail business client
                      parent_company_id:
                        type: integer
                        nullable: true
                        description: ID of the parent company
                        example: 456
                      invoice_export_template_id:
                        type: integer
                        nullable: true
                        description: ID of the invoice export template
                        example: 789
                      custom_fields:
                        type: object
                        description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Industry: Manufacturing
                          Region: Southwest
                          Annual Revenue: $5M-$10M
                      assigned_sales_reps:
                        type: array
                        description: |
                          Sales rep users assigned to this company (Go Team members). Resolved from the company's
                          `goTeamMember.user` relation. Only present when the relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: User ID of the assigned sales rep
                              example: 42
                            email:
                              type: string
                              description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                              example: rep@example.com
                            first_name:
                              type: string
                              nullable: true
                              example: Jane
                            last_name:
                              type: string
                              nullable: true
                              example: Doe
                      sales_channel:
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                                description: Sales channel ID.
                              status:
                                type: string
                                description: Sales channel status (e.g. active).
                              label:
                                type: string
                                nullable: true
                                description: Human-readable channel label.
                              channel_type:
                                type: string
                                nullable: true
                                description: Channel type (e.g. the integration/platform the channel represents).
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        nullable: true
                        description: The company's default sales channel. Only present when the relation is loaded.
                    required:
                      - id
                      - name
                      - status
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteCompany
      tags:
        - Companies
      summary: Delete a company
      description: Delete a company by ID
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      responses:
        '204':
          description: Company successfully deleted
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  /suppliers:
    get:
      operationId: getSuppliers
      tags:
        - Suppliers
      summary: Suppliers
      description: |
        Get a paginated list of suppliers (factories) that are active and visible to the authenticated user.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Supplier name
        - `city`: City
        - `state`: State
        - `country`: Country
        - `zip`: ZIP/Postal code

        ### DateTime Filters
        - `created_at`: When the supplier was created
        - `updated_at`: When the supplier was last updated

        ## Examples
        ```
        # Find suppliers by name
        ?name[contains]=Acme

        # Find suppliers in a specific country
        ?country[eq]=China

        # Find suppliers updated since a date
        ?updated_at[gte]=2026-01-01
        ```
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: name
          schema:
            type: string
          description: Filter by supplier name
        - in: query
          name: city
          schema:
            type: string
          description: Filter by city
        - in: query
          name: state
          schema:
            type: string
          description: Filter by state
        - in: query
          name: country
          schema:
            type: string
          description: Filter by country
        - in: query
          name: zip
          schema:
            type: string
          description: Filter by ZIP/Postal code
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
      responses:
        '200':
          description: A list of suppliers
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the supplier
                          example: 42
                        status:
                          type: integer
                          description: Numeric status flag (1 = active)
                          example: 1
                        created_at:
                          type: string
                          format: date-time
                          description: When the supplier was created
                          example: '2026-04-20T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the supplier was last updated
                          example: '2026-04-20T14:30:00Z'
                        created_by:
                          type: integer
                          nullable: true
                          description: ID of the user that created this supplier
                          example: 100
                        updated_by:
                          type: integer
                          nullable: true
                          description: ID of the user that last updated this supplier
                          example: 100
                        name:
                          type: string
                          description: Supplier name
                          example: Acme Manufacturing
                        description:
                          type: string
                          nullable: true
                          description: Supplier description
                          example: Primary overseas supplier for apparel
                        street_address:
                          type: string
                          nullable: true
                          example: 123 Industrial Way
                        city:
                          type: string
                          nullable: true
                          example: Shenzhen
                        state:
                          type: string
                          nullable: true
                          example: Guangdong
                        zip:
                          type: string
                          nullable: true
                          example: '518000'
                        country:
                          type: string
                          nullable: true
                          example: China
                        factory_admin_id:
                          type: integer
                          nullable: true
                          description: ID of the internal user acting as the primary admin for this supplier
                          example: 100
                        supplier_admin_id:
                          type: integer
                          nullable: true
                          description: Alias of `factory_admin_id`
                          example: 100
                        contact_name:
                          type: string
                          nullable: true
                          description: Legacy single-contact name (use `contacts` for the full list)
                          example: Jane Doe
                        contact_email:
                          type: string
                          format: email
                          nullable: true
                          description: Legacy single-contact email (use `contacts` for the full list)
                          example: jane@acme.example
                        contact_phone:
                          type: string
                          nullable: true
                          description: Legacy single-contact phone (use `contacts` for the full list)
                          example: +86 755 1234 5678
                        bank_name:
                          type: string
                          nullable: true
                          example: Bank of China
                        routing_number:
                          type: string
                          nullable: true
                          example: '021000021'
                        account_number:
                          type: string
                          nullable: true
                          example: '1234567890'
                        swift_code:
                          type: string
                          nullable: true
                          example: BKCHCNBJ
                        default_payment_term:
                          type: string
                          nullable: true
                          description: 'Default payment term name, matches the set available to companies'
                          example: Net 30
                        default_currency_code:
                          type: string
                          nullable: true
                          description: Default ISO 4217 currency code for this supplier. Auto-applied to new purchase orders created for the supplier.
                          example: USD
                        default_logistic_code:
                          type: string
                          nullable: true
                          description: 'Incoterm applied to a purchase order raised for this supplier when the order does not name one itself. One of "fob", "exw", "cif", "ddp" or "fca". Null when the supplier has no Incoterm default.'
                          example: fob
                        default_warehouse_id:
                          type: integer
                          nullable: true
                          description: 'Warehouse a purchase order raised for this supplier defaults to when the order does not name one. A warehouse id, as returned by GET /warehouses. Null when the supplier has no warehouse default.'
                          example: 7
                        default_order_type:
                          type: string
                          nullable: true
                          description: Order type a purchase order raised for this supplier defaults to when the order does not name one. Either "INTERNAL_TRANSFER_ORDER" or "DROP_SHIP_ORDER". Null when the supplier has no order type default.
                          example: DROP_SHIP_ORDER
                        default_requested_ship_date_offset_days:
                          type: integer
                          nullable: true
                          description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its requested ship date, when the order does not carry one. Null when the supplier has no requested ship date default.'
                          example: 14
                        default_arrival_due_date_offset_days:
                          type: integer
                          nullable: true
                          description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its arrival due date, when the order does not carry one. Null when the supplier has no arrival due date default.'
                          example: 30
                        custom_fields:
                          type: object
                          description: 'Map of the supplier''s custom field values as label => value pairs. Only fields defined for the supplier object type appear. Always a JSON object; empty when no custom fields are set. Field definitions are available via GET /custom-fields?object_type=supplier. Writable via POST — see the create/update request body. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          example:
                            Region: Southwest
                            Preferred Carrier: UPS
                            Onboarded On: '2025-03-14'
                        ship_to_addresses:
                          type: array
                          nullable: true
                          description: Addresses saved against this supplier for shipping purchase orders to (only present when the relation is loaded). The one entry with `is_default` true is the address a purchase order raised for this supplier ships to when the order does not carry its own; exactly one entry carries the flag whenever the set is non-empty.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                example: 88
                              is_default:
                                type: boolean
                                example: true
                              ship_to_name:
                                type: string
                                nullable: true
                                example: Main Warehouse
                              ship_to_company:
                                type: string
                                nullable: true
                                example: Acme Distribution
                              ship_to_phone:
                                type: string
                                nullable: true
                                example: +1 555 123 4567
                              ship_to_email:
                                type: string
                                nullable: true
                                example: receiving@acme.example
                              street_address_1:
                                type: string
                                nullable: true
                                example: 500 Distribution Blvd
                              street_address_2:
                                type: string
                                nullable: true
                                example: Suite 200
                              street_address_3:
                                type: string
                                nullable: true
                              city:
                                type: string
                                nullable: true
                                example: Dallas
                              state:
                                type: string
                                nullable: true
                                example: TX
                              zip:
                                type: string
                                nullable: true
                                example: '75201'
                              country:
                                type: string
                                nullable: true
                                example: USA
                        contacts:
                          type: array
                          nullable: true
                          description: Linked contacts (only present when the relation is loaded)
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                example: 501
                              name:
                                type: string
                                nullable: true
                                example: Jane Doe
                              email:
                                type: string
                                format: email
                                nullable: true
                                example: jane@acme.example
                              phone:
                                type: string
                                nullable: true
                                example: +86 755 1234 5678
                      required:
                        - id
                        - name
                        - status
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
    post:
      operationId: createSupplier
      tags:
        - Suppliers
      summary: Create a supplier
      description: Create a new supplier (factory).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Supplier name
                  example: Acme Manufacturing
                description:
                  type: string
                  nullable: true
                  description: Supplier description
                  example: Primary overseas supplier for apparel
                street_address:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: 123 Industrial Way
                city:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Shenzhen
                state:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Guangdong
                zip:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '518000'
                country:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: China
                factory_admin_id:
                  type: integer
                  nullable: true
                  description: ID of the internal user to set as the primary admin for this supplier
                  example: 100
                bank_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Bank of China
                routing_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '021000021'
                account_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '1234567890'
                swift_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: BKCHCNBJ
                default_payment_term:
                  type: string
                  nullable: true
                  description: Default payment term name. Must match one of the payment term names configured in Luminous.
                  example: Net 30
                default_currency_code:
                  type: string
                  nullable: true
                  minLength: 3
                  maxLength: 3
                  description: Default ISO 4217 currency code for this supplier (3 letters). Auto-applied to new purchase orders created for the supplier.
                  example: USD
                contact_ids:
                  type: array
                  nullable: true
                  description: IDs of existing contacts to link to this supplier
                  items:
                    type: integer
                  example:
                    - 501
                    - 502
                default_logistic_code:
                  type: string
                  nullable: true
                  enum:
                    - fob
                    - exw
                    - cif
                    - ddp
                    - fca
                  description: Incoterm applied to a purchase order raised for this supplier when the order does not name one itself.
                  example: fob
                default_warehouse_id:
                  type: integer
                  nullable: true
                  description: 'Warehouse a purchase order raised for this supplier defaults to when the order does not name one. A warehouse id, as returned by GET /warehouses.'
                  example: 7
                default_order_type:
                  type: string
                  nullable: true
                  enum:
                    - INTERNAL_TRANSFER_ORDER
                    - DROP_SHIP_ORDER
                  description: Order type a purchase order raised for this supplier defaults to when the order does not name one.
                  example: DROP_SHIP_ORDER
                default_requested_ship_date_offset_days:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its requested ship date, when the order does not carry one. Must be 0 or greater.'
                  example: 14
                default_arrival_due_date_offset_days:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: |
                    Whole calendar days (not business days) added to a purchase order's order date to produce its arrival due date, when the order does not carry one. Must be 0 or greater.

                    Must also be greater than or equal to `default_requested_ship_date_offset_days`, or the request fails with a 422 on this field. An offset you don't send is taken from the supplier's stored value, and the check is skipped when either offset ends up null. When updating an existing supplier, the check only runs if at least one offset is actually changing, so a supplier already stored with arrival earlier than ship can still be saved for unrelated edits.
                  example: 30
                ship_to_addresses:
                  type: array
                  nullable: true
                  description: |
                    The supplier's saved ship-to address set. There is no separate "default ship to" field — the default is the entry flagged `is_default`, and the set is normalized so exactly one carries the flag whenever it is non-empty.

                    This endpoint replaces rather than merges, but omitting `ship_to_addresses` leaves the existing set untouched; sending it (even as an empty array) writes it.
                  items:
                    type: object
                    properties:
                      is_default:
                        type: boolean
                        nullable: true
                        example: true
                      ship_to_name:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Main Warehouse
                      ship_to_company:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Acme Distribution
                      ship_to_phone:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: +1 555 123 4567
                      ship_to_email:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: receiving@acme.example
                      street_address_1:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: 500 Distribution Blvd
                      street_address_2:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Suite 200
                      street_address_3:
                        type: string
                        maxLength: 255
                        nullable: true
                      city:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Dallas
                      state:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: TX
                      zip:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: '75201'
                      country:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: USA
                custom_fields:
                  type: object
                  nullable: true
                  description: |
                    Custom field values as a `label => value` map, matching the shape GET returns. Only fields defined for the supplier object type are accepted; a label that is unknown, scoped to another object type, or a case-variant duplicate is rejected with a 422. Set a value to `null` to clear that field.

                    This endpoint replaces rather than merges, but omitting `custom_fields` leaves the existing values untouched; sending it writes it.
                  example:
                    Region: Southwest
                    Preferred Carrier: UPS
              required:
                - name
      responses:
        '201':
          description: Supplier successfully created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the supplier
                        example: 42
                      status:
                        type: integer
                        description: Numeric status flag (1 = active)
                        example: 1
                      created_at:
                        type: string
                        format: date-time
                        description: When the supplier was created
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the supplier was last updated
                        example: '2026-04-20T14:30:00Z'
                      created_by:
                        type: integer
                        nullable: true
                        description: ID of the user that created this supplier
                        example: 100
                      updated_by:
                        type: integer
                        nullable: true
                        description: ID of the user that last updated this supplier
                        example: 100
                      name:
                        type: string
                        description: Supplier name
                        example: Acme Manufacturing
                      description:
                        type: string
                        nullable: true
                        description: Supplier description
                        example: Primary overseas supplier for apparel
                      street_address:
                        type: string
                        nullable: true
                        example: 123 Industrial Way
                      city:
                        type: string
                        nullable: true
                        example: Shenzhen
                      state:
                        type: string
                        nullable: true
                        example: Guangdong
                      zip:
                        type: string
                        nullable: true
                        example: '518000'
                      country:
                        type: string
                        nullable: true
                        example: China
                      factory_admin_id:
                        type: integer
                        nullable: true
                        description: ID of the internal user acting as the primary admin for this supplier
                        example: 100
                      supplier_admin_id:
                        type: integer
                        nullable: true
                        description: Alias of `factory_admin_id`
                        example: 100
                      contact_name:
                        type: string
                        nullable: true
                        description: Legacy single-contact name (use `contacts` for the full list)
                        example: Jane Doe
                      contact_email:
                        type: string
                        format: email
                        nullable: true
                        description: Legacy single-contact email (use `contacts` for the full list)
                        example: jane@acme.example
                      contact_phone:
                        type: string
                        nullable: true
                        description: Legacy single-contact phone (use `contacts` for the full list)
                        example: +86 755 1234 5678
                      bank_name:
                        type: string
                        nullable: true
                        example: Bank of China
                      routing_number:
                        type: string
                        nullable: true
                        example: '021000021'
                      account_number:
                        type: string
                        nullable: true
                        example: '1234567890'
                      swift_code:
                        type: string
                        nullable: true
                        example: BKCHCNBJ
                      default_payment_term:
                        type: string
                        nullable: true
                        description: 'Default payment term name, matches the set available to companies'
                        example: Net 30
                      default_currency_code:
                        type: string
                        nullable: true
                        description: Default ISO 4217 currency code for this supplier. Auto-applied to new purchase orders created for the supplier.
                        example: USD
                      default_logistic_code:
                        type: string
                        nullable: true
                        description: 'Incoterm applied to a purchase order raised for this supplier when the order does not name one itself. One of "fob", "exw", "cif", "ddp" or "fca". Null when the supplier has no Incoterm default.'
                        example: fob
                      default_warehouse_id:
                        type: integer
                        nullable: true
                        description: 'Warehouse a purchase order raised for this supplier defaults to when the order does not name one. A warehouse id, as returned by GET /warehouses. Null when the supplier has no warehouse default.'
                        example: 7
                      default_order_type:
                        type: string
                        nullable: true
                        description: Order type a purchase order raised for this supplier defaults to when the order does not name one. Either "INTERNAL_TRANSFER_ORDER" or "DROP_SHIP_ORDER". Null when the supplier has no order type default.
                        example: DROP_SHIP_ORDER
                      default_requested_ship_date_offset_days:
                        type: integer
                        nullable: true
                        description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its requested ship date, when the order does not carry one. Null when the supplier has no requested ship date default.'
                        example: 14
                      default_arrival_due_date_offset_days:
                        type: integer
                        nullable: true
                        description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its arrival due date, when the order does not carry one. Null when the supplier has no arrival due date default.'
                        example: 30
                      custom_fields:
                        type: object
                        description: 'Map of the supplier''s custom field values as label => value pairs. Only fields defined for the supplier object type appear. Always a JSON object; empty when no custom fields are set. Field definitions are available via GET /custom-fields?object_type=supplier. Writable via POST — see the create/update request body. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Region: Southwest
                          Preferred Carrier: UPS
                          Onboarded On: '2025-03-14'
                      ship_to_addresses:
                        type: array
                        nullable: true
                        description: Addresses saved against this supplier for shipping purchase orders to (only present when the relation is loaded). The one entry with `is_default` true is the address a purchase order raised for this supplier ships to when the order does not carry its own; exactly one entry carries the flag whenever the set is non-empty.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 88
                            is_default:
                              type: boolean
                              example: true
                            ship_to_name:
                              type: string
                              nullable: true
                              example: Main Warehouse
                            ship_to_company:
                              type: string
                              nullable: true
                              example: Acme Distribution
                            ship_to_phone:
                              type: string
                              nullable: true
                              example: +1 555 123 4567
                            ship_to_email:
                              type: string
                              nullable: true
                              example: receiving@acme.example
                            street_address_1:
                              type: string
                              nullable: true
                              example: 500 Distribution Blvd
                            street_address_2:
                              type: string
                              nullable: true
                              example: Suite 200
                            street_address_3:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                              example: Dallas
                            state:
                              type: string
                              nullable: true
                              example: TX
                            zip:
                              type: string
                              nullable: true
                              example: '75201'
                            country:
                              type: string
                              nullable: true
                              example: USA
                      contacts:
                        type: array
                        nullable: true
                        description: Linked contacts (only present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 501
                            name:
                              type: string
                              nullable: true
                              example: Jane Doe
                            email:
                              type: string
                              format: email
                              nullable: true
                              example: jane@acme.example
                            phone:
                              type: string
                              nullable: true
                              example: +86 755 1234 5678
                    required:
                      - id
                      - name
                      - status
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/suppliers/{supplierId}':
    get:
      operationId: getSupplier
      tags:
        - Suppliers
      summary: Supplier
      description: Get detailed information for a specific supplier.
      security:
        - BearerAuth: []
      parameters:
        - name: supplierId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the supplier
      responses:
        '200':
          description: Supplier details
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the supplier
                        example: 42
                      status:
                        type: integer
                        description: Numeric status flag (1 = active)
                        example: 1
                      created_at:
                        type: string
                        format: date-time
                        description: When the supplier was created
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the supplier was last updated
                        example: '2026-04-20T14:30:00Z'
                      created_by:
                        type: integer
                        nullable: true
                        description: ID of the user that created this supplier
                        example: 100
                      updated_by:
                        type: integer
                        nullable: true
                        description: ID of the user that last updated this supplier
                        example: 100
                      name:
                        type: string
                        description: Supplier name
                        example: Acme Manufacturing
                      description:
                        type: string
                        nullable: true
                        description: Supplier description
                        example: Primary overseas supplier for apparel
                      street_address:
                        type: string
                        nullable: true
                        example: 123 Industrial Way
                      city:
                        type: string
                        nullable: true
                        example: Shenzhen
                      state:
                        type: string
                        nullable: true
                        example: Guangdong
                      zip:
                        type: string
                        nullable: true
                        example: '518000'
                      country:
                        type: string
                        nullable: true
                        example: China
                      factory_admin_id:
                        type: integer
                        nullable: true
                        description: ID of the internal user acting as the primary admin for this supplier
                        example: 100
                      supplier_admin_id:
                        type: integer
                        nullable: true
                        description: Alias of `factory_admin_id`
                        example: 100
                      contact_name:
                        type: string
                        nullable: true
                        description: Legacy single-contact name (use `contacts` for the full list)
                        example: Jane Doe
                      contact_email:
                        type: string
                        format: email
                        nullable: true
                        description: Legacy single-contact email (use `contacts` for the full list)
                        example: jane@acme.example
                      contact_phone:
                        type: string
                        nullable: true
                        description: Legacy single-contact phone (use `contacts` for the full list)
                        example: +86 755 1234 5678
                      bank_name:
                        type: string
                        nullable: true
                        example: Bank of China
                      routing_number:
                        type: string
                        nullable: true
                        example: '021000021'
                      account_number:
                        type: string
                        nullable: true
                        example: '1234567890'
                      swift_code:
                        type: string
                        nullable: true
                        example: BKCHCNBJ
                      default_payment_term:
                        type: string
                        nullable: true
                        description: 'Default payment term name, matches the set available to companies'
                        example: Net 30
                      default_currency_code:
                        type: string
                        nullable: true
                        description: Default ISO 4217 currency code for this supplier. Auto-applied to new purchase orders created for the supplier.
                        example: USD
                      default_logistic_code:
                        type: string
                        nullable: true
                        description: 'Incoterm applied to a purchase order raised for this supplier when the order does not name one itself. One of "fob", "exw", "cif", "ddp" or "fca". Null when the supplier has no Incoterm default.'
                        example: fob
                      default_warehouse_id:
                        type: integer
                        nullable: true
                        description: 'Warehouse a purchase order raised for this supplier defaults to when the order does not name one. A warehouse id, as returned by GET /warehouses. Null when the supplier has no warehouse default.'
                        example: 7
                      default_order_type:
                        type: string
                        nullable: true
                        description: Order type a purchase order raised for this supplier defaults to when the order does not name one. Either "INTERNAL_TRANSFER_ORDER" or "DROP_SHIP_ORDER". Null when the supplier has no order type default.
                        example: DROP_SHIP_ORDER
                      default_requested_ship_date_offset_days:
                        type: integer
                        nullable: true
                        description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its requested ship date, when the order does not carry one. Null when the supplier has no requested ship date default.'
                        example: 14
                      default_arrival_due_date_offset_days:
                        type: integer
                        nullable: true
                        description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its arrival due date, when the order does not carry one. Null when the supplier has no arrival due date default.'
                        example: 30
                      custom_fields:
                        type: object
                        description: 'Map of the supplier''s custom field values as label => value pairs. Only fields defined for the supplier object type appear. Always a JSON object; empty when no custom fields are set. Field definitions are available via GET /custom-fields?object_type=supplier. Writable via POST — see the create/update request body. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Region: Southwest
                          Preferred Carrier: UPS
                          Onboarded On: '2025-03-14'
                      ship_to_addresses:
                        type: array
                        nullable: true
                        description: Addresses saved against this supplier for shipping purchase orders to (only present when the relation is loaded). The one entry with `is_default` true is the address a purchase order raised for this supplier ships to when the order does not carry its own; exactly one entry carries the flag whenever the set is non-empty.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 88
                            is_default:
                              type: boolean
                              example: true
                            ship_to_name:
                              type: string
                              nullable: true
                              example: Main Warehouse
                            ship_to_company:
                              type: string
                              nullable: true
                              example: Acme Distribution
                            ship_to_phone:
                              type: string
                              nullable: true
                              example: +1 555 123 4567
                            ship_to_email:
                              type: string
                              nullable: true
                              example: receiving@acme.example
                            street_address_1:
                              type: string
                              nullable: true
                              example: 500 Distribution Blvd
                            street_address_2:
                              type: string
                              nullable: true
                              example: Suite 200
                            street_address_3:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                              example: Dallas
                            state:
                              type: string
                              nullable: true
                              example: TX
                            zip:
                              type: string
                              nullable: true
                              example: '75201'
                            country:
                              type: string
                              nullable: true
                              example: USA
                      contacts:
                        type: array
                        nullable: true
                        description: Linked contacts (only present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 501
                            name:
                              type: string
                              nullable: true
                              example: Jane Doe
                            email:
                              type: string
                              format: email
                              nullable: true
                              example: jane@acme.example
                            phone:
                              type: string
                              nullable: true
                              example: +86 755 1234 5678
                    required:
                      - id
                      - name
                      - status
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    post:
      operationId: updateSupplier
      tags:
        - Suppliers
      summary: Update a supplier
      description: Update an existing supplier's information.
      security:
        - BearerAuth: []
      parameters:
        - name: supplierId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the supplier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Supplier name
                  example: Acme Manufacturing
                description:
                  type: string
                  nullable: true
                  description: Supplier description
                  example: Primary overseas supplier for apparel
                street_address:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: 123 Industrial Way
                city:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Shenzhen
                state:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Guangdong
                zip:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '518000'
                country:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: China
                factory_admin_id:
                  type: integer
                  nullable: true
                  description: ID of the internal user to set as the primary admin for this supplier
                  example: 100
                bank_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Bank of China
                routing_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '021000021'
                account_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '1234567890'
                swift_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: BKCHCNBJ
                default_payment_term:
                  type: string
                  nullable: true
                  description: Default payment term name. Must match one of the payment term names configured in Luminous.
                  example: Net 30
                default_currency_code:
                  type: string
                  nullable: true
                  minLength: 3
                  maxLength: 3
                  description: Default ISO 4217 currency code for this supplier (3 letters). Auto-applied to new purchase orders created for the supplier.
                  example: USD
                contact_ids:
                  type: array
                  nullable: true
                  description: IDs of existing contacts to link to this supplier
                  items:
                    type: integer
                  example:
                    - 501
                    - 502
                default_logistic_code:
                  type: string
                  nullable: true
                  enum:
                    - fob
                    - exw
                    - cif
                    - ddp
                    - fca
                  description: Incoterm applied to a purchase order raised for this supplier when the order does not name one itself.
                  example: fob
                default_warehouse_id:
                  type: integer
                  nullable: true
                  description: 'Warehouse a purchase order raised for this supplier defaults to when the order does not name one. A warehouse id, as returned by GET /warehouses.'
                  example: 7
                default_order_type:
                  type: string
                  nullable: true
                  enum:
                    - INTERNAL_TRANSFER_ORDER
                    - DROP_SHIP_ORDER
                  description: Order type a purchase order raised for this supplier defaults to when the order does not name one.
                  example: DROP_SHIP_ORDER
                default_requested_ship_date_offset_days:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its requested ship date, when the order does not carry one. Must be 0 or greater.'
                  example: 14
                default_arrival_due_date_offset_days:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: |
                    Whole calendar days (not business days) added to a purchase order's order date to produce its arrival due date, when the order does not carry one. Must be 0 or greater.

                    Must also be greater than or equal to `default_requested_ship_date_offset_days`, or the request fails with a 422 on this field. An offset you don't send is taken from the supplier's stored value, and the check is skipped when either offset ends up null. When updating an existing supplier, the check only runs if at least one offset is actually changing, so a supplier already stored with arrival earlier than ship can still be saved for unrelated edits.
                  example: 30
                ship_to_addresses:
                  type: array
                  nullable: true
                  description: |
                    The supplier's saved ship-to address set. There is no separate "default ship to" field — the default is the entry flagged `is_default`, and the set is normalized so exactly one carries the flag whenever it is non-empty.

                    This endpoint replaces rather than merges, but omitting `ship_to_addresses` leaves the existing set untouched; sending it (even as an empty array) writes it.
                  items:
                    type: object
                    properties:
                      is_default:
                        type: boolean
                        nullable: true
                        example: true
                      ship_to_name:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Main Warehouse
                      ship_to_company:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Acme Distribution
                      ship_to_phone:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: +1 555 123 4567
                      ship_to_email:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: receiving@acme.example
                      street_address_1:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: 500 Distribution Blvd
                      street_address_2:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Suite 200
                      street_address_3:
                        type: string
                        maxLength: 255
                        nullable: true
                      city:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Dallas
                      state:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: TX
                      zip:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: '75201'
                      country:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: USA
                custom_fields:
                  type: object
                  nullable: true
                  description: |
                    Custom field values as a `label => value` map, matching the shape GET returns. Only fields defined for the supplier object type are accepted; a label that is unknown, scoped to another object type, or a case-variant duplicate is rejected with a 422. Set a value to `null` to clear that field.

                    This endpoint replaces rather than merges, but omitting `custom_fields` leaves the existing values untouched; sending it writes it.
                  example:
                    Region: Southwest
                    Preferred Carrier: UPS
              required:
                - name
      responses:
        '200':
          description: Supplier successfully updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the supplier
                        example: 42
                      status:
                        type: integer
                        description: Numeric status flag (1 = active)
                        example: 1
                      created_at:
                        type: string
                        format: date-time
                        description: When the supplier was created
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the supplier was last updated
                        example: '2026-04-20T14:30:00Z'
                      created_by:
                        type: integer
                        nullable: true
                        description: ID of the user that created this supplier
                        example: 100
                      updated_by:
                        type: integer
                        nullable: true
                        description: ID of the user that last updated this supplier
                        example: 100
                      name:
                        type: string
                        description: Supplier name
                        example: Acme Manufacturing
                      description:
                        type: string
                        nullable: true
                        description: Supplier description
                        example: Primary overseas supplier for apparel
                      street_address:
                        type: string
                        nullable: true
                        example: 123 Industrial Way
                      city:
                        type: string
                        nullable: true
                        example: Shenzhen
                      state:
                        type: string
                        nullable: true
                        example: Guangdong
                      zip:
                        type: string
                        nullable: true
                        example: '518000'
                      country:
                        type: string
                        nullable: true
                        example: China
                      factory_admin_id:
                        type: integer
                        nullable: true
                        description: ID of the internal user acting as the primary admin for this supplier
                        example: 100
                      supplier_admin_id:
                        type: integer
                        nullable: true
                        description: Alias of `factory_admin_id`
                        example: 100
                      contact_name:
                        type: string
                        nullable: true
                        description: Legacy single-contact name (use `contacts` for the full list)
                        example: Jane Doe
                      contact_email:
                        type: string
                        format: email
                        nullable: true
                        description: Legacy single-contact email (use `contacts` for the full list)
                        example: jane@acme.example
                      contact_phone:
                        type: string
                        nullable: true
                        description: Legacy single-contact phone (use `contacts` for the full list)
                        example: +86 755 1234 5678
                      bank_name:
                        type: string
                        nullable: true
                        example: Bank of China
                      routing_number:
                        type: string
                        nullable: true
                        example: '021000021'
                      account_number:
                        type: string
                        nullable: true
                        example: '1234567890'
                      swift_code:
                        type: string
                        nullable: true
                        example: BKCHCNBJ
                      default_payment_term:
                        type: string
                        nullable: true
                        description: 'Default payment term name, matches the set available to companies'
                        example: Net 30
                      default_currency_code:
                        type: string
                        nullable: true
                        description: Default ISO 4217 currency code for this supplier. Auto-applied to new purchase orders created for the supplier.
                        example: USD
                      default_logistic_code:
                        type: string
                        nullable: true
                        description: 'Incoterm applied to a purchase order raised for this supplier when the order does not name one itself. One of "fob", "exw", "cif", "ddp" or "fca". Null when the supplier has no Incoterm default.'
                        example: fob
                      default_warehouse_id:
                        type: integer
                        nullable: true
                        description: 'Warehouse a purchase order raised for this supplier defaults to when the order does not name one. A warehouse id, as returned by GET /warehouses. Null when the supplier has no warehouse default.'
                        example: 7
                      default_order_type:
                        type: string
                        nullable: true
                        description: Order type a purchase order raised for this supplier defaults to when the order does not name one. Either "INTERNAL_TRANSFER_ORDER" or "DROP_SHIP_ORDER". Null when the supplier has no order type default.
                        example: DROP_SHIP_ORDER
                      default_requested_ship_date_offset_days:
                        type: integer
                        nullable: true
                        description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its requested ship date, when the order does not carry one. Null when the supplier has no requested ship date default.'
                        example: 14
                      default_arrival_due_date_offset_days:
                        type: integer
                        nullable: true
                        description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its arrival due date, when the order does not carry one. Null when the supplier has no arrival due date default.'
                        example: 30
                      custom_fields:
                        type: object
                        description: 'Map of the supplier''s custom field values as label => value pairs. Only fields defined for the supplier object type appear. Always a JSON object; empty when no custom fields are set. Field definitions are available via GET /custom-fields?object_type=supplier. Writable via POST — see the create/update request body. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Region: Southwest
                          Preferred Carrier: UPS
                          Onboarded On: '2025-03-14'
                      ship_to_addresses:
                        type: array
                        nullable: true
                        description: Addresses saved against this supplier for shipping purchase orders to (only present when the relation is loaded). The one entry with `is_default` true is the address a purchase order raised for this supplier ships to when the order does not carry its own; exactly one entry carries the flag whenever the set is non-empty.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 88
                            is_default:
                              type: boolean
                              example: true
                            ship_to_name:
                              type: string
                              nullable: true
                              example: Main Warehouse
                            ship_to_company:
                              type: string
                              nullable: true
                              example: Acme Distribution
                            ship_to_phone:
                              type: string
                              nullable: true
                              example: +1 555 123 4567
                            ship_to_email:
                              type: string
                              nullable: true
                              example: receiving@acme.example
                            street_address_1:
                              type: string
                              nullable: true
                              example: 500 Distribution Blvd
                            street_address_2:
                              type: string
                              nullable: true
                              example: Suite 200
                            street_address_3:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                              example: Dallas
                            state:
                              type: string
                              nullable: true
                              example: TX
                            zip:
                              type: string
                              nullable: true
                              example: '75201'
                            country:
                              type: string
                              nullable: true
                              example: USA
                      contacts:
                        type: array
                        nullable: true
                        description: Linked contacts (only present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 501
                            name:
                              type: string
                              nullable: true
                              example: Jane Doe
                            email:
                              type: string
                              format: email
                              nullable: true
                              example: jane@acme.example
                            phone:
                              type: string
                              nullable: true
                              example: +86 755 1234 5678
                    required:
                      - id
                      - name
                      - status
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    patch:
      operationId: patchSupplier
      tags:
        - Suppliers
      summary: Partially update a supplier
      description: |
        Partially update an existing supplier. Only the fields present in the request body are written; omitted fields are left unchanged, and a nullable field sent as `null` is cleared. At least one recognized supplier field must be supplied.

        Use `POST /suppliers/{supplierId}` when you want to replace the whole record instead.
      security:
        - BearerAuth: []
      parameters:
        - name: supplierId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the supplier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |
                Partial update. Only the fields you send are written; omitted fields are left unchanged. Send a nullable field as `null` to clear it. At least one recognized supplier field must be supplied.

                For a full replace of the supplier record, use `POST /suppliers/{supplierId}` instead.
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Supplier name. If supplied it must be a non-empty string.
                  example: Acme Manufacturing
                description:
                  type: string
                  nullable: true
                  description: Supplier description
                  example: Primary overseas supplier for apparel
                street_address:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: 123 Industrial Way
                city:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Shenzhen
                state:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Guangdong
                zip:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '518000'
                country:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: China
                factory_admin_id:
                  type: integer
                  nullable: true
                  description: ID of the internal user to set as the primary admin for this supplier
                  example: 100
                bank_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: Bank of China
                routing_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '021000021'
                account_number:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: '1234567890'
                swift_code:
                  type: string
                  maxLength: 255
                  nullable: true
                  example: BKCHCNBJ
                default_payment_term:
                  type: string
                  nullable: true
                  description: Default payment term name. Must match one of the payment term names configured in Luminous.
                  example: Net 30
                default_currency_code:
                  type: string
                  nullable: true
                  minLength: 3
                  maxLength: 3
                  description: Default ISO 4217 currency code for this supplier (3 letters). Auto-applied to new purchase orders created for the supplier.
                  example: USD
                contact_ids:
                  type: array
                  nullable: true
                  description: IDs of existing contacts to link to this supplier
                  items:
                    type: integer
                  example:
                    - 501
                    - 502
                default_logistic_code:
                  type: string
                  nullable: true
                  enum:
                    - fob
                    - exw
                    - cif
                    - ddp
                    - fca
                  description: Incoterm applied to a purchase order raised for this supplier when the order does not name one itself.
                  example: fob
                default_warehouse_id:
                  type: integer
                  nullable: true
                  description: 'Warehouse a purchase order raised for this supplier defaults to when the order does not name one. A warehouse id, as returned by GET /warehouses.'
                  example: 7
                default_order_type:
                  type: string
                  nullable: true
                  enum:
                    - INTERNAL_TRANSFER_ORDER
                    - DROP_SHIP_ORDER
                  description: Order type a purchase order raised for this supplier defaults to when the order does not name one.
                  example: DROP_SHIP_ORDER
                default_requested_ship_date_offset_days:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its requested ship date, when the order does not carry one. Must be 0 or greater.'
                  example: 14
                default_arrival_due_date_offset_days:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: |
                    Whole calendar days (not business days) added to a purchase order's order date to produce its arrival due date, when the order does not carry one. Must be 0 or greater.

                    Must also be greater than or equal to `default_requested_ship_date_offset_days`, or the request fails with a 422 on this field. An offset you don't send is taken from the supplier's stored value, and the check is skipped when either offset ends up null. When updating an existing supplier, the check only runs if at least one offset is actually changing, so a supplier already stored with arrival earlier than ship can still be saved for unrelated edits.
                  example: 30
                ship_to_addresses:
                  type: array
                  nullable: true
                  description: |
                    The supplier's saved ship-to address set. There is no separate "default ship to" field — the default is the entry flagged `is_default`, and the set is normalized so exactly one carries the flag whenever it is non-empty.

                    Sending `ship_to_addresses` replaces rather than merges the set (even an empty array writes it); omitting it leaves the existing set untouched.
                  items:
                    type: object
                    properties:
                      is_default:
                        type: boolean
                        nullable: true
                        example: true
                      ship_to_name:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Main Warehouse
                      ship_to_company:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Acme Distribution
                      ship_to_phone:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: +1 555 123 4567
                      ship_to_email:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: receiving@acme.example
                      street_address_1:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: 500 Distribution Blvd
                      street_address_2:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Suite 200
                      street_address_3:
                        type: string
                        maxLength: 255
                        nullable: true
                      city:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: Dallas
                      state:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: TX
                      zip:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: '75201'
                      country:
                        type: string
                        maxLength: 255
                        nullable: true
                        example: USA
                custom_fields:
                  type: object
                  nullable: true
                  description: |
                    Custom field values as a `label => value` map, matching the shape GET returns. Only fields defined for the supplier object type are accepted; a label that is unknown, scoped to another object type, or a case-variant duplicate is rejected with a 422. Set a value to `null` to clear that field.

                    Sending `custom_fields` replaces rather than merges; omitting it leaves the existing values untouched.
                  example:
                    Region: Southwest
                    Preferred Carrier: UPS
      responses:
        '200':
          description: Supplier successfully updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the supplier
                        example: 42
                      status:
                        type: integer
                        description: Numeric status flag (1 = active)
                        example: 1
                      created_at:
                        type: string
                        format: date-time
                        description: When the supplier was created
                        example: '2026-04-20T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the supplier was last updated
                        example: '2026-04-20T14:30:00Z'
                      created_by:
                        type: integer
                        nullable: true
                        description: ID of the user that created this supplier
                        example: 100
                      updated_by:
                        type: integer
                        nullable: true
                        description: ID of the user that last updated this supplier
                        example: 100
                      name:
                        type: string
                        description: Supplier name
                        example: Acme Manufacturing
                      description:
                        type: string
                        nullable: true
                        description: Supplier description
                        example: Primary overseas supplier for apparel
                      street_address:
                        type: string
                        nullable: true
                        example: 123 Industrial Way
                      city:
                        type: string
                        nullable: true
                        example: Shenzhen
                      state:
                        type: string
                        nullable: true
                        example: Guangdong
                      zip:
                        type: string
                        nullable: true
                        example: '518000'
                      country:
                        type: string
                        nullable: true
                        example: China
                      factory_admin_id:
                        type: integer
                        nullable: true
                        description: ID of the internal user acting as the primary admin for this supplier
                        example: 100
                      supplier_admin_id:
                        type: integer
                        nullable: true
                        description: Alias of `factory_admin_id`
                        example: 100
                      contact_name:
                        type: string
                        nullable: true
                        description: Legacy single-contact name (use `contacts` for the full list)
                        example: Jane Doe
                      contact_email:
                        type: string
                        format: email
                        nullable: true
                        description: Legacy single-contact email (use `contacts` for the full list)
                        example: jane@acme.example
                      contact_phone:
                        type: string
                        nullable: true
                        description: Legacy single-contact phone (use `contacts` for the full list)
                        example: +86 755 1234 5678
                      bank_name:
                        type: string
                        nullable: true
                        example: Bank of China
                      routing_number:
                        type: string
                        nullable: true
                        example: '021000021'
                      account_number:
                        type: string
                        nullable: true
                        example: '1234567890'
                      swift_code:
                        type: string
                        nullable: true
                        example: BKCHCNBJ
                      default_payment_term:
                        type: string
                        nullable: true
                        description: 'Default payment term name, matches the set available to companies'
                        example: Net 30
                      default_currency_code:
                        type: string
                        nullable: true
                        description: Default ISO 4217 currency code for this supplier. Auto-applied to new purchase orders created for the supplier.
                        example: USD
                      default_logistic_code:
                        type: string
                        nullable: true
                        description: 'Incoterm applied to a purchase order raised for this supplier when the order does not name one itself. One of "fob", "exw", "cif", "ddp" or "fca". Null when the supplier has no Incoterm default.'
                        example: fob
                      default_warehouse_id:
                        type: integer
                        nullable: true
                        description: 'Warehouse a purchase order raised for this supplier defaults to when the order does not name one. A warehouse id, as returned by GET /warehouses. Null when the supplier has no warehouse default.'
                        example: 7
                      default_order_type:
                        type: string
                        nullable: true
                        description: Order type a purchase order raised for this supplier defaults to when the order does not name one. Either "INTERNAL_TRANSFER_ORDER" or "DROP_SHIP_ORDER". Null when the supplier has no order type default.
                        example: DROP_SHIP_ORDER
                      default_requested_ship_date_offset_days:
                        type: integer
                        nullable: true
                        description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its requested ship date, when the order does not carry one. Null when the supplier has no requested ship date default.'
                        example: 14
                      default_arrival_due_date_offset_days:
                        type: integer
                        nullable: true
                        description: 'Whole calendar days (not business days) added to a purchase order''s order date to produce its arrival due date, when the order does not carry one. Null when the supplier has no arrival due date default.'
                        example: 30
                      custom_fields:
                        type: object
                        description: 'Map of the supplier''s custom field values as label => value pairs. Only fields defined for the supplier object type appear. Always a JSON object; empty when no custom fields are set. Field definitions are available via GET /custom-fields?object_type=supplier. Writable via POST — see the create/update request body. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        example:
                          Region: Southwest
                          Preferred Carrier: UPS
                          Onboarded On: '2025-03-14'
                      ship_to_addresses:
                        type: array
                        nullable: true
                        description: Addresses saved against this supplier for shipping purchase orders to (only present when the relation is loaded). The one entry with `is_default` true is the address a purchase order raised for this supplier ships to when the order does not carry its own; exactly one entry carries the flag whenever the set is non-empty.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 88
                            is_default:
                              type: boolean
                              example: true
                            ship_to_name:
                              type: string
                              nullable: true
                              example: Main Warehouse
                            ship_to_company:
                              type: string
                              nullable: true
                              example: Acme Distribution
                            ship_to_phone:
                              type: string
                              nullable: true
                              example: +1 555 123 4567
                            ship_to_email:
                              type: string
                              nullable: true
                              example: receiving@acme.example
                            street_address_1:
                              type: string
                              nullable: true
                              example: 500 Distribution Blvd
                            street_address_2:
                              type: string
                              nullable: true
                              example: Suite 200
                            street_address_3:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                              example: Dallas
                            state:
                              type: string
                              nullable: true
                              example: TX
                            zip:
                              type: string
                              nullable: true
                              example: '75201'
                            country:
                              type: string
                              nullable: true
                              example: USA
                      contacts:
                        type: array
                        nullable: true
                        description: Linked contacts (only present when the relation is loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 501
                            name:
                              type: string
                              nullable: true
                              example: Jane Doe
                            email:
                              type: string
                              format: email
                              nullable: true
                              example: jane@acme.example
                            phone:
                              type: string
                              nullable: true
                              example: +86 755 1234 5678
                    required:
                      - id
                      - name
                      - status
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteSupplier
      tags:
        - Suppliers
      summary: Delete a supplier
      description: Delete a supplier by ID.
      security:
        - BearerAuth: []
      parameters:
        - name: supplierId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the supplier
      responses:
        '204':
          description: Supplier successfully deleted
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  '/suppliers/{supplierId}/contacts':
    get:
      operationId: getSupplierContacts
      tags:
        - Suppliers
      summary: Supplier contacts
      description: 'List the contacts attached to a supplier. Suppliers hold contacts separately from company contacts, so these are not reachable via the company-scoped `POST /contacts` endpoint.'
      security:
        - BearerAuth: []
      parameters:
        - name: supplierId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the supplier.
      responses:
        '200':
          description: A list of the supplier's contacts
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A contact attached to a supplier.
                      properties:
                        contact_details_id:
                          type: integer
                          description: 'Stable identifier of the contact. The supplier-contact link has no surrogate key, so this is the ID a caller references.'
                        supplier_id:
                          type: integer
                          description: ID of the supplier the contact is attached to.
                        name:
                          type: string
                          nullable: true
                          description: Contact name.
                        email:
                          type: string
                          nullable: true
                          description: Contact email address.
                        phone:
                          type: string
                          nullable: true
                          description: Contact phone number.
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp of when the contact link was created.
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp of when the contact link was last updated.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    post:
      operationId: addSupplierContact
      tags:
        - Suppliers
      summary: Add a supplier contact
      description: Attach a new contact to a supplier. This appends to the supplier's existing contacts rather than replacing them. The contact email must be unique across the platform.
      security:
        - BearerAuth: []
      parameters:
        - name: supplierId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the supplier.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contact_name
                - contact_email
              properties:
                contact_name:
                  type: string
                  maxLength: 255
                  description: Contact name.
                contact_email:
                  type: string
                  format: email
                  maxLength: 255
                  description: Contact email address. Must be unique across all contacts on the platform; reusing an existing email returns a `422` validation error.
                contact_phone:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Contact phone number.
      responses:
        '201':
          description: Contact successfully attached to the supplier
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A contact attached to a supplier.
                    properties:
                      contact_details_id:
                        type: integer
                        description: 'Stable identifier of the contact. The supplier-contact link has no surrogate key, so this is the ID a caller references.'
                      supplier_id:
                        type: integer
                        description: ID of the supplier the contact is attached to.
                      name:
                        type: string
                        nullable: true
                        description: Contact name.
                      email:
                        type: string
                        nullable: true
                        description: Contact email address.
                      phone:
                        type: string
                        nullable: true
                        description: Contact phone number.
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp of when the contact link was created.
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp of when the contact link was last updated.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /supplier-skus/bulk:
    post:
      operationId: bulkUpsertSupplierSkus
      tags:
        - Supplier SKUs
      summary: Bulk upsert supplier SKUs
      description: |
        Upserts multiple supplier SKU records for a single supplier, keyed by
        **internal Luminous SKU**. For each item:
        - If a record already exists for the resolved product + supplier, it is updated.
        - Otherwise a new record is created.

        Items with an unrecognized `internal_sku` (not matching any Luminous product)
        are skipped and counted in `skipped`. Items that fail validation are counted
        in `errors`.

        Returns a summary with counts of created, updated, skipped, and errored rows —
        not a collection of the upserted records.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - supplier_id
                - items
              properties:
                supplier_id:
                  type: integer
                  description: Supplier ID that all items belong to
                items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - internal_sku
                      - sku
                    properties:
                      internal_sku:
                        type: string
                        description: Luminous internal SKU used to look up the product
                      sku:
                        type: string
                        description: Supplier-specific SKU to record
                      unit_cost:
                        type: number
                        minimum: 0
                        nullable: true
                        description: Per-unit cost from this supplier
                      moq_quantity:
                        type: number
                        minimum: 0
                        nullable: true
                        description: Minimum order quantity for this supplier SKU
                      moq_unit_id:
                        type: integer
                        nullable: true
                        description: ID of the unit of measure the MOQ is expressed in
      responses:
        '200':
          description: Bulk upsert summary
          content:
            application/json:
              schema:
                type: object
                properties:
                  created:
                    type: integer
                  updated:
                    type: integer
                  skipped:
                    type: integer
                    description: Rows skipped due to unrecognized `internal_sku`
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        row:
                          type: integer
                          description: Zero-based index of the failed item
                        message:
                          type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /supplier-skus:
    get:
      operationId: getSupplierSkus
      tags:
        - Supplier SKUs
      summary: List supplier SKUs
      description: |
        Returns a paginated list of supplier-specific SKU and unit-cost overrides.
        Each row represents one supplier's SKU for a given Luminous product.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### Integer Filters
        - `product_id`: Filter by Luminous product ID
        - `supplier_id`: Filter by supplier ID

        ### String Filters
        - `sku`: Supplier SKU

        ### Numeric Filters
        - `unit_cost`: Per-unit cost from this supplier

        ### DateTime Filters
        - `created_at`: When the record was created
        - `updated_at`: When the record was last updated
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Items per page (max 100)
        - in: query
          name: product_id
          schema:
            type: integer
          description: Filter by product ID
        - in: query
          name: supplier_id
          schema:
            type: integer
          description: Filter by supplier ID
        - in: query
          name: sku
          schema:
            type: string
          description: Filter by supplier SKU
        - in: query
          name: unit_cost
          schema:
            type: number
          description: Filter by unit cost
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
      responses:
        '200':
          description: Paginated list of supplier SKU records
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier
                        product_id:
                          type: integer
                          description: Luminous product (rfq) ID
                        supplier_id:
                          type: integer
                          description: Supplier (factory) ID
                        sku:
                          type: string
                          description: Supplier-specific SKU for this product
                        unit_cost:
                          type: number
                          format: float
                          nullable: true
                          description: Per-unit cost from this supplier; null if not set
                        moq_quantity:
                          type: number
                          format: float
                          nullable: true
                          description: Minimum order quantity for this supplier SKU; null if not set
                        moq_unit_id:
                          type: integer
                          nullable: true
                          description: ID of the unit of measure the MOQ is expressed in; null if not set
                        moq_unit:
                          nullable: true
                          description: Embedded MOQ unit of measure (present when the `moqUnit` relation is loaded)
                          type: object
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            status:
                              type: string
                              nullable: true
                            unit_class_id:
                              type: integer
                            unit_class:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                base_class:
                                  type: boolean
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            base_unit:
                              type: boolean
                              description: True if this UOM is the base unit for its class.
                            unit_conversion_rules:
                              type: array
                              description: Present when the relation is loaded.
                              items:
                                type: object
                                description: |
                                  A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                  1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                properties:
                                  id:
                                    type: integer
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  status:
                                    type: string
                                    nullable: true
                                  base_unit_of_measure_id:
                                    type: integer
                                  base_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  converted_unit_of_measure_id:
                                    type: integer
                                  converted_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  conversion_factor:
                                    type: number
                                    description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                  type:
                                    type: string
                                    enum:
                                      - SYSTEM
                                      - SKU
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Required when `type=SKU`; null when `type=SYSTEM`.
                                  product:
                                    type: object
                                    nullable: true
                                    description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                    additionalProperties: true
                                  product_alternate_skus:
                                    type: array
                                    description: Present when the relation is loaded.
                                    items:
                                      type: object
                                      additionalProperties: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        product:
                          type: object
                          nullable: true
                          description: Embedded product summary (present when loaded)
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                              description: Internal Luminous SKU
                            name:
                              type: string
                        supplier:
                          type: object
                          nullable: true
                          description: Embedded supplier (present when loaded)
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            contact_name:
                              type: string
                              nullable: true
                            contact_email:
                              type: string
                              nullable: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createSupplierSku
      tags:
        - Supplier SKUs
      summary: Create a supplier SKU
      description: |
        Creates a new supplier-specific SKU and optional unit cost for a given
        product/supplier pair. The combination of `product_id` + `supplier_id` + `sku`
        must be unique; the underlying service enforces this constraint.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - product_id
                - supplier_id
                - sku
              properties:
                product_id:
                  type: integer
                  description: Luminous product (rfq) ID
                supplier_id:
                  type: integer
                  description: Supplier ID
                sku:
                  type: string
                  maxLength: 255
                  description: Supplier-specific SKU
                unit_cost:
                  type: number
                  minimum: 0
                  nullable: true
                  description: Per-unit cost from this supplier
                moq_quantity:
                  type: number
                  minimum: 0
                  nullable: true
                  description: Minimum order quantity for this supplier SKU
                moq_unit_id:
                  type: integer
                  nullable: true
                  description: ID of the unit of measure the MOQ is expressed in
      responses:
        '201':
          description: Supplier SKU created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier
                      product_id:
                        type: integer
                        description: Luminous product (rfq) ID
                      supplier_id:
                        type: integer
                        description: Supplier (factory) ID
                      sku:
                        type: string
                        description: Supplier-specific SKU for this product
                      unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Per-unit cost from this supplier; null if not set
                      moq_quantity:
                        type: number
                        format: float
                        nullable: true
                        description: Minimum order quantity for this supplier SKU; null if not set
                      moq_unit_id:
                        type: integer
                        nullable: true
                        description: ID of the unit of measure the MOQ is expressed in; null if not set
                      moq_unit:
                        nullable: true
                        description: Embedded MOQ unit of measure (present when the `moqUnit` relation is loaded)
                        type: object
                        properties:
                          id:
                            type: integer
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          status:
                            type: string
                            nullable: true
                          unit_class_id:
                            type: integer
                          unit_class:
                            type: object
                            description: Present when the relation is loaded.
                            nullable: true
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              base_class:
                                type: boolean
                          name:
                            type: string
                          description:
                            type: string
                            nullable: true
                          base_unit:
                            type: boolean
                            description: True if this UOM is the base unit for its class.
                          unit_conversion_rules:
                            type: array
                            description: Present when the relation is loaded.
                            items:
                              type: object
                              description: |
                                A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                              properties:
                                id:
                                  type: integer
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                                status:
                                  type: string
                                  nullable: true
                                base_unit_of_measure_id:
                                  type: integer
                                base_unit_of_measure:
                                  type: object
                                  description: Present when the relation is loaded.
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    unit_class_id:
                                      type: integer
                                    base_unit:
                                      type: boolean
                                converted_unit_of_measure_id:
                                  type: integer
                                converted_unit_of_measure:
                                  type: object
                                  description: Present when the relation is loaded.
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    unit_class_id:
                                      type: integer
                                    base_unit:
                                      type: boolean
                                conversion_factor:
                                  type: number
                                  description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                type:
                                  type: string
                                  enum:
                                    - SYSTEM
                                    - SKU
                                product_id:
                                  type: integer
                                  nullable: true
                                  description: Required when `type=SKU`; null when `type=SYSTEM`.
                                product:
                                  type: object
                                  nullable: true
                                  description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                  additionalProperties: true
                                product_alternate_skus:
                                  type: array
                                  description: Present when the relation is loaded.
                                  items:
                                    type: object
                                    additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      product:
                        type: object
                        nullable: true
                        description: Embedded product summary (present when loaded)
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                            description: Internal Luminous SKU
                          name:
                            type: string
                      supplier:
                        type: object
                        nullable: true
                        description: Embedded supplier (present when loaded)
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          contact_name:
                            type: string
                            nullable: true
                          contact_email:
                            type: string
                            nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error or uniqueness conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/supplier-skus/{supplierProductSkuId}':
    get:
      operationId: getSupplierSku
      tags:
        - Supplier SKUs
      summary: Get a supplier SKU
      description: Returns a single supplier SKU record by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: supplierProductSkuId
          required: true
          schema:
            type: integer
          description: Supplier SKU record ID
      responses:
        '200':
          description: Supplier SKU details
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier
                      product_id:
                        type: integer
                        description: Luminous product (rfq) ID
                      supplier_id:
                        type: integer
                        description: Supplier (factory) ID
                      sku:
                        type: string
                        description: Supplier-specific SKU for this product
                      unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Per-unit cost from this supplier; null if not set
                      moq_quantity:
                        type: number
                        format: float
                        nullable: true
                        description: Minimum order quantity for this supplier SKU; null if not set
                      moq_unit_id:
                        type: integer
                        nullable: true
                        description: ID of the unit of measure the MOQ is expressed in; null if not set
                      moq_unit:
                        nullable: true
                        description: Embedded MOQ unit of measure (present when the `moqUnit` relation is loaded)
                        type: object
                        properties:
                          id:
                            type: integer
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          status:
                            type: string
                            nullable: true
                          unit_class_id:
                            type: integer
                          unit_class:
                            type: object
                            description: Present when the relation is loaded.
                            nullable: true
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              base_class:
                                type: boolean
                          name:
                            type: string
                          description:
                            type: string
                            nullable: true
                          base_unit:
                            type: boolean
                            description: True if this UOM is the base unit for its class.
                          unit_conversion_rules:
                            type: array
                            description: Present when the relation is loaded.
                            items:
                              type: object
                              description: |
                                A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                              properties:
                                id:
                                  type: integer
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                                status:
                                  type: string
                                  nullable: true
                                base_unit_of_measure_id:
                                  type: integer
                                base_unit_of_measure:
                                  type: object
                                  description: Present when the relation is loaded.
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    unit_class_id:
                                      type: integer
                                    base_unit:
                                      type: boolean
                                converted_unit_of_measure_id:
                                  type: integer
                                converted_unit_of_measure:
                                  type: object
                                  description: Present when the relation is loaded.
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    unit_class_id:
                                      type: integer
                                    base_unit:
                                      type: boolean
                                conversion_factor:
                                  type: number
                                  description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                type:
                                  type: string
                                  enum:
                                    - SYSTEM
                                    - SKU
                                product_id:
                                  type: integer
                                  nullable: true
                                  description: Required when `type=SKU`; null when `type=SYSTEM`.
                                product:
                                  type: object
                                  nullable: true
                                  description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                  additionalProperties: true
                                product_alternate_skus:
                                  type: array
                                  description: Present when the relation is loaded.
                                  items:
                                    type: object
                                    additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      product:
                        type: object
                        nullable: true
                        description: Embedded product summary (present when loaded)
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                            description: Internal Luminous SKU
                          name:
                            type: string
                      supplier:
                        type: object
                        nullable: true
                        description: Embedded supplier (present when loaded)
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          contact_name:
                            type: string
                            nullable: true
                          contact_email:
                            type: string
                            nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateSupplierSku
      tags:
        - Supplier SKUs
      summary: Update a supplier SKU
      description: |
        Updates a supplier SKU record. All fields are optional — only fields
        present in the body are changed.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: supplierProductSkuId
          required: true
          schema:
            type: integer
          description: Supplier SKU record ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                product_id:
                  type: integer
                  description: Luminous product (rfq) ID
                supplier_id:
                  type: integer
                  description: Supplier ID
                sku:
                  type: string
                  maxLength: 255
                  description: Supplier-specific SKU
                unit_cost:
                  type: number
                  minimum: 0
                  nullable: true
                  description: Per-unit cost; pass `null` to clear
                moq_quantity:
                  type: number
                  minimum: 0
                  nullable: true
                  description: Minimum order quantity; pass `null` to clear
                moq_unit_id:
                  type: integer
                  nullable: true
                  description: ID of the unit of measure the MOQ is expressed in; pass `null` to clear
      responses:
        '200':
          description: Updated supplier SKU
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier
                      product_id:
                        type: integer
                        description: Luminous product (rfq) ID
                      supplier_id:
                        type: integer
                        description: Supplier (factory) ID
                      sku:
                        type: string
                        description: Supplier-specific SKU for this product
                      unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Per-unit cost from this supplier; null if not set
                      moq_quantity:
                        type: number
                        format: float
                        nullable: true
                        description: Minimum order quantity for this supplier SKU; null if not set
                      moq_unit_id:
                        type: integer
                        nullable: true
                        description: ID of the unit of measure the MOQ is expressed in; null if not set
                      moq_unit:
                        nullable: true
                        description: Embedded MOQ unit of measure (present when the `moqUnit` relation is loaded)
                        type: object
                        properties:
                          id:
                            type: integer
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          status:
                            type: string
                            nullable: true
                          unit_class_id:
                            type: integer
                          unit_class:
                            type: object
                            description: Present when the relation is loaded.
                            nullable: true
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              base_class:
                                type: boolean
                          name:
                            type: string
                          description:
                            type: string
                            nullable: true
                          base_unit:
                            type: boolean
                            description: True if this UOM is the base unit for its class.
                          unit_conversion_rules:
                            type: array
                            description: Present when the relation is loaded.
                            items:
                              type: object
                              description: |
                                A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                              properties:
                                id:
                                  type: integer
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                                status:
                                  type: string
                                  nullable: true
                                base_unit_of_measure_id:
                                  type: integer
                                base_unit_of_measure:
                                  type: object
                                  description: Present when the relation is loaded.
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    unit_class_id:
                                      type: integer
                                    base_unit:
                                      type: boolean
                                converted_unit_of_measure_id:
                                  type: integer
                                converted_unit_of_measure:
                                  type: object
                                  description: Present when the relation is loaded.
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    unit_class_id:
                                      type: integer
                                    base_unit:
                                      type: boolean
                                conversion_factor:
                                  type: number
                                  description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                type:
                                  type: string
                                  enum:
                                    - SYSTEM
                                    - SKU
                                product_id:
                                  type: integer
                                  nullable: true
                                  description: Required when `type=SKU`; null when `type=SYSTEM`.
                                product:
                                  type: object
                                  nullable: true
                                  description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                  additionalProperties: true
                                product_alternate_skus:
                                  type: array
                                  description: Present when the relation is loaded.
                                  items:
                                    type: object
                                    additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      product:
                        type: object
                        nullable: true
                        description: Embedded product summary (present when loaded)
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                            description: Internal Luminous SKU
                          name:
                            type: string
                      supplier:
                        type: object
                        nullable: true
                        description: Embedded supplier (present when loaded)
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          contact_name:
                            type: string
                            nullable: true
                          contact_email:
                            type: string
                            nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error or uniqueness conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteSupplierSku
      tags:
        - Supplier SKUs
      summary: Delete a supplier SKU
      description: Permanently deletes a supplier SKU record.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: supplierProductSkuId
          required: true
          schema:
            type: integer
          description: Supplier SKU record ID
      responses:
        '204':
          description: Deleted successfully
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/companies/{companyId}/contacts':
    get:
      operationId: getCompanyContacts
      tags:
        - Companies
        - Contacts
      summary: Company Contacts
      description: |
        Get a paginated list of contacts associated with a specific company.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `first_name`: Contact first name
        - `last_name`: Contact last name
        - `email`: Contact email
        - `phone`: Contact phone number
        - `status`: Contact status
        - `company.name`: Company name

        ### DateTime Filters
        - `created_at`: When the contact was created
        - `updated_at`: When the contact was last updated
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the company
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: first_name
          schema:
            type: string
          description: Filter by contact first name
        - in: query
          name: last_name
          schema:
            type: string
          description: Filter by contact last name
        - in: query
          name: email
          schema:
            type: string
          description: Filter by contact email
        - in: query
          name: phone
          schema:
            type: string
          description: Filter by contact phone number
        - in: query
          name: status
          schema:
            type: string
          description: Filter by contact status
        - in: query
          name: company.name
          schema:
            type: string
          description: Filter by company name
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
      responses:
        '200':
          description: A list of company contacts
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Unique identifier for the contact
                          example: '789123'
                        created_at:
                          type: string
                          format: date-time
                          description: When the contact was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the contact was last updated
                          example: '2023-03-15T14:30:00Z'
                        status:
                          type: string
                          description: Current status of the contact
                          example: active
                        first_name:
                          type: string
                          description: Contact's first name
                          example: John
                        last_name:
                          type: string
                          description: Contact's last name
                          example: Smith
                        email:
                          type: string
                          format: email
                          description: Contact's email address
                          example: john.smith@acmecorp.com
                        phone:
                          type: string
                          description: Contact's primary phone number
                          example: 555-987-6543
                        phone_2:
                          type: string
                          description: Contact's secondary phone number
                          example: 555-555-5555
                        full_name:
                          type: string
                          description: Contact's full name
                          example: John Smith
                        company_id:
                          type: string
                          description: ID of the company this contact belongs to
                          example: '123456'
                        company:
                          type: object
                          description: Company information for this contact
                          properties:
                            id:
                              type: string
                              example: '123456'
                            name:
                              type: string
                              example: Acme Corporation
                        is_primary:
                          type: boolean
                          description: Whether this is the primary contact for the company
                          example: true
                        receive_quotation_pdf:
                          type: boolean
                          description: Whether the contact should receive quotation PDFs
                          example: false
                        receive_purchase_order_pdf:
                          type: boolean
                          description: Whether the contact should receive purchase order PDFs
                          example: false
                        receive_purchase_order_invoice_pdf:
                          type: boolean
                          description: Whether the contact should receive purchase order invoice PDFs
                          example: false
                        has_portal_login:
                          type: boolean
                          description: True when the contact has a linked B2B client portal login
                          example: false
                        companies:
                          type: array
                          description: Companies associated with this contact (when loaded)
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                                nullable: true
                              is_primary:
                                type: boolean
                              receive_quotation_pdf:
                                type: boolean
                              receive_purchase_order_pdf:
                                type: boolean
                              receive_purchase_order_invoice_pdf:
                                type: boolean
                        tags:
                          type: array
                          description: Tags associated with the contact
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              icon:
                                type: string
                                nullable: true
                              color:
                                type: string
                                nullable: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  '/companies/{companyId}/product-price-overrides':
    get:
      operationId: getCompanyProductPriceOverrides
      tags:
        - Companies
        - Pricing
      summary: Company Product Price Overrides
      description: |
        Get a list of product-specific price overrides for a particular company.

        These price overrides allow specific products to have custom pricing when sold to a particular company,
        overriding the standard pricing or any applicable price schedule.
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the company
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: A list of product price overrides for the company
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: number
                          description: Unique identifier for the price override
                          example: 123
                        created_at:
                          type: string
                          format: date-time
                          description: When the price override was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the price override was last updated
                          example: '2023-03-15T14:30:00Z'
                        status:
                          type: string
                          description: Status of the price override record
                          enum:
                            - Active
                            - Inactive
                            - Deleted
                          example: Active
                        company_id:
                          type: number
                          description: ID of the company this price override applies to
                          example: 5567
                        product_id:
                          type: number
                          description: ID of the product being overridden
                          example: 567890
                        price:
                          type: number
                          format: float
                          description: The override price for this product when sold to this company
                          example: 42.5
                        product:
                          type: object
                          nullable: true
                          description: Product information (included when the product relation is loaded)
                          properties:
                            id:
                              type: number
                              description: Unique identifier for the product
                              example: 567890
                            sku:
                              type: string
                              description: Internal SKU/code of the product
                              example: WIDGET-123
                            name:
                              type: string
                              description: Name of the product
                              example: Deluxe Widget
                            retail_price:
                              type: number
                              format: float
                              description: Standard retail price of the product
                              example: 59.99
                            wholesale_price:
                              type: number
                              format: float
                              description: Standard wholesale price of the product
                              example: 49.99
                            variant_parent_id:
                              type: integer
                              nullable: true
                              description: ID of the parent product if this is a variant
                              example: null
                            is_variant:
                              type: boolean
                              description: Whether this product is a variant of another product
                              example: false
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    post:
      operationId: createCompanyProductPriceOverride
      tags:
        - Companies
        - Pricing
      summary: Create company product price override
      description: |
        Set a company-specific price for one product. Identify the product by `product_id`, `sku`,
        or both (when both are sent they must refer to the same product).

        Returns a 422 if the company already has an active override for the product — update it with
        `POST /companies/{companyId}/product-price-overrides/{overrideId}` or use the bulk upsert
        instead. A previously deleted override for the same product is restored with the new price.
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - price
              properties:
                product_id:
                  type: integer
                  description: Product ID. Required when `sku` is not sent.
                  example: 567890
                sku:
                  type: string
                  description: Product SKU. Required when `product_id` is not sent. Must match exactly one active product.
                  example: TEE-BLK-M
                price:
                  type: number
                  minimum: 0
                  description: The company's price for this product
                  example: 18.5
      responses:
        '201':
          description: Price override created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: number
                        description: Unique identifier for the price override
                        example: 123
                      created_at:
                        type: string
                        format: date-time
                        description: When the price override was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the price override was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Status of the price override record
                        enum:
                          - Active
                          - Inactive
                          - Deleted
                        example: Active
                      company_id:
                        type: number
                        description: ID of the company this price override applies to
                        example: 5567
                      product_id:
                        type: number
                        description: ID of the product being overridden
                        example: 567890
                      price:
                        type: number
                        format: float
                        description: The override price for this product when sold to this company
                        example: 42.5
                      product:
                        type: object
                        nullable: true
                        description: Product information (included when the product relation is loaded)
                        properties:
                          id:
                            type: number
                            description: Unique identifier for the product
                            example: 567890
                          sku:
                            type: string
                            description: Internal SKU/code of the product
                            example: WIDGET-123
                          name:
                            type: string
                            description: Name of the product
                            example: Deluxe Widget
                          retail_price:
                            type: number
                            format: float
                            description: Standard retail price of the product
                            example: 59.99
                          wholesale_price:
                            type: number
                            format: float
                            description: Standard wholesale price of the product
                            example: 49.99
                          variant_parent_id:
                            type: integer
                            nullable: true
                            description: ID of the parent product if this is a variant
                            example: null
                          is_variant:
                            type: boolean
                            description: Whether this product is a variant of another product
                            example: false
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: 'Validation error (product not found, SKU matches no or several products, or an override already exists for the product)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/companies/{companyId}/product-price-overrides/bulk':
    post:
      operationId: bulkUpsertCompanyProductPriceOverrides
      tags:
        - Companies
        - Pricing
      summary: Bulk upsert company product price overrides
      description: |
        Create or update a company's price for many products in one call. For each item, an existing
        override for that product is updated (a deleted one is restored); otherwise a new one is
        created.

        Each item needs a `product_id` or a `sku`. The whole call runs in one transaction: if any item
        fails validation, nothing is saved, and the error key names the item (for example
        `items.2.sku`).
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - price
                    properties:
                      product_id:
                        type: integer
                        nullable: true
                        description: Product ID. Required when `sku` is not sent.
                      sku:
                        type: string
                        nullable: true
                        description: Product SKU. Required when `product_id` is not sent. Must match exactly one active product.
                      price:
                        type: number
                        minimum: 0
                        description: The company's price for this product
              example:
                items:
                  - sku: TEE-BLK-M
                    price: 18.5
                  - product_id: 567890
                    price: 22
      responses:
        '200':
          description: 'The saved overrides, in request order'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: number
                          description: Unique identifier for the price override
                          example: 123
                        created_at:
                          type: string
                          format: date-time
                          description: When the price override was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the price override was last updated
                          example: '2023-03-15T14:30:00Z'
                        status:
                          type: string
                          description: Status of the price override record
                          enum:
                            - Active
                            - Inactive
                            - Deleted
                          example: Active
                        company_id:
                          type: number
                          description: ID of the company this price override applies to
                          example: 5567
                        product_id:
                          type: number
                          description: ID of the product being overridden
                          example: 567890
                        price:
                          type: number
                          format: float
                          description: The override price for this product when sold to this company
                          example: 42.5
                        product:
                          type: object
                          nullable: true
                          description: Product information (included when the product relation is loaded)
                          properties:
                            id:
                              type: number
                              description: Unique identifier for the product
                              example: 567890
                            sku:
                              type: string
                              description: Internal SKU/code of the product
                              example: WIDGET-123
                            name:
                              type: string
                              description: Name of the product
                              example: Deluxe Widget
                            retail_price:
                              type: number
                              format: float
                              description: Standard retail price of the product
                              example: 59.99
                            wholesale_price:
                              type: number
                              format: float
                              description: Standard wholesale price of the product
                              example: 49.99
                            variant_parent_id:
                              type: integer
                              nullable: true
                              description: ID of the parent product if this is a variant
                              example: null
                            is_variant:
                              type: boolean
                              description: Whether this product is a variant of another product
                              example: false
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error; nothing was saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/companies/{companyId}/product-price-overrides/{overrideId}':
    post:
      operationId: updateCompanyProductPriceOverride
      tags:
        - Companies
        - Pricing
      summary: Update company product price override
      description: Change the price on one of a company's product price overrides.
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
        - name: overrideId
          in: path
          required: true
          schema:
            type: integer
          description: 'ID of the price override (the `id` from `GET /companies/{companyId}/product-price-overrides`)'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - price
              properties:
                price:
                  type: number
                  minimum: 0
                  description: The company's new price for this product
                  example: 17.25
      responses:
        '200':
          description: The updated price override
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: number
                        description: Unique identifier for the price override
                        example: 123
                      created_at:
                        type: string
                        format: date-time
                        description: When the price override was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the price override was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Status of the price override record
                        enum:
                          - Active
                          - Inactive
                          - Deleted
                        example: Active
                      company_id:
                        type: number
                        description: ID of the company this price override applies to
                        example: 5567
                      product_id:
                        type: number
                        description: ID of the product being overridden
                        example: 567890
                      price:
                        type: number
                        format: float
                        description: The override price for this product when sold to this company
                        example: 42.5
                      product:
                        type: object
                        nullable: true
                        description: Product information (included when the product relation is loaded)
                        properties:
                          id:
                            type: number
                            description: Unique identifier for the product
                            example: 567890
                          sku:
                            type: string
                            description: Internal SKU/code of the product
                            example: WIDGET-123
                          name:
                            type: string
                            description: Name of the product
                            example: Deluxe Widget
                          retail_price:
                            type: number
                            format: float
                            description: Standard retail price of the product
                            example: 59.99
                          wholesale_price:
                            type: number
                            format: float
                            description: Standard wholesale price of the product
                            example: 49.99
                          variant_parent_id:
                            type: integer
                            nullable: true
                            description: ID of the parent product if this is a variant
                            example: null
                          is_variant:
                            type: boolean
                            description: Whether this product is a variant of another product
                            example: false
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: 'Company not found, or the override does not belong to this company'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteCompanyProductPriceOverride
      tags:
        - Companies
        - Pricing
      summary: Delete company product price override
      description: Remove one of a company's product price overrides. The product goes back to the company's normal pricing.
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
        - name: overrideId
          in: path
          required: true
          schema:
            type: integer
          description: ID of the price override
      responses:
        '204':
          description: Price override deleted (no body)
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: 'Company not found, or the override does not belong to this company'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The override could not be deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/companies/{companyId}/price-groups':
    get:
      operationId: listCompanyPriceGroups
      tags:
        - Companies
        - Pricing
      summary: List company price groups
      description: |
        List a company's pricing structure: which price level applies to each product category
        (or subcategory) for this company. Ordered by ID; not paginated.
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      responses:
        '200':
          description: The company's price-level assignments
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: Assigns the price level a company gets for a product category (optionally narrowed to a subcategory).
                      properties:
                        id:
                          type: integer
                          description: ID of the assignment
                          example: 311
                        company_id:
                          type: integer
                          example: 5567
                        price_group_id:
                          type: integer
                          nullable: true
                          description: 'Price group, when one was set'
                        price_level_id:
                          type: integer
                          example: 4
                        product_category_id:
                          type: integer
                          example: 18
                        product_subcategory_id:
                          type: integer
                          nullable: true
                          description: 'Subcategory the assignment is narrowed to, or null for the whole category'
                        price_level:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              example: Wholesale Tier 2
                        product_category:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              example: Apparel
                        product_subcategory:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              example: T-Shirts
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    post:
      operationId: createCompanyPriceGroup
      tags:
        - Companies
        - Pricing
      summary: Assign company price group
      description: |
        Assign the price level a company gets for a product category, optionally narrowed to one
        subcategory. The subcategory must belong to the category.

        Returns a 422 if the company already has the same assignment, or if the price level,
        category, subcategory, or price group does not exist. Use
        `POST /companies/{companyId}/price-groups/bulk` to assign several at once.
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - price_level_id
                - product_category_id
              properties:
                price_level_id:
                  type: integer
                  description: Price level to apply (see `GET /price-levels`)
                  example: 4
                product_category_id:
                  type: integer
                  description: Product category the price level applies to
                  example: 18
                product_subcategory_id:
                  type: integer
                  nullable: true
                  description: Narrow the assignment to one subcategory of `product_category_id`. Omit or null for the whole category.
                  example: 52
                price_group_id:
                  type: integer
                  nullable: true
                  description: Optional price group to record on the assignment
      responses:
        '201':
          description: Assignment created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: Assigns the price level a company gets for a product category (optionally narrowed to a subcategory).
                    properties:
                      id:
                        type: integer
                        description: ID of the assignment
                        example: 311
                      company_id:
                        type: integer
                        example: 5567
                      price_group_id:
                        type: integer
                        nullable: true
                        description: 'Price group, when one was set'
                      price_level_id:
                        type: integer
                        example: 4
                      product_category_id:
                        type: integer
                        example: 18
                      product_subcategory_id:
                        type: integer
                        nullable: true
                        description: 'Subcategory the assignment is narrowed to, or null for the whole category'
                      price_level:
                        type: object
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                            example: Wholesale Tier 2
                      product_category:
                        type: object
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                            example: Apparel
                      product_subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                            example: T-Shirts
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: 'Validation error (unknown price level/category/subcategory/price group, subcategory outside the category, or a duplicate assignment)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/companies/{companyId}/price-groups/bulk':
    post:
      operationId: bulkCreateCompanyPriceGroups
      tags:
        - Companies
        - Pricing
      summary: Bulk assign company price groups
      description: |
        Assign several category/subcategory price levels to a company in one call. The same rules as
        the single assign apply to each entry. The whole call runs in one transaction: if any entry
        fails, nothing is saved, and the error key names the entry (for example
        `groups.1.price_level_id`).
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - groups
              properties:
                groups:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - price_level_id
                      - product_category_id
                    properties:
                      price_level_id:
                        type: integer
                        description: Price level to apply (see `GET /price-levels`)
                        example: 4
                      product_category_id:
                        type: integer
                        description: Product category the price level applies to
                        example: 18
                      product_subcategory_id:
                        type: integer
                        nullable: true
                        description: Narrow the assignment to one subcategory of `product_category_id`. Omit or null for the whole category.
                        example: 52
                      price_group_id:
                        type: integer
                        nullable: true
                        description: Optional price group to record on the assignment
      responses:
        '201':
          description: 'The created assignments, in request order'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: Assigns the price level a company gets for a product category (optionally narrowed to a subcategory).
                      properties:
                        id:
                          type: integer
                          description: ID of the assignment
                          example: 311
                        company_id:
                          type: integer
                          example: 5567
                        price_group_id:
                          type: integer
                          nullable: true
                          description: 'Price group, when one was set'
                        price_level_id:
                          type: integer
                          example: 4
                        product_category_id:
                          type: integer
                          example: 18
                        product_subcategory_id:
                          type: integer
                          nullable: true
                          description: 'Subcategory the assignment is narrowed to, or null for the whole category'
                        price_level:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              example: Wholesale Tier 2
                        product_category:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              example: Apparel
                        product_subcategory:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              example: T-Shirts
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error; nothing was saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/companies/{companyId}/price-groups/{assignmentId}':
    delete:
      operationId: deleteCompanyPriceGroup
      tags:
        - Companies
        - Pricing
      summary: Delete company price group
      description: Remove one of a company's price-level assignments.
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the company
        - name: assignmentId
          in: path
          required: true
          schema:
            type: integer
          description: 'ID of the assignment (the `id` from `GET /companies/{companyId}/price-groups`)'
      responses:
        '204':
          description: Assignment deleted (no body)
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: 'Company not found, or the assignment does not belong to this company'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The assignment could not be deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/companies/{companyId}/products':
    get:
      operationId: getCompanyProducts
      tags:
        - Companies
        - Products
      summary: Company Products
      description: |
        Get a paginated list of products associated with a specific company.

        Each product includes a calculated `price` field that reflects the company-specific 
        pricing based on their assigned price levels, price groups, and any applicable 
        discounts or markups for the product's category.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Product name
        - `description`: Product description
        - `sku`: Product SKU (searches both internal SKU and alternate SKUs)
        - `upc`: Product UPC/Barcode
        - `tag`: Product tags
        - `q`: General search matches name OR upc OR sku
        - `category.name`: Filter by category name
        - `sub_category.name`: Filter by sub-category name
        - `supplier.name`: Filter by supplier name

        ### Integer Filters
        - `category.id`: Filter by category ID
        - `sub_category.id`: Filter by sub-category ID
        - `supplier.id`: Filter by supplier ID

        ### Float Filters
        - `retail_price`: Product retail price
        - `wholesale_price`: Product wholesale price

        ### Boolean Filters
        - `sellable`: If the product is sellable or not
        - `discontinued`: If the product is discontinued

        ### DateTime Filters
        - `created_at`: When the product was created
        - `updated_at`: When the product was last updated

        ## Examples
        ```
        # Find products by SKU (includes alternate SKUs)
        ?sku[eq]=SKU-001

        # Find products with specific retail price range
        ?retail_price[gte]=50.00&retail_price[lte]=100.00

        # Find recently updated products
        ?updated_at[gte]=2024-01-01 00:00:00

        # Search products by name
        ?name[contains]=Test Product

        # Find products by category and sub-category
        ?category.name[eq]=Electronics&sub_category.name[eq]=Smartphones

        # Find products by supplier
        ?supplier.name[contains]=Acme
        ```
      security:
        - BearerAuth: []
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the company
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: include
          schema:
            type: string
          example: created_via
          description: |
            Comma-separated list of optional fields to include on each product. Pass
            `created_via` to include the product's creation source (omitted from list
            responses by default; always present on single-product responses).
        - in: query
          name: q
          schema:
            type: string
          description: Filter by name OR upc OR sku
        - in: query
          name: name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: description
          schema:
            type: string
          description: Filter by product description
        - in: query
          name: sku
          schema:
            type: string
          description: Filter by SKU (searches both internal and alternate SKUs)
        - in: query
          name: upc
          schema:
            type: string
          description: Filter by UPC/Barcode
        - in: query
          name: sellable
          schema:
            type: boolean
          description: Filter by sellable status
        - in: query
          name: discontinued
          schema:
            type: boolean
          description: Filter by whether the product is discontinued
        - in: query
          name: retail_price
          schema:
            type: number
            format: float
          description: Filter by retail price
        - in: query
          name: wholesale_price
          schema:
            type: number
            format: float
          description: Filter by wholesale price
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by product tags
        - in: query
          name: category.id
          schema:
            type: integer
          description: Filter by category ID
        - in: query
          name: category.name
          schema:
            type: string
          description: Filter by category name
        - in: query
          name: sub_category.id
          schema:
            type: integer
          description: Filter by sub-category ID
        - in: query
          name: sub_category.name
          schema:
            type: string
          description: Filter by sub-category name
        - in: query
          name: supplier.id
          schema:
            type: integer
          description: Filter by supplier ID
        - in: query
          name: supplier.name
          schema:
            type: string
          description: Filter by supplier name
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the product
                        name:
                          type: string
                          description: Product name
                        description:
                          type: string
                          nullable: true
                          description: Product description
                        retail_price:
                          type: number
                          format: float
                          description: Retail price
                        wholesale_price:
                          type: number
                          format: float
                          description: Wholesale price
                        unit_cost:
                          type: number
                          format: float
                          description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                        purchase_unit_cost:
                          type: number
                          format: float
                          nullable: true
                          description: |
                            Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                        purchase_currency:
                          type: string
                          nullable: true
                          description: |
                            ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                        landed_cost:
                          type: number
                          format: float
                          nullable: true
                          description: Landed cost per unit
                        estimated_landed_cost:
                          type: number
                          format: float
                          nullable: true
                          description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                        design_link:
                          type: string
                          nullable: true
                          description: Product design URL or link. `null` when unset or empty.
                        manufacturing_fee:
                          type: number
                          format: float
                          nullable: true
                          description: Manufacturing fee per unit
                        company_prices:
                          type: array
                          description: |
                            Array of company-specific pricing for this product. Each object contains pricing 
                            calculated based on the company's price level, price group assignments, and any 
                            applicable discounts or markups based on product category.
                          items:
                            type: object
                            description: Company-specific pricing information
                            properties:
                              company_id:
                                type: integer
                                description: The unique identifier of the company
                                example: 1
                              company_name:
                                type: string
                                description: The name of the company
                                example: Electronics Retailer Pro
                              price:
                                type: number
                                format: float
                                description: |
                                  The calculated price for this company based on their price level, price group assignments,
                                  and any applicable discounts or markups based on product category.
                                example: 91.99
                        product_weight:
                          type: number
                          format: float
                          description: Weight of the product
                        product_length:
                          type: number
                          format: float
                          description: Length of the product (in inches)
                        product_width:
                          type: number
                          format: float
                          description: Width of the product (in inches)
                        product_height:
                          type: number
                          format: float
                          description: Height of the product (in inches)
                        qty_low_alert:
                          type: integer
                          description: Low stock alert threshold
                        qty_reorder_threshold:
                          type: integer
                          description: Reorder threshold quantity
                        qty_minimum:
                          type: integer
                          description: Minimum stock quantity
                        sellable:
                          type: boolean
                          description: Whether the product can be sold
                        discontinued:
                          type: boolean
                          description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                        image_url:
                          type: string
                          nullable: true
                          description: URL to the product's main image
                        category:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                          description: Product category information
                        subcategory:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                          description: Product subcategory information
                        custom_fields:
                          type: object
                          description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties:
                            type: string
                        attachments:
                          type: array
                          description: Product attachments
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the attachment
                              name:
                                type: string
                                description: Filename of the attachment
                              type:
                                type: string
                                description: MIME type of the attachment
                              size:
                                type: integer
                                description: File size in bytes
                              full_url:
                                type: string
                                description: Full resolution URL of the attachment
                              thumb_url:
                                type: string
                                description: Thumbnail URL of the attachment (if applicable)
                            required:
                              - id
                              - name
                              - type
                              - size
                              - full_url
                        variants:
                          type: array
                          description: Product variants with company-specific pricing
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              attachments:
                                type: array
                                description: Variant-specific attachments
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the attachment
                                    name:
                                      type: string
                                      description: Filename of the attachment
                                    type:
                                      type: string
                                      description: MIME type of the attachment
                                    size:
                                      type: integer
                                      description: File size in bytes
                                    full_url:
                                      type: string
                                      description: Full resolution URL of the attachment
                                    thumb_url:
                                      type: string
                                      description: Thumbnail URL of the attachment (if applicable)
                                  required:
                                    - id
                                    - name
                                    - type
                                    - size
                                    - full_url
                              retail_price:
                                type: number
                                format: float
                              wholesale_price:
                                type: number
                                format: float
                              company_prices:
                                type: array
                                description: |
                                  Array of company-specific pricing for this variant. Each object contains pricing 
                                  calculated using the same pricing logic as the main product but applied to the variant.
                                items:
                                  type: object
                                  description: Company-specific pricing information
                                  properties:
                                    company_id:
                                      type: integer
                                      description: The unique identifier of the company
                                      example: 1
                                    company_name:
                                      type: string
                                      description: The name of the company
                                      example: Electronics Retailer Pro
                                    price:
                                      type: number
                                      format: float
                                      description: |
                                        The calculated price for this company based on their price level, price group assignments,
                                        and any applicable discounts or markups based on product category.
                                      example: 91.99
                              custom_fields:
                                type: array
                                items:
                                  type: object
                              variant_attributes:
                                type: object
                                additionalProperties:
                                  type: string
                              sku:
                                type: string
                              upc:
                                type: string
                              sellable:
                                type: boolean
                                description: Whether the variant can be sold
                              discontinued:
                                type: boolean
                                description: Whether the variant is discontinued
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        variant_attributes:
                          type: object
                          nullable: true
                          description: Available variant attributes
                        sku:
                          type: string
                          description: Internal SKU
                        alternate_skus:
                          type: array
                          description: Alternate SKUs
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              sku:
                                type: string
                        upc:
                          type: string
                          description: UPC/Barcode
                        tags:
                          type: array
                          description: Tags associated with the product
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the tag
                              name:
                                type: string
                                description: Name of the tag
                              description:
                                type: string
                                nullable: true
                                description: Description of the tag
                              icon:
                                type: string
                                nullable: true
                                description: Icon identifier or URL for the tag
                              color:
                                type: string
                                nullable: true
                                description: Color code for the tag
                            required:
                              - id
                              - name
                        substitutions:
                          type: array
                          description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Substitution record ID
                              priority:
                                type: integer
                                description: Substitution priority (lower number = higher priority)
                              product:
                                type: object
                                description: The substitute product
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the product
                                  name:
                                    type: string
                                    description: Product name
                                  description:
                                    type: string
                                    nullable: true
                                    description: Product description
                                  retail_price:
                                    type: number
                                    format: float
                                    description: Retail price
                                  wholesale_price:
                                    type: number
                                    format: float
                                    description: Wholesale price
                                  unit_cost:
                                    type: number
                                    format: float
                                    description: Cost per unit
                                  product_weight:
                                    type: number
                                    format: float
                                    description: Weight of the product
                                  product_length:
                                    type: number
                                    format: float
                                    description: Length of the product (in inches)
                                  product_width:
                                    type: number
                                    format: float
                                    description: Width of the product (in inches)
                                  product_height:
                                    type: number
                                    format: float
                                    description: Height of the product (in inches)
                                  sellable:
                                    type: boolean
                                    description: Whether the product can be sold
                                  discontinued:
                                    type: boolean
                                    description: Whether the product is discontinued
                                  image_url:
                                    type: string
                                    nullable: true
                                    description: URL to the product's main image
                                  sku:
                                    type: string
                                    description: Internal SKU
                                  upc:
                                    type: string
                                    description: UPC/Barcode
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was last updated
                        supplier:
                          type: object
                          nullable: true
                          description: Supplier information
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the product was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the product was last updated
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/companies/{companyId}/invoices':
    get:
      operationId: getCompanyInvoices
      tags:
        - Companies
      summary: List invoices for a company
      description: List invoices (client purchase orders) for the given company. Supports the same filtering as `GET /invoices` (the company is fixed by the path) plus field projection via the `fields` query parameter.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: companyId
          required: true
          schema:
            type: integer
          description: The unique identifier of the company.
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination.
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100).
        - in: query
          name: fields
          schema:
            type: string
          description: 'Comma-separated list of fields to include in each returned invoice (field projection). When omitted, the full invoice object is returned. Example: `fields=id,status,total`.'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the invoice
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the invoice was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the invoice was last updated
                        status:
                          type: string
                          description: Current status of the invoice
                        payment_status:
                          type: string
                          description: Payment status of the invoice
                        order_date:
                          type: string
                          format: date-time
                          description: Date when the invoice was created
                        ship_by_date:
                          type: string
                          format: date-time
                          description: Required ship by date
                        approval_status:
                          type: string
                          description: Approval status of the invoice
                        customer_po_number:
                          type: string
                          description: Customer PO number
                        payment_terms:
                          type: string
                          nullable: true
                          description: Payment terms for the invoice
                        public_note:
                          type: string
                          nullable: true
                          description: Public note visible to customer
                        private_note:
                          type: string
                          nullable: true
                          description: Private internal note
                        total_qty:
                          type: number
                          format: float
                          description: Total quantity of items
                        total_shipping:
                          type: number
                          format: float
                          description: 'Shipping charge on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total_discount:
                          type: number
                          format: float
                          description: 'Discount amount on the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total:
                          type: number
                          format: float
                          description: 'Net total invoice amount, rounded to 2 decimal places (cents, HALF_UP).'
                        total_paid:
                          type: number
                          format: float
                          description: 'Amount paid against the invoice, rounded to 2 decimal places (cents, HALF_UP).'
                        total_due:
                          type: number
                          format: float
                          description: 'Outstanding amount due (total minus total_paid), rounded to 2 decimal places (cents, HALF_UP).'
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: Associated warehouse ID
                        ship_to:
                          type: object
                          properties:
                            address_1:
                              type: string
                              nullable: true
                            address_2:
                              type: string
                              nullable: true
                            city:
                              type: string
                              nullable: true
                            state:
                              type: string
                              nullable: true
                            zip:
                              type: string
                              nullable: true
                            country:
                              type: string
                              nullable: true
                          description: Shipping address details
                        quickbooks_invoice_id:
                          type: string
                          nullable: true
                          description: QuickBooks invoice ID
                        quickbooks_message:
                          type: string
                          description: Message from QuickBooks integration
                        customer:
                          description: Customer information
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the customer
                            name:
                              type: string
                              description: Business name
                            address_1:
                              type: string
                              nullable: true
                              description: Primary address
                            address_2:
                              type: string
                              nullable: true
                              description: Secondary address
                            city:
                              type: string
                              nullable: true
                              description: City
                            state:
                              type: string
                              nullable: true
                              description: State/Province
                            zip:
                              type: string
                              nullable: true
                              description: Postal code
                            country:
                              type: string
                              nullable: true
                              description: Country
                            phone:
                              type: string
                              nullable: true
                              description: Phone number
                            email:
                              type: string
                              nullable: true
                              description: Email address
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when customer was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when customer was last updated
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the line item
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was last updated
                              sku:
                                type: string
                                description: Product SKU
                              name:
                                type: string
                                description: Product name
                              product_id:
                                type: integer
                                description: Product identifier
                              qty:
                                type: number
                                format: float
                                description: Quantity ordered
                              unit_price:
                                type: number
                                format: float
                                description: Price per unit
                              discount:
                                type: number
                                format: float
                                nullable: true
                                description: Discount amount
                              total:
                                type: number
                                format: float
                                description: Total line item amount
                              taxable:
                                type: boolean
                                description: Whether the line item is subject to sales tax. Defaults to true when not set.
                          description: Line items in the invoice
                        payments:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the payment
                              invoice_id:
                                type: integer
                                description: Associated invoice ID
                              gateway:
                                type: string
                                description: Payment gateway used
                              type:
                                type: string
                                description: Payment type
                              charge_type:
                                type: string
                                description: Type of charge
                              amount:
                                type: number
                                format: float
                                description: Payment amount
                              date:
                                type: string
                                format: date-time
                                description: Payment date
                              status:
                                type: string
                                description: Payment status
                              external_id:
                                type: string
                                nullable: true
                                description: External payment identifier
                              notes:
                                type: string
                                nullable: true
                                description: Payment notes
                              reference_id:
                                type: string
                                nullable: true
                                description: Reference identifier
                              gateway_response:
                                type: object
                                properties:
                                  status:
                                    type: string
                                    description: Gateway response status
                                  code:
                                    type: string
                                    description: Response code
                                  message:
                                    type: string
                                    description: Response message
                                  metadata:
                                    type: string
                                    description: Additional metadata
                                description: Payment gateway response details
                              created_by:
                                type: integer
                                nullable: true
                                description: User who created the payment
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when payment was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when payment was last updated
                              deleted_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: Soft delete timestamp
                          description: Payment records for the invoice
                        sales_order:
                          type: object
                          nullable: true
                          description: Sales order associated with the invoice (if any)
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the sales order
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the order was last updated
                            status:
                              type: string
                              description: Current status of the order
                            order_id:
                              type: string
                              description: External order identifier
                            order_number:
                              type: string
                              description: Order number
                            order_date:
                              type: string
                              format: date
                              description: Date when the order was placed
                            payment_date:
                              type: string
                              format: date
                              description: Date when payment was received
                            ship_by_date:
                              type: string
                              format: date
                              description: Required ship by date
                            age:
                              type: integer
                              description: Age of the order in days
                            order_status:
                              type: string
                              description: Status of the order
                            customer_id:
                              type: string
                              description: Customer identifier
                            customer_username:
                              type: string
                              description: Customer's username
                            customer_email:
                              type: string
                              description: Customer's email address
                            bill_to:
                              type: object
                              description: Billing information
                            ship_to:
                              type: object
                              description: Shipping information
                            requested_shipping_service:
                              type: string
                              nullable: true
                              description: What shipping service to use when shipping this order
                            total:
                              type: number
                              format: float
                              description: Total order amount
                            total_paid:
                              type: number
                              format: float
                              description: Amount paid
                            total_tax:
                              type: number
                              format: float
                              description: Total tax amount
                            total_shipping:
                              type: number
                              format: float
                              description: Total shipping amount
                            customer_notes:
                              type: string
                              description: Notes from the customer
                            internal_notes:
                              type: string
                              description: Internal notes
                            ship_date:
                              type: string
                              format: date
                              description: Date when order was shipped
                            hold_until_date:
                              type: string
                              format: date
                              description: Hold until date
                            user_id:
                              type: integer
                              description: User ID associated with the order
                            externally_fulfilled:
                              type: boolean
                              description: Whether the order is fulfilled externally
                            externally_fulfilled_by:
                              type: string
                              description: Entity fulfilling the order externally
                            is_posted:
                              type: boolean
                              description: Whether the order is posted
                            posted_by:
                              type: string
                              description: User who posted the order
                            not_sync:
                              type: boolean
                              description: Sync status
                            sales_posted:
                              type: boolean
                              description: Sales posting status
                            split_order:
                              type: boolean
                              description: Whether the order is split
                            skip_inventory:
                              type: boolean
                              description: Whether to skip inventory
                            skip_sales_report:
                              type: boolean
                              description: Whether to skip sales report
                            channel_id:
                              type: integer
                              description: Channel identifier
                            total_order_cost:
                              type: number
                              format: float
                              description: Total cost of order
                            total_order_quantity:
                              type: number
                              format: float
                              description: Total quantity of items
                            order_cost_details:
                              type: object
                              description: Detailed order cost information
                            source:
                              type: string
                              description: Order source
                            shipstation_order_id:
                              type: string
                              description: ShipStation order identifier
                            type:
                              type: string
                              description: Order type
                            parent_id:
                              type: integer
                              description: Parent order ID if applicable
                            shipping_revenue:
                              type: number
                              format: float
                              description: Revenue from shipping
                            product_total:
                              type: number
                              format: float
                              description: Total product amount
                            total_discount:
                              type: number
                              format: float
                              description: Total discount amount
                            picking_status:
                              type: string
                              description: Status of picking process
                            starred_description:
                              type: string
                              description: Description for starred orders
                            customer_po_number:
                              type: string
                              description: Customer PO number
                        custom_fields:
                          type: object
                          description: 'Custom fields for the invoice. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          example:
                            Field Name 1: Some Value
                        tags:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the tag
                              name:
                                type: string
                                description: Name of the tag
                              description:
                                type: string
                                nullable: true
                                description: Description of the tag
                              icon:
                                type: string
                                nullable: true
                                description: Icon identifier or URL for the tag
                              color:
                                type: string
                                nullable: true
                                description: Color code for the tag
                            required:
                              - id
                              - name
                          description: Tags associated with the invoice
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  '/companies/{companyId}/sales-orders':
    get:
      operationId: getCompanySalesOrders
      tags:
        - Companies
      summary: List sales orders for a company
      description: List sales orders for the given company. Supports the same filtering as `GET /sales-orders` (the company is fixed by the path) plus field projection via the `fields` query parameter.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: companyId
          required: true
          schema:
            type: integer
          description: The unique identifier of the company.
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination.
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100).
        - in: query
          name: fields
          schema:
            type: string
          description: 'Comma-separated list of fields to include in each returned sales order (field projection). When omitted, the full sales order object is returned. Example: `fields=id,order_number,status`.'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the sales order
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the order was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the order was last updated
                        status:
                          type: string
                          description: Current status of the order
                        order_id:
                          type: string
                          description: External order identifier
                        order_number:
                          type: string
                          description: Order number
                        order_date:
                          type: string
                          format: date
                          description: Date when the order was placed
                        payment_date:
                          type: string
                          format: date
                          description: Date when payment was received
                        ship_by_date:
                          type: string
                          format: date
                          description: Required ship by date
                        age:
                          type: integer
                          description: Age of the order in days
                        order_status:
                          type: string
                          description: Status of the order
                        customer_id:
                          type: string
                          description: Customer identifier
                        customer_username:
                          type: string
                          description: Customer's username
                        customer_email:
                          type: string
                          description: Customer's email address
                        bill_to:
                          type: object
                          description: Billing information
                        ship_to:
                          type: object
                          description: Shipping information
                        requested_shipping_service:
                          type: string
                          nullable: true
                          description: What shipping service to use when shipping this order
                        total:
                          type: number
                          format: float
                          description: Total order amount
                        total_paid:
                          type: number
                          format: float
                          description: Amount paid
                        total_tax:
                          type: number
                          format: float
                          description: Total tax amount
                        total_shipping:
                          type: number
                          format: float
                          description: Total shipping amount
                        customer_notes:
                          type: string
                          description: Notes from the customer
                        internal_notes:
                          type: string
                          description: Internal notes
                        ship_date:
                          type: string
                          format: date
                          description: Date when order was shipped
                        hold_until_date:
                          type: string
                          format: date
                          description: Hold until date
                        earliest_ship_date:
                          type: string
                          format: date
                          nullable: true
                          description: Earliest date the order can be shipped
                        user_id:
                          type: integer
                          description: User ID associated with the order
                        externally_fulfilled:
                          type: boolean
                          description: Whether the order is fulfilled externally
                        externally_fulfilled_by:
                          type: string
                          description: Entity fulfilling the order externally
                        is_posted:
                          type: boolean
                          description: Whether the order is posted
                        posted_by:
                          type: string
                          description: User who posted the order
                        not_sync:
                          type: boolean
                          description: Sync status
                        sales_posted:
                          type: boolean
                          description: Sales posting status
                        split_order:
                          type: boolean
                          description: Whether the order is split
                        skip_inventory:
                          type: boolean
                          description: Whether to skip inventory
                        skip_sales_report:
                          type: boolean
                          description: Whether to skip sales report
                        channel_id:
                          type: integer
                          description: Channel identifier
                        total_order_cost:
                          type: number
                          format: float
                          description: Total cost of order
                        total_order_quantity:
                          type: number
                          format: float
                          description: Total quantity of items
                        order_cost_details:
                          type: object
                          description: Detailed order cost information
                        source:
                          type: string
                          description: Order source
                        shipstation_order_id:
                          type: string
                          description: ShipStation order identifier
                        type:
                          type: string
                          description: Order type
                        parent_id:
                          type: integer
                          description: Parent order ID if applicable
                        shipping_revenue:
                          type: number
                          format: float
                          description: Revenue from shipping
                        product_total:
                          type: number
                          format: float
                          description: Total product amount
                        total_discount:
                          type: number
                          format: float
                          description: Total discount amount
                        picking_status:
                          type: string
                          description: Status of picking process
                        starred_description:
                          type: string
                          description: Description for starred orders
                        customer_po_number:
                          type: string
                          description: Customer PO number
                        company_id:
                          type: integer
                          nullable: true
                          description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                          example: 123
                        company:
                          nullable: true
                          description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the company
                              example: 123456
                            created_at:
                              type: string
                              format: date-time
                              description: When the company was created
                              example: '2023-03-15T14:30:00Z'
                            updated_at:
                              type: string
                              format: date-time
                              description: When the company was last updated
                              example: '2023-03-15T14:30:00Z'
                            status:
                              type: string
                              description: Status of the company
                              enum:
                                - active
                                - inactive
                              example: active
                            name:
                              type: string
                              description: Company name
                              example: Acme Corporation
                            type:
                              type: string
                              nullable: true
                              description: Type of business
                              example: Retail
                            phone:
                              type: string
                              nullable: true
                              description: Primary phone number for the company
                              example: 555-123-4567
                            address:
                              type: string
                              nullable: true
                              description: Street address for the company
                              example: 123 Main St
                            address_line_2:
                              type: string
                              nullable: true
                              description: Additional address information
                              example: Suite 500
                            city:
                              type: string
                              nullable: true
                              description: City
                              example: Austin
                            state:
                              type: string
                              nullable: true
                              description: State/province
                              example: TX
                            postal_code:
                              type: string
                              nullable: true
                              description: Postal/ZIP code
                              example: '78701'
                            country:
                              type: string
                              nullable: true
                              description: Country
                              example: USA
                            full_address:
                              type: string
                              nullable: true
                              description: Complete formatted address
                              example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                            shipping_first_name:
                              type: string
                              nullable: true
                              description: First name for shipping contact (legacy field)
                              example: John
                            shipping_last_name:
                              type: string
                              nullable: true
                              description: Last name for shipping contact (legacy field)
                              example: Doe
                            shipping_email:
                              type: string
                              format: email
                              nullable: true
                              description: Email for shipping contact (legacy field)
                              example: shipping@acmecorp.com
                            shipping_phone:
                              type: string
                              nullable: true
                              description: Phone number for shipping contact (legacy field)
                              example: 555-987-6543
                            shipping_address:
                              type: string
                              nullable: true
                              description: Shipping street address (legacy field)
                              example: 456 Warehouse Blvd
                            shipping_city:
                              type: string
                              nullable: true
                              description: Shipping city (legacy field)
                              example: Austin
                            shipping_state:
                              type: string
                              nullable: true
                              description: Shipping state/province (legacy field)
                              example: TX
                            shipping_postal_code:
                              type: string
                              nullable: true
                              description: Shipping postal/ZIP code (legacy field)
                              example: '78745'
                            shipping_country:
                              type: string
                              nullable: true
                              description: Shipping country (legacy field)
                              example: USA
                            shipping_full_address:
                              type: string
                              nullable: true
                              description: Complete formatted shipping address (legacy field)
                              example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                            payment_term:
                              type: string
                              nullable: true
                              description: Payment terms for the company
                              example: Net 30
                            tax_exempt:
                              type: boolean
                              nullable: true
                              description: Whether the company is exempt from taxes
                              example: false
                            tax_rate:
                              type: number
                              format: float
                              nullable: true
                              description: Tax rate applied to the company's orders
                              example: 8.25
                            due_date_days:
                              type: integer
                              nullable: true
                              description: Number of days until payment is due
                              example: 30
                            credit_limit:
                              type: number
                              format: float
                              nullable: true
                              description: Credit limit for the company. `null` means no limit is set.
                              example: 5000
                            header_discount_enabled:
                              type: boolean
                              description: Whether an order-header trade discount is applied by default for this company
                              example: false
                            header_discount_type:
                              type: string
                              nullable: true
                              enum:
                                - PERCENT
                                - FIXED_AMOUNT
                              description: How the header discount is calculated — a percentage of the order or a fixed amount
                              example: PERCENT
                            header_discount_value:
                              type: number
                              format: float
                              nullable: true
                              description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                              example: 5
                            header_discount_effective_from:
                              type: string
                              format: date
                              nullable: true
                              description: Date from which the header discount takes effect (YYYY-MM-DD)
                              example: '2026-01-01'
                            default_currency_code:
                              type: string
                              nullable: true
                              description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                              example: USD
                            price_level:
                              nullable: true
                              description: Price level associated with this company
                              type: object
                              properties:
                                id:
                                  type: number
                                  description: Unique identifier for the price level
                                  example: 123
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the price level was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the price level was last updated
                                  example: '2023-03-15T14:30:00Z'
                                status:
                                  type: string
                                  description: Status of the price level
                                  enum:
                                    - active
                                    - inactive
                                  example: active
                                name:
                                  type: string
                                  description: Name of the price level
                                  example: Wholesale
                                type:
                                  type: string
                                  description: Type of the price level
                                  example: percentage
                                percent_increase:
                                  type: number
                                  format: float
                                  description: Percentage increase (or decrease) for this price level
                                  example: 15.5
                            notes:
                              type: string
                              nullable: true
                              description: Additional notes about the company
                              example: 'Key account, requires special handling'
                            fein:
                              type: string
                              nullable: true
                              description: Federal Employer Identification Number
                              example: 12-3456789
                            tags:
                              type: array
                              nullable: true
                              description: List of tags associated with the company
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the tag
                                  name:
                                    type: string
                                    description: Name of the tag
                                  description:
                                    type: string
                                    nullable: true
                                    description: Description of the tag
                                  icon:
                                    type: string
                                    nullable: true
                                    description: Icon identifier or URL for the tag
                                  color:
                                    type: string
                                    nullable: true
                                    description: Color code for the tag
                                required:
                                  - id
                                  - name
                            default_shipping:
                              nullable: true
                              description: Default shipping address
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the shipping address
                                  example: 789
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the shipping address was last updated
                                  example: '2023-03-15T14:30:00Z'
                                company_id:
                                  type: integer
                                  description: ID of the company this shipping address belongs to
                                  example: 123456
                                company_name:
                                  type: string
                                  nullable: true
                                  description: Name of the company
                                  example: Acme Corporation
                                address:
                                  type: string
                                  description: Street address
                                  example: 456 Warehouse Blvd
                                address_line_2:
                                  type: string
                                  nullable: true
                                  description: Additional address information
                                  example: Building 2
                                city:
                                  type: string
                                  description: City
                                  example: Austin
                                state:
                                  type: string
                                  description: State/province
                                  example: TX
                                postal_code:
                                  type: string
                                  description: Postal/ZIP code
                                  example: '78745'
                                country:
                                  type: string
                                  description: Country
                                  example: USA
                                full_address:
                                  type: string
                                  description: Complete formatted address
                                  example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                full_name:
                                  type: string
                                  description: Full name of the contact person
                                  example: John Doe
                                first_name:
                                  type: string
                                  nullable: true
                                  description: First name of the contact person
                                  example: John
                                last_name:
                                  type: string
                                  nullable: true
                                  description: Last name of the contact person
                                  example: Doe
                                phone:
                                  type: string
                                  nullable: true
                                  description: Phone number
                                  example: 555-987-6543
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  description: Email address
                                  example: shipping@acmecorp.com
                                is_default:
                                  type: boolean
                                  description: Whether this is the default shipping address
                                  example: true
                              required:
                                - id
                                - company_id
                                - address
                                - city
                                - state
                                - postal_code
                                - country
                            shipping_addresses:
                              type: array
                              nullable: true
                              description: List of shipping addresses for the company
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the shipping address
                                    example: 789
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: When the shipping address was created
                                    example: '2023-03-15T14:30:00Z'
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: When the shipping address was last updated
                                    example: '2023-03-15T14:30:00Z'
                                  company_id:
                                    type: integer
                                    description: ID of the company this shipping address belongs to
                                    example: 123456
                                  company_name:
                                    type: string
                                    nullable: true
                                    description: Name of the company
                                    example: Acme Corporation
                                  address:
                                    type: string
                                    description: Street address
                                    example: 456 Warehouse Blvd
                                  address_line_2:
                                    type: string
                                    nullable: true
                                    description: Additional address information
                                    example: Building 2
                                  city:
                                    type: string
                                    description: City
                                    example: Austin
                                  state:
                                    type: string
                                    description: State/province
                                    example: TX
                                  postal_code:
                                    type: string
                                    description: Postal/ZIP code
                                    example: '78745'
                                  country:
                                    type: string
                                    description: Country
                                    example: USA
                                  full_address:
                                    type: string
                                    description: Complete formatted address
                                    example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                  full_name:
                                    type: string
                                    description: Full name of the contact person
                                    example: John Doe
                                  first_name:
                                    type: string
                                    nullable: true
                                    description: First name of the contact person
                                    example: John
                                  last_name:
                                    type: string
                                    nullable: true
                                    description: Last name of the contact person
                                    example: Doe
                                  phone:
                                    type: string
                                    nullable: true
                                    description: Phone number
                                    example: 555-987-6543
                                  email:
                                    type: string
                                    format: email
                                    nullable: true
                                    description: Email address
                                    example: shipping@acmecorp.com
                                  is_default:
                                    type: boolean
                                    description: Whether this is the default shipping address
                                    example: true
                                required:
                                  - id
                                  - company_id
                                  - address
                                  - city
                                  - state
                                  - postal_code
                                  - country
                            billing_info:
                              type: object
                              nullable: true
                              description: Billing information
                              properties:
                                id:
                                  type: integer
                                  example: 456
                                created_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                first_name:
                                  type: string
                                  nullable: true
                                  example: Jane
                                last_name:
                                  type: string
                                  nullable: true
                                  example: Smith
                                email:
                                  type: string
                                  format: email
                                  nullable: true
                                  example: accounting@acmecorp.com
                                receiving_bank_name:
                                  type: string
                                  nullable: true
                                  example: First National Bank
                                receiving_bank_address:
                                  type: string
                                  nullable: true
                                  example: '789 Finance Street, Austin, TX 78701'
                            client_type:
                              type: object
                              nullable: true
                              description: Type of client
                              properties:
                                id:
                                  type: integer
                                  example: 123
                                created_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  example: '2023-03-15T14:30:00Z'
                                name:
                                  type: string
                                  example: Retail
                                description:
                                  type: string
                                  nullable: true
                                  example: Retail business client
                            parent_company_id:
                              type: integer
                              nullable: true
                              description: ID of the parent company
                              example: 456
                            invoice_export_template_id:
                              type: integer
                              nullable: true
                              description: ID of the invoice export template
                              example: 789
                            custom_fields:
                              type: object
                              description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              example:
                                Industry: Manufacturing
                                Region: Southwest
                                Annual Revenue: $5M-$10M
                            assigned_sales_reps:
                              type: array
                              description: |
                                Sales rep users assigned to this company (Go Team members). Resolved from the company's
                                `goTeamMember.user` relation. Only present when the relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: User ID of the assigned sales rep
                                    example: 42
                                  email:
                                    type: string
                                    description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                    example: rep@example.com
                                  first_name:
                                    type: string
                                    nullable: true
                                    example: Jane
                                  last_name:
                                    type: string
                                    nullable: true
                                    example: Doe
                            sales_channel:
                              allOf:
                                - type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Sales channel ID.
                                    status:
                                      type: string
                                      description: Sales channel status (e.g. active).
                                    label:
                                      type: string
                                      nullable: true
                                      description: Human-readable channel label.
                                    channel_type:
                                      type: string
                                      nullable: true
                                      description: Channel type (e.g. the integration/platform the channel represents).
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                              nullable: true
                              description: The company's default sales channel. Only present when the relation is loaded.
                          required:
                            - id
                            - name
                            - status
                        custom_fields:
                          type: object
                          description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties:
                            type: string
                        items:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the order item
                              line_number:
                                type: integer
                                description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                              created_at:
                                type: string
                                format: date-time
                                description: Creation timestamp
                              updated_at:
                                type: string
                                format: date-time
                                description: Last update timestamp
                              sku:
                                type: string
                                description: Stock keeping unit
                              name:
                                type: string
                                description: Product name
                              image_url:
                                type: string
                                description: URL of product image
                              weight:
                                type: object
                                description: Weight information
                              quantity:
                                type: number
                                format: float
                                description: Ordered quantity
                              unit_price:
                                type: number
                                format: float
                                description: Price per unit
                              tax:
                                type: number
                                format: float
                                description: Tax amount
                              shipping:
                                type: number
                                format: float
                                description: Shipping amount
                              warehouse_location:
                                type: string
                                description: Location in warehouse
                              options:
                                type: object
                                description: Additional options
                              fulfillment_sku:
                                type: string
                                description: SKU used for fulfillment
                              adjustment:
                                type: number
                                format: float
                                description: Price adjustment
                              upc:
                                type: string
                                description: Universal Product Code
                              stock_id:
                                type: integer
                                description: Stock identifier
                              kit_id:
                                type: integer
                                description: Kit identifier if part of a kit
                              non_physical_item:
                                type: boolean
                                description: Whether item is non-physical
                              ignore_item:
                                type: boolean
                                description: Whether to ignore this item
                              is_locally_added:
                                type: boolean
                                description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                              quantity_shipped:
                                type: number
                                format: float
                                description: Quantity shipped
                              quantity_cancelled:
                                type: number
                                format: float
                                description: Quantity cancelled
                              quantity_invoiced:
                                type: number
                                format: float
                                description: Quantity invoiced
                              quantity_ordered:
                                type: number
                                format: float
                                description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                              base_uom_id:
                                type: integer
                                description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                              ordered_uom_id:
                                type: integer
                                description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                              product_id:
                                type: integer
                                description: Product identifier
                              total_returned_base_quantity:
                                type: number
                                format: float
                                description: Total quantity returned
                              parent_id:
                                type: integer
                                description: Parent item ID
                              status:
                                type: string
                                description: Item status
                              discount:
                                type: number
                                format: float
                                description: Discount amount
                              estimated_ship_date:
                                type: string
                                format: date
                                description: Estimated shipping date
                              custom_fields:
                                type: object
                                description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties:
                                  type: string
                              product:
                                type: object
                                description: Product information
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the product
                                  name:
                                    type: string
                                    description: Product name
                                  description:
                                    type: string
                                    nullable: true
                                    description: Product description
                                  retail_price:
                                    type: number
                                    format: float
                                    description: Retail price
                                  wholesale_price:
                                    type: number
                                    format: float
                                    description: Wholesale price
                                  unit_cost:
                                    type: number
                                    format: float
                                    description: Cost per unit
                                  product_weight:
                                    type: number
                                    format: float
                                    description: Weight of the product
                                  product_length:
                                    type: number
                                    format: float
                                    description: Length of the product (in inches)
                                  product_width:
                                    type: number
                                    format: float
                                    description: Width of the product (in inches)
                                  product_height:
                                    type: number
                                    format: float
                                    description: Height of the product (in inches)
                                  sellable:
                                    type: boolean
                                    description: Whether the product can be sold
                                  discontinued:
                                    type: boolean
                                    description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                  image_url:
                                    type: string
                                    nullable: true
                                    description: URL to the product's main image
                                  category:
                                    type: object
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                    description: Product category information
                                  subcategory:
                                    type: object
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                    description: Product subcategory information
                                  custom_fields:
                                    type: object
                                    description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                    additionalProperties:
                                      type: string
                                  variant_attributes:
                                    type: object
                                    nullable: true
                                    description: Available variant attributes
                                  sku:
                                    type: string
                                    description: Internal SKU
                                  alternate_skus:
                                    type: array
                                    description: Alternate SKUs
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                        sku:
                                          type: string
                                  upc:
                                    type: string
                                    description: UPC/Barcode
                                  tags:
                                    type: array
                                    description: Tags associated with the product
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the tag
                                        name:
                                          type: string
                                          description: Name of the tag
                                        description:
                                          type: string
                                          nullable: true
                                          description: Description of the tag
                                        icon:
                                          type: string
                                          nullable: true
                                          description: Icon identifier or URL for the tag
                                        color:
                                          type: string
                                          nullable: true
                                          description: Color code for the tag
                                      required:
                                        - id
                                        - name
                                  supplier:
                                    type: object
                                    nullable: true
                                    description: Supplier information
                                  type:
                                    type: string
                                    enum:
                                      - PRODUCT
                                      - KIT
                                    description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                  kit_items:
                                    type: array
                                    nullable: true
                                    description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the kit item
                                        product_id:
                                          type: integer
                                          description: ID of the product component
                                        quantity:
                                          type: number
                                          format: float
                                          description: Quantity of this component in the kit
                                        uom_id:
                                          type: integer
                                          description: Unit of measure ID for the quantity
                                        base_uom_quantity:
                                          type: number
                                          format: float
                                          description: Quantity converted to base unit of measure
                                        price:
                                          type: number
                                          format: float
                                          description: Price for this kit item
                                        original_price:
                                          type: number
                                          format: float
                                          description: Original price for this kit item
                                        total:
                                          type: number
                                          format: float
                                          description: Calculated total (quantity * price)
                                        product:
                                          type: object
                                          nullable: true
                                          description: Product information for this kit item (when loaded)
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                            sku:
                                              type: string
                                            description:
                                              type: string
                                              nullable: true
                                            retail_price:
                                              type: number
                                              format: float
                                            wholesale_price:
                                              type: number
                                              format: float
                                        unit_of_measure:
                                          type: object
                                          nullable: true
                                          description: Unit of measure information (when loaded)
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                            description:
                                              type: string
                                              nullable: true
                                            base_unit:
                                              type: boolean
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the product was last updated
                              tags:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    description:
                                      type: string
                                    icon:
                                      type: string
                                    color:
                                      type: string
                                    discount_structure:
                                      type: object
                                    markup_structure:
                                      type: object
                                description: Tags associated with the sales order item
                          description: Line items in the order
                        fulfillment_orders:
                          type: array
                          description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Fulfillment order ID
                              order_number:
                                type: string
                                description: Fulfillment order number
                              order_key:
                                type: string
                                nullable: true
                                description: Fulfillment order key
                              order_status:
                                type: string
                                description: Fulfillment order status
                              sales_order_id:
                                type: integer
                                description: Associated sales order ID
                              warehouse_group_id:
                                type: integer
                                nullable: true
                                description: Warehouse group ID
                              destination_oms_id:
                                type: integer
                                nullable: true
                                description: Destination app integration account ID
                              destination_oms_store_id:
                                type: integer
                                nullable: true
                              fulfillment_channel_id:
                                type: integer
                                nullable: true
                              pushed_at:
                                type: string
                                format: date-time
                                nullable: true
                              packing_slip_printed_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                              error_message:
                                type: string
                                nullable: true
                                description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                              ship_by_date:
                                type: string
                                format: date
                                nullable: true
                                description: Ship by date
                              total:
                                type: number
                                format: float
                                nullable: true
                                description: Order total
                              bill_to:
                                type: object
                                nullable: true
                                description: Billing address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              ship_to:
                                type: object
                                nullable: true
                                description: Shipping address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              invoice_to:
                                type: object
                                nullable: true
                                description: Invoice address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              sales_order:
                                type: object
                                nullable: true
                                description: Nested sales order data
                              picklists:
                                type: array
                                description: Associated picklists
                                items:
                                  type: object
                              fulfillment_order_items:
                                type: array
                                description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      nullable: true
                                      description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                    shipment_id:
                                      type: integer
                                      nullable: true
                                      description: ID of the fulfillment order this line belongs to.
                                    status:
                                      nullable: true
                                      description: Line status.
                                    sales_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                    sku:
                                      type: string
                                      nullable: true
                                    name:
                                      type: string
                                      nullable: true
                                    weight:
                                      nullable: true
                                      description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                    dimensions:
                                      nullable: true
                                      description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                    quantity:
                                      type: number
                                      description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                    unit_price:
                                      type: number
                                      description: Unit price. Always `0` on synthetic component rows.
                                    lot_id:
                                      type: integer
                                      nullable: true
                                    lot_number:
                                      type: string
                                      nullable: true
                                    expiry_date:
                                      type: string
                                      nullable: true
                                      description: Lot expiry date.
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    is_kit_component:
                                      type: boolean
                                      description: True when the row is a component of a kit (stored or synthetic).
                                    parent_fulfillment_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                    kit_sales_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                    is_synthetic:
                                      type: boolean
                                      description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                              total_weight:
                                type: object
                                nullable: true
                                description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                                properties:
                                  total_oz:
                                    type: number
                                    format: float
                                    description: Total weight in ounces
                                  total_lb:
                                    type: number
                                    format: float
                                    description: Total weight in pounds
                                  line_count:
                                    type: integer
                                    description: Number of fulfillment order lines
                                  weighed_line_count:
                                    type: integer
                                    description: Number of lines that had a usable weight and contributed to the total
                                  is_complete:
                                    type: boolean
                                    description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                              tags:
                                type: array
                                description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the tag
                                    name:
                                      type: string
                                      description: Name of the tag
                                    description:
                                      type: string
                                      nullable: true
                                      description: Description of the tag
                                    icon:
                                      type: string
                                      nullable: true
                                      description: Icon identifier or URL for the tag
                                    color:
                                      type: string
                                      nullable: true
                                      description: Color code for the tag
                                  required:
                                    - id
                                    - name
                              purchase_orders:
                                type: array
                                description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    order_status:
                                      type: string
                                      nullable: true
                                      enum:
                                        - active
                                        - deleted
                                        - completed
                              source_reference_identifier:
                                type: string
                                nullable: true
                                description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                              held_for_item_change:
                                type: boolean
                                description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                              created_at:
                                type: string
                                format: date-time
                                description: When the fulfillment order was created
                              updated_at:
                                type: string
                                format: date-time
                                description: When the fulfillment order was last updated
                        tags:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                              icon:
                                type: string
                              color:
                                type: string
                              discount_structure:
                                type: object
                              markup_structure:
                                type: object
                          description: Tags associated with the order
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  /contacts:
    get:
      operationId: getContacts
      tags:
        - Contacts
      summary: Contacts
      description: |
        Get a paginated list of all contacts with optional filtering and sorting.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Sort Fields

        - `id` - Sort by contact ID
        - `created_at` - Sort by creation date (default: `updated_at:desc`)
        - `updated_at` - Sort by last update date (default: `updated_at:desc`)

        Sort format: `field:direction` where direction is `asc` (ascending) or `desc` (descending).

        Examples:
        - `?sort=id:asc` - Sort by ID ascending
        - `?sort=created_at:desc` - Sort by creation date descending
        - `?sort=updated_at:asc` - Sort by update date ascending

        ## Available Filters
        ### String Filters
        - `first_name`: Contact first name
        - `last_name`: Contact last name
        - `email`: Contact email
        - `phone`: Contact phone number
        - `status`: Contact status
        - `company.name`: Company name

        ### DateTime Filters
        - `created_at`: When the contact was created
        - `updated_at`: When the contact was last updated

        ## Examples
        ```
        # Find contacts by email domain
        ?email[like]=@example.com

        # Find contacts by company
        ?company.name[eq]=Acme Corp

        # Find contacts by status
        ?status[eq]=active

        # Find contacts by phone
        ?phone[eq]=555-123-4567

        # Find recently added contacts
        ?created_at[gte]=2024-01-01
        ```
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: sort
          schema:
            type: string
            default: 'updated_at:desc'
          description: |
            Sort results by field and direction. Format: `field:direction`

            Available sort fields:
            - `id` - Contact ID
            - `created_at` - Creation date
            - `updated_at` - Last update date (default)

            Examples:
            - `id:asc` - Sort by ID ascending
            - `created_at:desc` - Sort by creation date descending
            - `updated_at:asc` - Sort by update date ascending
        - in: query
          name: first_name
          schema:
            type: string
          description: Filter by first name
        - in: query
          name: last_name
          schema:
            type: string
          description: Filter by last name
        - in: query
          name: email
          schema:
            type: string
          description: Filter by email address
        - in: query
          name: phone
          schema:
            type: string
          description: Filter by phone number
        - in: query
          name: status
          schema:
            type: string
          description: Filter by contact status
        - in: query
          name: company.name
          schema:
            type: string
          description: Filter by company name
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
      responses:
        '200':
          description: A list of contacts
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Unique identifier for the contact
                          example: '789123'
                        created_at:
                          type: string
                          format: date-time
                          description: When the contact was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the contact was last updated
                          example: '2023-03-15T14:30:00Z'
                        status:
                          type: string
                          description: Current status of the contact
                          example: active
                        first_name:
                          type: string
                          description: Contact's first name
                          example: John
                        last_name:
                          type: string
                          description: Contact's last name
                          example: Smith
                        email:
                          type: string
                          format: email
                          description: Contact's email address
                          example: john.smith@acmecorp.com
                        phone:
                          type: string
                          description: Contact's primary phone number
                          example: 555-987-6543
                        phone_2:
                          type: string
                          description: Contact's secondary phone number
                          example: 555-555-5555
                        full_name:
                          type: string
                          description: Contact's full name
                          example: John Smith
                        company_id:
                          type: string
                          description: ID of the company this contact belongs to
                          example: '123456'
                        company:
                          type: object
                          description: Company information for this contact
                          properties:
                            id:
                              type: string
                              example: '123456'
                            name:
                              type: string
                              example: Acme Corporation
                        is_primary:
                          type: boolean
                          description: Whether this is the primary contact for the company
                          example: true
                        receive_quotation_pdf:
                          type: boolean
                          description: Whether the contact should receive quotation PDFs
                          example: false
                        receive_purchase_order_pdf:
                          type: boolean
                          description: Whether the contact should receive purchase order PDFs
                          example: false
                        receive_purchase_order_invoice_pdf:
                          type: boolean
                          description: Whether the contact should receive purchase order invoice PDFs
                          example: false
                        has_portal_login:
                          type: boolean
                          description: True when the contact has a linked B2B client portal login
                          example: false
                        companies:
                          type: array
                          description: Companies associated with this contact (when loaded)
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                                nullable: true
                              is_primary:
                                type: boolean
                              receive_quotation_pdf:
                                type: boolean
                              receive_purchase_order_pdf:
                                type: boolean
                              receive_purchase_order_invoice_pdf:
                                type: boolean
                        tags:
                          type: array
                          description: Tags associated with the contact
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              icon:
                                type: string
                                nullable: true
                              color:
                                type: string
                                nullable: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
    post:
      operationId: createContact
      tags:
        - Contacts
      summary: Create a contact
      description: |
        Create a new contact. Requires `first_name` and either `company_id` or `company_ids`.

        All other fields are optional and can be provided when creating the contact or updated later.

        ## B2B Portal Login

        Include an optional `password` field (min 8 characters) to provision a B2B client portal login.
        When `password` is provided, `email` is required. The response will include `has_portal_login: true`
        when a portal login is linked.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - first_name
              properties:
                first_name:
                  type: string
                  maxLength: 255
                  description: Contact's first name
                  example: John
                last_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Contact's last name
                  example: Smith
                company_id:
                  type: integer
                  description: ID of the company this contact belongs to (provide either company_id or company_ids)
                  example: 123
                company_ids:
                  type: array
                  description: Multiple company associations (alternative to company_id; do not send both)
                  minItems: 1
                  items:
                    type: integer
                  example:
                    - 123
                    - 456
                email:
                  type: string
                  format: email
                  maxLength: 255
                  nullable: true
                  description: Contact's email address
                  example: john.smith@acmecorp.com
                phone_1:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Contact's primary phone number
                  example: 555-987-6543
                phone_2:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Contact's secondary phone number
                  example: 555-555-5555
                receiving_bank_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Bank name for receiving payments
                receiving_bank_address:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Bank address for receiving payments
                is_primary:
                  type: boolean
                  nullable: true
                  description: Whether this is the primary contact for the company
                  example: false
                receive_quotation_pdf:
                  type: boolean
                  nullable: true
                  description: Whether the contact should receive quotation PDFs
                  example: false
                receive_purchase_order_pdf:
                  type: boolean
                  nullable: true
                  description: Whether the contact should receive purchase order PDFs
                  example: false
                receive_purchase_order_invoice_pdf:
                  type: boolean
                  nullable: true
                  description: Whether the contact should receive purchase order invoice PDFs
                  example: false
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the contact
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - sales
                    - primary
                password:
                  type: string
                  format: password
                  minLength: 8
                  maxLength: 255
                  description: 'Optional. Creates a B2B portal login when `email` is also provided. Required: `email` must be set when `password` is provided.'
      responses:
        '201':
          description: Contact successfully created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Unique identifier for the contact
                        example: '789123'
                      created_at:
                        type: string
                        format: date-time
                        description: When the contact was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the contact was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Current status of the contact
                        example: active
                      first_name:
                        type: string
                        description: Contact's first name
                        example: John
                      last_name:
                        type: string
                        description: Contact's last name
                        example: Smith
                      email:
                        type: string
                        format: email
                        description: Contact's email address
                        example: john.smith@acmecorp.com
                      phone:
                        type: string
                        description: Contact's primary phone number
                        example: 555-987-6543
                      phone_2:
                        type: string
                        description: Contact's secondary phone number
                        example: 555-555-5555
                      full_name:
                        type: string
                        description: Contact's full name
                        example: John Smith
                      company_id:
                        type: string
                        description: ID of the company this contact belongs to
                        example: '123456'
                      company:
                        type: object
                        description: Company information for this contact
                        properties:
                          id:
                            type: string
                            example: '123456'
                          name:
                            type: string
                            example: Acme Corporation
                      is_primary:
                        type: boolean
                        description: Whether this is the primary contact for the company
                        example: true
                      receive_quotation_pdf:
                        type: boolean
                        description: Whether the contact should receive quotation PDFs
                        example: false
                      receive_purchase_order_pdf:
                        type: boolean
                        description: Whether the contact should receive purchase order PDFs
                        example: false
                      receive_purchase_order_invoice_pdf:
                        type: boolean
                        description: Whether the contact should receive purchase order invoice PDFs
                        example: false
                      has_portal_login:
                        type: boolean
                        description: True when the contact has a linked B2B client portal login
                        example: false
                      companies:
                        type: array
                        description: Companies associated with this contact (when loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                            is_primary:
                              type: boolean
                            receive_quotation_pdf:
                              type: boolean
                            receive_purchase_order_pdf:
                              type: boolean
                            receive_purchase_order_invoice_pdf:
                              type: boolean
                      tags:
                        type: array
                        description: Tags associated with the contact
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/contacts/{contactId}':
    get:
      operationId: getContactById
      tags:
        - Contacts
      summary: Single contact
      description: Get detailed information for a specific contact by ID
      security:
        - BearerAuth: []
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the contact
      responses:
        '200':
          description: Contact details
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Unique identifier for the contact
                        example: '789123'
                      created_at:
                        type: string
                        format: date-time
                        description: When the contact was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the contact was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Current status of the contact
                        example: active
                      first_name:
                        type: string
                        description: Contact's first name
                        example: John
                      last_name:
                        type: string
                        description: Contact's last name
                        example: Smith
                      email:
                        type: string
                        format: email
                        description: Contact's email address
                        example: john.smith@acmecorp.com
                      phone:
                        type: string
                        description: Contact's primary phone number
                        example: 555-987-6543
                      phone_2:
                        type: string
                        description: Contact's secondary phone number
                        example: 555-555-5555
                      full_name:
                        type: string
                        description: Contact's full name
                        example: John Smith
                      company_id:
                        type: string
                        description: ID of the company this contact belongs to
                        example: '123456'
                      company:
                        type: object
                        description: Company information for this contact
                        properties:
                          id:
                            type: string
                            example: '123456'
                          name:
                            type: string
                            example: Acme Corporation
                      is_primary:
                        type: boolean
                        description: Whether this is the primary contact for the company
                        example: true
                      receive_quotation_pdf:
                        type: boolean
                        description: Whether the contact should receive quotation PDFs
                        example: false
                      receive_purchase_order_pdf:
                        type: boolean
                        description: Whether the contact should receive purchase order PDFs
                        example: false
                      receive_purchase_order_invoice_pdf:
                        type: boolean
                        description: Whether the contact should receive purchase order invoice PDFs
                        example: false
                      has_portal_login:
                        type: boolean
                        description: True when the contact has a linked B2B client portal login
                        example: false
                      companies:
                        type: array
                        description: Companies associated with this contact (when loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                            is_primary:
                              type: boolean
                            receive_quotation_pdf:
                              type: boolean
                            receive_purchase_order_pdf:
                              type: boolean
                            receive_purchase_order_invoice_pdf:
                              type: boolean
                      tags:
                        type: array
                        description: Tags associated with the contact
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    post:
      operationId: updateContact
      tags:
        - Contacts
      summary: Update a contact
      description: |
        Update an existing contact's information. **All fields are optional**, allowing partial updates.

        ## Update Behavior

        - **No fields are required** - you can update just one field or multiple fields
        - Only fields provided in the request will be updated; all other fields remain unchanged
        - `company_id` is optional - if not provided, the existing company association will be preserved
        - If `company_id` is provided, it must be a valid, non-empty integer that exists in the system
        - Changing the `company_id` will move the contact to the new company

        ## B2B Portal Login

        Include `password` (min 8 characters) to create or update the B2B client portal login.
        The contact must have an `email` set (either existing or provided in the same request).
        Changing `email` without `password` on a contact that already has a portal login will
        update the linked login's email to match (422 if that email is already used by another login).

        ## Examples

        ```
        # Update only email
        POST /contacts/123
        {
          "email": "newemail@example.com"
        }

        # Update multiple fields
        POST /contacts/123
        {
          "first_name": "Updated",
          "last_name": "Name",
          "phone_1": "555-1234"
        }

        # Change company association
        POST /contacts/123
        {
          "company_id": 456
        }

        # Update without changing company (company_id omitted)
        POST /contacts/123
        {
          "email": "updated@example.com",
          "is_primary": true
        }
        ```
      security:
        - BearerAuth: []
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the contact
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                first_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Contact's first name
                  example: John
                last_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Contact's last name
                  example: Smith
                company_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of the company this contact belongs to. 

                    **For updates:**
                    - Optional - if not provided, the existing company association will be preserved
                    - If provided, must be a valid, non-empty integer that exists in the system
                    - Cannot be an empty string or null if included in the request
                    - Changing the `company_id` will move the contact to the new company
                  example: 123
                email:
                  type: string
                  format: email
                  maxLength: 255
                  nullable: true
                  description: Contact's email address
                  example: john.smith@acmecorp.com
                phone_1:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Contact's primary phone number
                  example: 555-987-6543
                phone_2:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Contact's secondary phone number
                  example: 555-555-5555
                receiving_bank_name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Bank name for receiving payments
                receiving_bank_address:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Bank address for receiving payments
                is_primary:
                  type: boolean
                  nullable: true
                  description: Whether this is the primary contact for the company
                  example: false
                receive_quotation_pdf:
                  type: boolean
                  nullable: true
                  description: Whether the contact should receive quotation PDFs
                  example: false
                receive_purchase_order_pdf:
                  type: boolean
                  nullable: true
                  description: Whether the contact should receive purchase order PDFs
                  example: false
                receive_purchase_order_invoice_pdf:
                  type: boolean
                  nullable: true
                  description: Whether the contact should receive purchase order invoice PDFs
                  example: false
                tags:
                  type: array
                  nullable: true
                  description: Tags to associate with the contact
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - sales
                    - primary
                company_ids:
                  type: array
                  description: Multiple company associations (alternative to company_id)
                  minItems: 1
                  items:
                    type: integer
                password:
                  type: string
                  format: password
                  minLength: 8
                  maxLength: 255
                  description: |
                    Optional. Creates or updates the B2B client portal login for this contact.
                    The contact must have an `email` set (either existing or provided in the same request).
                    Changing `email` without `password` on a contact that already has a portal login
                    will update the linked login's email to match.
            examples:
              partial_update_email:
                summary: Update only email
                description: 'Update just the email address, leaving all other fields unchanged'
                value:
                  email: newemail@example.com
              partial_update_name:
                summary: Update name fields
                description: Update first and last name without changing other fields
                value:
                  first_name: Updated
                  last_name: Name
              change_company:
                summary: Change company association
                description: Move contact to a different company
                value:
                  company_id: 456
              multiple_fields:
                summary: Update multiple fields
                description: Update several fields at once
                value:
                  first_name: John
                  last_name: Doe
                  email: john.doe@example.com
                  phone_1: 555-1234
                  is_primary: true
              set_portal_password:
                summary: Set B2B portal password
                description: Create or update the B2B portal login for a contact
                value:
                  password: securePass1
              change_email_with_portal:
                summary: Change email (syncs linked portal login)
                description: Changing email on a contact with an existing portal login updates the login email
                value:
                  email: new.address@example.com
              empty_request:
                summary: Empty request body
                description: Send an empty object - no fields will be updated (request will succeed)
                value: {}
      responses:
        '200':
          description: Contact successfully updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Unique identifier for the contact
                        example: '789123'
                      created_at:
                        type: string
                        format: date-time
                        description: When the contact was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the contact was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Current status of the contact
                        example: active
                      first_name:
                        type: string
                        description: Contact's first name
                        example: John
                      last_name:
                        type: string
                        description: Contact's last name
                        example: Smith
                      email:
                        type: string
                        format: email
                        description: Contact's email address
                        example: john.smith@acmecorp.com
                      phone:
                        type: string
                        description: Contact's primary phone number
                        example: 555-987-6543
                      phone_2:
                        type: string
                        description: Contact's secondary phone number
                        example: 555-555-5555
                      full_name:
                        type: string
                        description: Contact's full name
                        example: John Smith
                      company_id:
                        type: string
                        description: ID of the company this contact belongs to
                        example: '123456'
                      company:
                        type: object
                        description: Company information for this contact
                        properties:
                          id:
                            type: string
                            example: '123456'
                          name:
                            type: string
                            example: Acme Corporation
                      is_primary:
                        type: boolean
                        description: Whether this is the primary contact for the company
                        example: true
                      receive_quotation_pdf:
                        type: boolean
                        description: Whether the contact should receive quotation PDFs
                        example: false
                      receive_purchase_order_pdf:
                        type: boolean
                        description: Whether the contact should receive purchase order PDFs
                        example: false
                      receive_purchase_order_invoice_pdf:
                        type: boolean
                        description: Whether the contact should receive purchase order invoice PDFs
                        example: false
                      has_portal_login:
                        type: boolean
                        description: True when the contact has a linked B2B client portal login
                        example: false
                      companies:
                        type: array
                        description: Companies associated with this contact (when loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                            is_primary:
                              type: boolean
                            receive_quotation_pdf:
                              type: boolean
                            receive_purchase_order_pdf:
                              type: boolean
                            receive_purchase_order_invoice_pdf:
                              type: boolean
                      tags:
                        type: array
                        description: Tags associated with the contact
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
              examples:
                invalid_email:
                  summary: Invalid email format
                  value:
                    message: The given data was invalid.
                    errors:
                      email:
                        - The email must be a valid email address.
                invalid_company_id:
                  summary: Invalid company ID
                  value:
                    message: The given data was invalid.
                    errors:
                      company_id:
                        - The specified company does not exist.
                empty_company_id:
                  summary: Empty company ID
                  value:
                    message: The given data was invalid.
                    errors:
                      company_id:
                        - Company ID cannot be empty if provided.
    delete:
      operationId: deleteContact
      tags:
        - Contacts
      summary: Delete a contact
      description: Delete a contact by ID. This performs a soft delete by setting the contact status to inactive.
      security:
        - BearerAuth: []
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the contact
      responses:
        '204':
          description: Contact successfully deleted
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  '/contacts/{contactId}/b2b-portal-password':
    post:
      operationId: setB2bPortalPassword
      tags:
        - Contacts
      summary: Set or rotate B2B portal password
      description: |
        Sets or rotates the B2B client portal password for a contact. Uses the same backend logic as
        sending `password` on `POST /contacts/{contactId}`, but accepts only the password field.

        The contact must have a non-empty `email` (set via create or a prior update).
        The response includes `has_portal_login: true` when the login is linked.
      security:
        - BearerAuth: []
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: integer
          description: The unique identifier of the contact
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - password
              properties:
                password:
                  type: string
                  format: password
                  minLength: 8
                  maxLength: 255
                  description: Plain-text password (min 8 characters). Transmitted only over HTTPS.
            example:
              password: minimum8chars
      responses:
        '200':
          description: Contact with updated portal login status
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Unique identifier for the contact
                        example: '789123'
                      created_at:
                        type: string
                        format: date-time
                        description: When the contact was created
                        example: '2023-03-15T14:30:00Z'
                      updated_at:
                        type: string
                        format: date-time
                        description: When the contact was last updated
                        example: '2023-03-15T14:30:00Z'
                      status:
                        type: string
                        description: Current status of the contact
                        example: active
                      first_name:
                        type: string
                        description: Contact's first name
                        example: John
                      last_name:
                        type: string
                        description: Contact's last name
                        example: Smith
                      email:
                        type: string
                        format: email
                        description: Contact's email address
                        example: john.smith@acmecorp.com
                      phone:
                        type: string
                        description: Contact's primary phone number
                        example: 555-987-6543
                      phone_2:
                        type: string
                        description: Contact's secondary phone number
                        example: 555-555-5555
                      full_name:
                        type: string
                        description: Contact's full name
                        example: John Smith
                      company_id:
                        type: string
                        description: ID of the company this contact belongs to
                        example: '123456'
                      company:
                        type: object
                        description: Company information for this contact
                        properties:
                          id:
                            type: string
                            example: '123456'
                          name:
                            type: string
                            example: Acme Corporation
                      is_primary:
                        type: boolean
                        description: Whether this is the primary contact for the company
                        example: true
                      receive_quotation_pdf:
                        type: boolean
                        description: Whether the contact should receive quotation PDFs
                        example: false
                      receive_purchase_order_pdf:
                        type: boolean
                        description: Whether the contact should receive purchase order PDFs
                        example: false
                      receive_purchase_order_invoice_pdf:
                        type: boolean
                        description: Whether the contact should receive purchase order invoice PDFs
                        example: false
                      has_portal_login:
                        type: boolean
                        description: True when the contact has a linked B2B client portal login
                        example: false
                      companies:
                        type: array
                        description: Companies associated with this contact (when loaded)
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                            is_primary:
                              type: boolean
                            receive_quotation_pdf:
                              type: boolean
                            receive_purchase_order_pdf:
                              type: boolean
                            receive_purchase_order_invoice_pdf:
                              type: boolean
                      tags:
                        type: array
                        description: Tags associated with the contact
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            icon:
                              type: string
                              nullable: true
                            color:
                              type: string
                              nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Contact not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error (e.g. missing password, shorter than 8 characters) or business rule
            failure (no email on contact, duplicate portal email, unable to create/update login).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /price-schedules:
    get:
      operationId: getPriceSchedules
      tags:
        - Pricing
      summary: Price Schedules
      description: |
        Get a paginated list of price schedules with optional filtering.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Schedule name
        - `counting_algorithm`: Type of counting algorithm used
        - `modification_type`: Type of price modification

        ## Examples
        ```
        # Find schedules by name
        ?name[eq]=Bulk Discount

        # Find schedules by counting algorithm
        ?counting_algorithm[eq]=individual

        # Find schedules by modification type
        ?modification_type[eq]=percentage
        ```
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: name
          schema:
            type: string
          description: Filter by schedule name
        - in: query
          name: counting_algorithm
          schema:
            type: string
          description: Filter by counting algorithm
        - in: query
          name: modification_type
          schema:
            type: string
          description: Filter by modification type
      responses:
        '200':
          description: A list of price schedules
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: number
                          description: Unique identifier for the price schedule
                          example: 123
                        name:
                          type: string
                          description: Name of the price schedule
                          example: Holiday Sale 2023
                        description:
                          type: string
                          description: Detailed description of the price schedule
                          example: Special pricing for holiday season
                        status:
                          type: string
                          description: Status of the price schedule
                          enum:
                            - active
                            - inactive
                          example: active
                        start_date:
                          type: string
                          format: date
                          description: When the price schedule becomes active
                          example: '2023-11-01'
                        end_date:
                          type: string
                          format: date
                          description: When the price schedule expires
                          example: '2023-12-31'
                        priority:
                          type: integer
                          description: Priority of this price schedule (higher numbers take precedence)
                          example: 100
                        price_levels:
                          type: array
                          description: List of price levels this schedule applies to
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                                example: '789'
                              name:
                                type: string
                                example: Wholesale
                        companies:
                          type: array
                          description: List of companies this schedule applies to (if specific to companies)
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                                example: '123456'
                              name:
                                type: string
                                example: Acme Corporation
                        created_at:
                          type: string
                          format: date-time
                          description: When the price schedule was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the price schedule was last updated
                          example: '2023-03-15T14:30:00Z'
                        counting_algorithm:
                          type: string
                          description: Algorithm used for counting items for price determination
                          example: each_item
                        modification_type:
                          type: string
                          description: Type of price modification applied
                          example: amount_off
                        global:
                          type: boolean
                          description: Whether this price schedule applies globally
                          example: true
                        tiers:
                          type: array
                          description: List of price schedule tiers
                          items:
                            type: object
                            properties:
                              id:
                                type: number
                                description: Unique identifier for the price schedule tier
                                example: 123
                              created_at:
                                type: string
                                format: date-time
                                description: When the price schedule tier was created
                                example: '2023-03-15T14:30:00Z'
                              updated_at:
                                type: string
                                format: date-time
                                description: When the price schedule tier was last updated
                                example: '2023-03-15T14:30:00Z'
                              status:
                                type: string
                                description: Status of the price schedule tier
                                enum:
                                  - active
                                  - inactive
                                example: active
                              price_schedule_id:
                                type: string
                                description: ID of the parent price schedule
                                example: '456789'
                              quantity:
                                type: number
                                format: float
                                description: Quantity threshold for this pricing tier
                                example: 10
                              discount_amount:
                                type: number
                                format: float
                                description: Amount of discount applied at this tier
                                example: 5.99
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  '/price-schedules/{scheduleId}':
    get:
      operationId: getPriceSchedule
      tags:
        - Pricing
      summary: Price Schedule
      description: Get detailed information for a specific price schedule
      security:
        - BearerAuth: []
      parameters:
        - name: scheduleId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the price schedule
      responses:
        '200':
          description: Price schedule details
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: number
                    description: Unique identifier for the price schedule
                    example: 123
                  name:
                    type: string
                    description: Name of the price schedule
                    example: Holiday Sale 2023
                  description:
                    type: string
                    description: Detailed description of the price schedule
                    example: Special pricing for holiday season
                  status:
                    type: string
                    description: Status of the price schedule
                    enum:
                      - active
                      - inactive
                    example: active
                  start_date:
                    type: string
                    format: date
                    description: When the price schedule becomes active
                    example: '2023-11-01'
                  end_date:
                    type: string
                    format: date
                    description: When the price schedule expires
                    example: '2023-12-31'
                  priority:
                    type: integer
                    description: Priority of this price schedule (higher numbers take precedence)
                    example: 100
                  price_levels:
                    type: array
                    description: List of price levels this schedule applies to
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          example: '789'
                        name:
                          type: string
                          example: Wholesale
                  companies:
                    type: array
                    description: List of companies this schedule applies to (if specific to companies)
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          example: '123456'
                        name:
                          type: string
                          example: Acme Corporation
                  created_at:
                    type: string
                    format: date-time
                    description: When the price schedule was created
                    example: '2023-03-15T14:30:00Z'
                  updated_at:
                    type: string
                    format: date-time
                    description: When the price schedule was last updated
                    example: '2023-03-15T14:30:00Z'
                  counting_algorithm:
                    type: string
                    description: Algorithm used for counting items for price determination
                    example: each_item
                  modification_type:
                    type: string
                    description: Type of price modification applied
                    example: amount_off
                  global:
                    type: boolean
                    description: Whether this price schedule applies globally
                    example: true
                  tiers:
                    type: array
                    description: List of price schedule tiers
                    items:
                      type: object
                      properties:
                        id:
                          type: number
                          description: Unique identifier for the price schedule tier
                          example: 123
                        created_at:
                          type: string
                          format: date-time
                          description: When the price schedule tier was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the price schedule tier was last updated
                          example: '2023-03-15T14:30:00Z'
                        status:
                          type: string
                          description: Status of the price schedule tier
                          enum:
                            - active
                            - inactive
                          example: active
                        price_schedule_id:
                          type: string
                          description: ID of the parent price schedule
                          example: '456789'
                        quantity:
                          type: number
                          format: float
                          description: Quantity threshold for this pricing tier
                          example: 10
                        discount_amount:
                          type: number
                          format: float
                          description: Amount of discount applied at this tier
                          example: 5.99
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  /price-levels:
    get:
      operationId: getPriceLevels
      tags:
        - Pricing
      summary: Price Levels
      description: |
        Get a paginated list of price levels with optional filtering.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### String Filters
        - `name`: Level name
        - `type`: Level type

        ### Float Filters
        - `percent_increase`: Percentage increase for the price level

        ## Examples
        ```
        # Find levels by name
        ?name[eq]=Retail

        # Find levels by type
        ?type[eq]=percentage

        # Find levels with specific percentage increase
        ?percent_increase[gte]=10
        ```
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination (starts at 1)
        - name: limit
          in: query
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - name: sort
          in: query
          schema:
            type: string
            default: 'id:desc'
          description: |
            Sort results by field and direction. Format: `field:direction`

            Examples:
            - `name:asc` - Sort by name in ascending order
            - `created_at:desc` - Sort by creation date in descending order
            - `id:asc` - Sort by ID in ascending order

            Default is `id:desc` 
        - in: query
          name: name
          schema:
            type: string
          description: Filter by level name
        - in: query
          name: type
          schema:
            type: string
          description: Filter by level type
        - in: query
          name: percent_increase
          schema:
            type: number
            format: float
          description: Filter by percentage increase
      responses:
        '200':
          description: A list of price levels
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: number
                          description: Unique identifier for the price level
                          example: 123
                        created_at:
                          type: string
                          format: date-time
                          description: When the price level was created
                          example: '2023-03-15T14:30:00Z'
                        updated_at:
                          type: string
                          format: date-time
                          description: When the price level was last updated
                          example: '2023-03-15T14:30:00Z'
                        status:
                          type: string
                          description: Status of the price level
                          enum:
                            - active
                            - inactive
                          example: active
                        name:
                          type: string
                          description: Name of the price level
                          example: Wholesale
                        type:
                          type: string
                          description: Type of the price level
                          example: percentage
                        percent_increase:
                          type: number
                          format: float
                          description: Percentage increase (or decrease) for this price level
                          example: 15.5
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  '/price-levels/{levelId}':
    get:
      operationId: getPriceLevel
      tags:
        - Pricing
      summary: Price Level
      description: Get detailed information for a specific price level
      security:
        - BearerAuth: []
      parameters:
        - name: levelId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the price level
      responses:
        '200':
          description: Price level details
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: number
                    description: Unique identifier for the price level
                    example: 123
                  created_at:
                    type: string
                    format: date-time
                    description: When the price level was created
                    example: '2023-03-15T14:30:00Z'
                  updated_at:
                    type: string
                    format: date-time
                    description: When the price level was last updated
                    example: '2023-03-15T14:30:00Z'
                  status:
                    type: string
                    description: Status of the price level
                    enum:
                      - active
                      - inactive
                    example: active
                  name:
                    type: string
                    description: Name of the price level
                    example: Wholesale
                  type:
                    type: string
                    description: Type of the price level
                    example: percentage
                  percent_increase:
                    type: number
                    format: float
                    description: Percentage increase (or decrease) for this price level
                    example: 15.5
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  /boms:
    get:
      operationId: getBoms
      tags:
        - BOMs
      summary: BOMs
      description: |
        Get a paginated list of BOMs (Bills of Materials) with optional filtering.

        For detailed information about the filtering system and available operators, 
        refer to the [Filter System Documentation](/filters).

        ## Available Filters
        ### BOM Filters
        #### String Filters
        - `name`: BOM name

        #### DateTime Filters
        - `created_at`: When the BOM was created
        - `updated_at`: When the BOM was last updated

        ### Product Filters
        Filter BOMs by products contained in their items. All product filters are prefixed with `item.product.`

        #### String Filters
        - `item.product.name`: Product name
        - `item.product.description`: Product description
        - `item.product.sku`: Product SKU (searches both internal SKU and alternate SKUs)
        - `item.product.upc`: Product UPC/Barcode
        - `item.product.tag`: Product tags
        - `item.product.q`: General search matches name OR upc OR sku
        - `item.product.category.name`: Filter by category name
        - `item.product.sub_category.name`: Filter by sub-category name
        - `item.product.supplier.name`: Filter by supplier name

        #### Integer Filters
        - `item.product.id`: Filter by product ID
        - `item.product.category.id`: Filter by category ID
        - `item.product.sub_category.id`: Filter by sub-category ID
        - `item.product.supplier.id`: Filter by supplier ID

        #### Float Filters
        - `item.product.retail_price`: Product retail price
        - `item.product.wholesale_price`: Product wholesale price

        #### Boolean Filters
        - `item.product.sellable`: If the product is sellable or not
        - `item.product.discontinued`: If the product is discontinued

        #### DateTime Filters
        - `item.product.created_at`: When the product was created
        - `item.product.updated_at`: When the product was last updated

        ## Examples
        ```
        # Find BOMs by name
        ?name[contains]=Assembly

        # Find recently created BOMs
        ?created_at[gte]=2024-01-01 00:00:00

        # Find BOMs containing a specific product by SKU
        ?item.product.sku[eq]=SKU-001

        # Find BOMs containing products with specific price range
        ?item.product.retail_price[gte]=50.00&item.product.retail_price[lte]=100.00

        # Find BOMs containing products from a specific category
        ?item.product.category.name[eq]=Electronics

        # Find BOMs containing products by supplier
        ?item.product.supplier.name[contains]=Acme

        # Find BOMs containing products with specific tags
        ?item.product.tag[eq]=Assembly
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: name
          schema:
            type: string
          description: Filter by BOM name
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
        - in: query
          name: item.product.id
          schema:
            type: integer
          description: Filter by product ID (returns BOMs containing items with this product)
        - in: query
          name: item.product.sku
          schema:
            type: string
          description: Filter by product SKU (searches both internal and alternate SKUs)
        - in: query
          name: item.product.name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: item.product.category.id
          schema:
            type: integer
          description: Filter by product category ID
        - in: query
          name: item.product.category.name
          schema:
            type: string
          description: Filter by product category name
        - in: query
          name: item.product.supplier.id
          schema:
            type: integer
          description: Filter by product supplier ID
        - in: query
          name: item.product.supplier.name
          schema:
            type: string
          description: Filter by product supplier name
        - in: query
          name: item.product.tag
          schema:
            type: string
          description: Filter by product tags
        - in: query
          name: item.product.retail_price
          schema:
            type: number
            format: float
          description: Filter by product retail price
        - in: query
          name: item.product.wholesale_price
          schema:
            type: number
            format: float
          description: Filter by product wholesale price
        - in: query
          name: item.product.sellable
          schema:
            type: boolean
          description: Filter by product sellable status
        - in: query
          name: item.product.discontinued
          schema:
            type: boolean
          description: Filter by whether the product is discontinued
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the BOM
                        name:
                          type: string
                          description: BOM name
                        items:
                          type: array
                          description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the BOM item
                              bom_id:
                                type: integer
                                description: ID of the BOM this item belongs to
                              product_id:
                                type: integer
                                description: ID of the product/component
                              product:
                                type: object
                                nullable: true
                                description: Product information (when loaded)
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  sku:
                                    type: string
                                  description:
                                    type: string
                                    nullable: true
                              quantity:
                                type: number
                                format: float
                                description: Quantity required for this item
                              base_quantity:
                                type: number
                                format: float
                                description: Base quantity (converted to base unit of measure)
                              note:
                                type: string
                                nullable: true
                                description: Optional note for this item
                              uom_id:
                                type: integer
                                nullable: true
                                description: Unit of measure ID
                              unit_of_measure:
                                type: object
                                nullable: true
                                description: Unit of measure information (when loaded)
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              order:
                                type: integer
                                nullable: true
                                description: Display order for this item
                              consumption_basis:
                                type: string
                                enum:
                                  - planned
                                  - actual
                                description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the item was last updated
                            required:
                              - id
                              - bom_id
                              - product_id
                              - quantity
                        extra_costs:
                          type: array
                          description: Additional costs associated with the BOM
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the extra cost
                              name:
                                type: string
                                description: Name/description of the extra cost
                              quantity:
                                type: number
                                format: float
                                description: Quantity for this cost item
                              unit_price:
                                type: number
                                format: float
                                description: Unit price for this cost item
                              line_total:
                                type: number
                                format: float
                                description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the extra cost was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the extra cost was last updated
                            required:
                              - id
                              - name
                              - quantity
                              - unit_price
                              - line_total
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the BOM was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the BOM was last updated
                      required:
                        - id
                        - name
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createBom
      tags:
        - BOMs
      summary: Create a BOM
      description: |
        Create a new BOM (Bill of Materials) with items and optional extra costs.

        Each item must specify either a `product_id` or `sku`. If a `sku` is provided, 
        the system will locate the product by SKU (including alternate SKUs). If no product 
        is found, an error will be thrown.

        If no `uom_id` is provided for an item, the default unit of measure will be used.

        For extra costs, only `name`, `quantity`, and `unit_price` are required. The 
        `line_total` will be calculated automatically on the backend. Do not provide 
        `line_total` in the request.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - items
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: BOM name (must be unique)
                items:
                  type: array
                  minItems: 1
                  description: BOM items (components/products)
                  items:
                    type: object
                    required:
                      - quantity
                    properties:
                      product_id:
                        type: integer
                        description: ID of the product/component (required if sku not provided)
                      sku:
                        type: string
                        description: SKU of the product/component (required if product_id not provided). Can be internal SKU or alternate SKU.
                      quantity:
                        type: number
                        format: float
                        minimum: 0
                        description: Quantity required for this item. Zero is allowed for optional or refurbishment components (quantities below 0 are rejected with a 422).
                      note:
                        type: string
                        nullable: true
                        description: Optional note for this item
                      uom_id:
                        type: integer
                        nullable: true
                        description: 'Unit of measure ID. If not provided, the default UOM will be used.'
                      order:
                        type: integer
                        nullable: true
                        minimum: 0
                        description: Display order for this item
                      consumption_basis:
                        type: string
                        nullable: true
                        enum:
                          - planned
                          - actual
                        description: How much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned` when omitted.
                    oneOf:
                      - required:
                          - product_id
                      - required:
                          - sku
                extra_costs:
                  type: array
                  nullable: true
                  description: Additional costs associated with the BOM
                  items:
                    type: object
                    required:
                      - name
                      - quantity
                      - unit_price
                    properties:
                      name:
                        type: string
                        maxLength: 255
                        description: Name/description of the extra cost
                      quantity:
                        type: number
                        format: float
                        minimum: 0
                        description: Quantity for this cost item
                      unit_price:
                        type: number
                        format: float
                        minimum: 0
                        description: Unit price for this cost item. The line_total will be calculated automatically on the backend as quantity × unit_price. Do not provide line_total in the request.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the BOM
                      name:
                        type: string
                        description: BOM name
                      items:
                        type: array
                        description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM item
                            bom_id:
                              type: integer
                              description: ID of the BOM this item belongs to
                            product_id:
                              type: integer
                              description: ID of the product/component
                            product:
                              type: object
                              nullable: true
                              description: Product information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            quantity:
                              type: number
                              format: float
                              description: Quantity required for this item
                            base_quantity:
                              type: number
                              format: float
                              description: Base quantity (converted to base unit of measure)
                            note:
                              type: string
                              nullable: true
                              description: Optional note for this item
                            uom_id:
                              type: integer
                              nullable: true
                              description: Unit of measure ID
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            order:
                              type: integer
                              nullable: true
                              description: Display order for this item
                            consumption_basis:
                              type: string
                              enum:
                                - planned
                                - actual
                              description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                          required:
                            - id
                            - bom_id
                            - product_id
                            - quantity
                      extra_costs:
                        type: array
                        description: Additional costs associated with the BOM
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the extra cost
                            name:
                              type: string
                              description: Name/description of the extra cost
                            quantity:
                              type: number
                              format: float
                              description: Quantity for this cost item
                            unit_price:
                              type: number
                              format: float
                              description: Unit price for this cost item
                            line_total:
                              type: number
                              format: float
                              description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the extra cost was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the extra cost was last updated
                          required:
                            - id
                            - name
                            - quantity
                            - unit_price
                            - line_total
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the BOM was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the BOM was last updated
                    required:
                      - id
                      - name
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/boms/{bomId}':
    get:
      operationId: getBomById
      tags:
        - BOMs
      summary: Single BOM
      description: |
        Get detailed information about a specific BOM by its ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: bomId
          required: true
          schema:
            type: integer
          description: BOM ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the BOM
                      name:
                        type: string
                        description: BOM name
                      items:
                        type: array
                        description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM item
                            bom_id:
                              type: integer
                              description: ID of the BOM this item belongs to
                            product_id:
                              type: integer
                              description: ID of the product/component
                            product:
                              type: object
                              nullable: true
                              description: Product information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            quantity:
                              type: number
                              format: float
                              description: Quantity required for this item
                            base_quantity:
                              type: number
                              format: float
                              description: Base quantity (converted to base unit of measure)
                            note:
                              type: string
                              nullable: true
                              description: Optional note for this item
                            uom_id:
                              type: integer
                              nullable: true
                              description: Unit of measure ID
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            order:
                              type: integer
                              nullable: true
                              description: Display order for this item
                            consumption_basis:
                              type: string
                              enum:
                                - planned
                                - actual
                              description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                          required:
                            - id
                            - bom_id
                            - product_id
                            - quantity
                      extra_costs:
                        type: array
                        description: Additional costs associated with the BOM
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the extra cost
                            name:
                              type: string
                              description: Name/description of the extra cost
                            quantity:
                              type: number
                              format: float
                              description: Quantity for this cost item
                            unit_price:
                              type: number
                              format: float
                              description: Unit price for this cost item
                            line_total:
                              type: number
                              format: float
                              description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the extra cost was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the extra cost was last updated
                          required:
                            - id
                            - name
                            - quantity
                            - unit_price
                            - line_total
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the BOM was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the BOM was last updated
                    required:
                      - id
                      - name
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: BOM not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: updateBomById
      tags:
        - BOMs
      summary: Update a BOM
      description: |
        Update an existing BOM's information. All fields are optional, allowing partial updates.

        When updating `items` or `extra_costs`, the provided arrays will replace all existing 
        items or extra costs respectively.

        Each item must specify either a `product_id` or `sku`. If a `sku` is provided, 
        the system will locate the product by SKU (including alternate SKUs). If no product 
        is found, an error will be thrown.

        If no `uom_id` is provided for an item, the default unit of measure will be used.

        For extra costs, only `name`, `quantity`, and `unit_price` are required. The 
        `line_total` will be calculated automatically on the backend. Do not provide 
        `line_total` in the request.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: bomId
          required: true
          schema:
            type: integer
          description: BOM ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: BOM name (must be unique)
                items:
                  type: array
                  minItems: 1
                  description: 'BOM items (components/products). When updating, this will replace all existing items.'
                  items:
                    type: object
                    required:
                      - quantity
                    properties:
                      product_id:
                        type: integer
                        description: ID of the product/component (required if sku not provided)
                      sku:
                        type: string
                        description: SKU of the product/component (required if product_id not provided). Can be internal SKU or alternate SKU.
                      quantity:
                        type: number
                        format: float
                        minimum: 0
                        description: Quantity required for this item. Zero is allowed for optional or refurbishment components (quantities below 0 are rejected with a 422).
                      note:
                        type: string
                        nullable: true
                        description: Optional note for this item
                      uom_id:
                        type: integer
                        nullable: true
                        description: 'Unit of measure ID. If not provided, the default UOM will be used.'
                      order:
                        type: integer
                        nullable: true
                        minimum: 0
                        description: Display order for this item
                      consumption_basis:
                        type: string
                        nullable: true
                        enum:
                          - planned
                          - actual
                        description: How much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned` when omitted.
                    oneOf:
                      - required:
                          - product_id
                      - required:
                          - sku
                extra_costs:
                  type: array
                  nullable: true
                  description: 'Additional costs associated with the BOM. When updating, this will replace all existing extra costs.'
                  items:
                    type: object
                    required:
                      - name
                      - quantity
                      - unit_price
                    properties:
                      name:
                        type: string
                        maxLength: 255
                        description: Name/description of the extra cost
                      quantity:
                        type: number
                        format: float
                        minimum: 0
                        description: Quantity for this cost item
                      unit_price:
                        type: number
                        format: float
                        minimum: 0
                        description: Unit price for this cost item. The line_total will be calculated automatically on the backend as quantity × unit_price. Do not provide line_total in the request.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the BOM
                      name:
                        type: string
                        description: BOM name
                      items:
                        type: array
                        description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM item
                            bom_id:
                              type: integer
                              description: ID of the BOM this item belongs to
                            product_id:
                              type: integer
                              description: ID of the product/component
                            product:
                              type: object
                              nullable: true
                              description: Product information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            quantity:
                              type: number
                              format: float
                              description: Quantity required for this item
                            base_quantity:
                              type: number
                              format: float
                              description: Base quantity (converted to base unit of measure)
                            note:
                              type: string
                              nullable: true
                              description: Optional note for this item
                            uom_id:
                              type: integer
                              nullable: true
                              description: Unit of measure ID
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            order:
                              type: integer
                              nullable: true
                              description: Display order for this item
                            consumption_basis:
                              type: string
                              enum:
                                - planned
                                - actual
                              description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the item was last updated
                          required:
                            - id
                            - bom_id
                            - product_id
                            - quantity
                      extra_costs:
                        type: array
                        description: Additional costs associated with the BOM
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the extra cost
                            name:
                              type: string
                              description: Name/description of the extra cost
                            quantity:
                              type: number
                              format: float
                              description: Quantity for this cost item
                            unit_price:
                              type: number
                              format: float
                              description: Unit price for this cost item
                            line_total:
                              type: number
                              format: float
                              description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the extra cost was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the extra cost was last updated
                          required:
                            - id
                            - name
                            - quantity
                            - unit_price
                            - line_total
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the BOM was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the BOM was last updated
                    required:
                      - id
                      - name
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: BOM not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: Conflict - BOM name already exists
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteBom
      tags:
        - BOMs
      summary: Delete BOM
      description: Delete a BOM by ID
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: bomId
          required: true
          schema:
            type: integer
          description: BOM ID
      responses:
        '200':
          description: BOM successfully deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: BOM deleted
        '400':
          description: Error deleting BOM
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: BOM not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /customer-topology:
    get:
      operationId: getCustomerTopology
      tags:
        - Customer Topology
      summary: Customer operational topology snapshot
      description: |
        Returns a read-only snapshot of the tenant's Luminous operational landscape
        (channels, integrations, warehouses, settings, profile, health signals, etc.).
        The snapshot is built from read-only queries and stored centrally.

        When no topology has been built yet, the first request dispatches a background
        build job and returns **202 Accepted** with a `Retry-After` header. Poll until a
        **200** is returned. Only one build per tenant runs at a time; concurrent callers
        receive **202** until the snapshot is stored.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Stored customer topology snapshot
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      tenant_id:
                        type: string
                        description: Identifier of the tenant the snapshot belongs to
                        example: acme
                      topology_data:
                        type: object
                        additionalProperties: true
                        description: |
                          Full topology JSON describing the tenant's operational landscape — channels, integrations, warehouses, settings, profile, health signals, etc. The structure is open-ended and may grow over time.
                      brief_md:
                        type: string
                        nullable: true
                        description: Rendered markdown brief derived from `topology_data`
                        example: |-
                          ## Acme operational overview
                          - 3 active channels
                          - 2 warehouses...
                      built_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When the snapshot was last built
                        example: '2026-06-09T12:00:00Z'
                      degradation_count:
                        type: integer
                        description: Count of topology sections that could not be fully built
                        example: 0
                    required:
                      - tenant_id
                      - topology_data
        '202':
          description: Topology build in progress; retry after `retry_after` seconds
          headers:
            Retry-After:
              description: Suggested delay in seconds before retrying
              schema:
                type: integer
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: processing
                  message:
                    type: string
                    example: Customer topology is being built. Please retry in a few seconds.
                  retry_after:
                    type: integer
                    description: Suggested delay in seconds before retrying
                    example: 5
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /stock-snapshot:
    get:
      operationId: getStockSnapshot
      tags:
        - Stock Snapshot
      summary: 'Stock snapshot (JSON, CSV, or Excel)'
      description: |
        Point-in-time stock snapshot with optional product filters.

        Product filters use the shared bracket-operator syntax, for example
        `sku[in]=SKU-1,SKU-2`, `id[in]=1,2`, `name[contains]=shirt`, or
        `sku_prefix=STYLE-RED-`. These let integrations pull a targeted snapshot
        without paginating an entire warehouse.

        JSON responses are paginated with `page` and `per_page`. When `export=csv`
        or `export=excel` is supplied, pagination is ignored and the filtered
        result set is streamed back as a file download.

        Returns **202 Accepted** with `Retry-After` when snapshot data is still being prepared.
        The 202 body names the build (`build_id`) and says whether it is `queued` or `running`.
        Returns **500** with `status: failed` when that build failed or its worker stopped; a request
        made after `retry_after` seconds starts a new build. A failed build is held for 30 minutes
        (60 minutes when the same date range has already failed within the last day) before a new
        request rebuilds it, so honor `retry_after` rather than polling. A build that waits in the
        queue too long without starting is also reported as failed.

        **Rate limit:** 120 requests per minute per API token. Requests over the limit get **429 Too
        Many Requests** with a `Retry-After` header. Each new date range starts a heavy background
        build, so page through one range and wait for its 202s to clear instead of looping over new
        ranges.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: start_date
          required: true
          schema:
            type: string
            example: '2025-01-01 00:00:00'
          description: 'Start date in Y-m-d H:i:s format'
        - in: query
          name: end_date
          required: true
          schema:
            type: string
            example: '2025-01-31 23:59:59'
          description: 'End date in Y-m-d H:i:s format, must be >= start_date'
        - in: query
          name: warehouse_id
          schema:
            type: integer
          description: |
            Optional warehouse scope. Products with no stock in that warehouse are excluded.
        - in: query
          name: sku
          schema:
            type: string
          description: |
            Filter by product SKU. Supports bracket operators such as `sku[eq]=ABC` and comma-separated `sku[in]=ABC,DEF`.
        - in: query
          name: sku_prefix
          schema:
            type: string
          description: |
            Internal SKU starts-with filter, for example `sku_prefix=STYLE-RED-`. Useful for pulling a style/size family without substring matches.
        - in: query
          name: id
          schema:
            type: integer
          description: |
            Filter by product ID. Supports bracket operators such as `id[in]=1,2,3`.
        - in: query
          name: name
          schema:
            type: string
          description: |
            Filter by product name. Supports bracket operators such as `name[contains]=shirt`.
        - in: query
          name: category.id
          schema:
            type: integer
          description: Filter by product category ID.
        - in: query
          name: sub_category.id
          schema:
            type: integer
          description: Filter by product subcategory ID.
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: page
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination
        - in: query
          name: dateBasis
          schema:
            type: string
            enum:
              - order_date
              - received_date
            default: order_date
          description: |
            Which date the received quantities and values are bucketed by: the purchase order's `order_date` (default) or the receiving report's `received_date`.
        - in: query
          name: export
          schema:
            type: string
            enum:
              - excel
              - csv
          description: 'When set to excel or csv, returns a file download instead of JSON.'
        - in: query
          name: columns
          schema:
            type: string
          description: JSON string of export column configuration (when exporting).
      responses:
        '200':
          description: |
            Paginated snapshot rows (JSON), or a CSV / Excel file download when `export=csv` or `export=excel` is supplied.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
            text/csv:
              schema:
                type: string
                format: binary
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '202':
          description: Snapshot build in progress; retry after the specified number of seconds.
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: processing
                  message:
                    type: string
                  retry_after:
                    type: integer
                    description: Suggested delay in seconds before retrying
                  build_id:
                    type: string
                    format: uuid
                    description: 'The background build this request is waiting on. Requests for the same date range share one build (all warehouses included), so they report the same ID.'
                  build_state:
                    type: string
                    enum:
                      - queued
                      - running
                    description: '`queued`: waiting for a worker to start it (it still runs once a worker is free, so keep polling). `running`: a worker is building it.'
                  queued_at:
                    type: string
                    format: date-time
                    description: 'When the build was queued (UTC, ISO 8601)'
                  started_at:
                    type: string
                    format: date-time
                    nullable: true
                    description: 'When a worker started the build (UTC, ISO 8601). `null` while queued.'
        '400':
          description: Validation or business rule error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '429':
          description: Rate limit exceeded (120 requests per minute per API token). Retry after the number of seconds in the `Retry-After` header.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying.
        '500':
          description: The snapshot build failed or its worker stopped; request again after `retry_after` seconds to start a new build.
          headers:
            Retry-After:
              schema:
                type: integer
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: failed
                  message:
                    type: string
                    example: The stock snapshot build failed. Request the snapshot again after retry_after seconds to start a new build.
                  build_id:
                    type: string
                    format: uuid
                    description: The build that failed. `failed` is final for this ID.
                  failed_at:
                    type: string
                    format: date-time
                    description: 'When the build failed or its worker stopped (UTC, ISO 8601)'
                  retry_after:
                    type: integer
                    description: Seconds until a new request starts a new build (with a new `build_id`)
  /inventory/transactions/consumption:
    get:
      operationId: getConsumption
      tags:
        - Consumption
      summary: Consumption report (paginated)
      description: |
        Aggregated or transactional consumption data. The `group` parameter controls the row shape.

        Supports quantity and other filters via the standard filter system; product-style filters are also applied.

        Each row includes `quantity` along with `total_cost` (COGS for the consumed quantity) and
        `unit_cost` (`total_cost / quantity`, or `0` when quantity is zero), enabling product-level
        COGS pulls directly from consumption.

        **Warehouse attribution.** Sales orders record only a **warehouse group**, so sales and
        kit-component rows are attributed to the order's warehouse group. Assembly, disassembly and
        adjustment rows are attributed to the physical **warehouse** they happened in. Rows grouped by
        warehouse (`day_product_warehouse`, `product_warehouse`) carry `warehouse.type`
        (`warehouse_group` or `warehouse`), so a group and a warehouse that share a numeric ID are
        returned as separate rows. `warehouse.id = 0` means no warehouse or group was recorded.

        **Warehouse-group filter.** Use `warehouse_group.id` (for example `warehouse_group.id[in]=2`)
        to count only consumption for one or more warehouse groups. Sales match on the order's
        warehouse group; assemblies and disassemblies on the assembly order's warehouse group;
        adjustments on the groups their warehouse is assigned to.

        **Warehouse filter.** Use `warehouse_id` (for example `warehouse_id=2` or `warehouse_id[in]=2,5`)
        to count only consumption for one or more physical warehouses. Assembly, disassembly and
        adjustment rows match the warehouse they happened in. Sales and kit rows match when the
        order's warehouse group includes that warehouse. Omitting `warehouse_id` leaves the totals
        unchanged.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: group
          schema:
            type: string
            enum:
              - day_product
              - product
              - day_product_warehouse
              - product_warehouse
              - transaction
            default: day_product
          description: Aggregation level for the data items. `product_warehouse` returns one row per product per warehouse / warehouse group with all dates in the range combined.
        - in: query
          name: 'date[gte]'
          schema:
            type: string
            format: date
            example: '2026-07-01'
          description: Only consumption on or after this transaction date (Y-m-d).
        - in: query
          name: 'date[lte]'
          schema:
            type: string
            format: date
            example: '2026-09-30'
          description: Only consumption on or before this transaction date (Y-m-d).
        - in: query
          name: 'date[eq]'
          schema:
            type: string
            format: date
          description: Only consumption on this transaction date (Y-m-d).
        - in: query
          name: 'warehouse_group.id[eq]'
          schema:
            type: integer
            example: 2
          description: Only consumption attributed to this warehouse group. `warehouse_group.id=2` is equivalent.
        - in: query
          name: 'warehouse_group.id[in]'
          schema:
            type: string
            example: '2,5'
          description: Comma-separated warehouse group IDs; consumption in any of them is counted.
        - in: query
          name: 'warehouse_group.id[notin]'
          schema:
            type: string
            example: '7'
          description: Comma-separated warehouse group IDs to exclude.
        - in: query
          name: warehouse_id
          schema:
            type: integer
            example: 2
          description: 'Only consumption for this physical warehouse. `warehouse_id[eq]=2` is equivalent. Sales and kit rows match when the order''s warehouse group includes the warehouse.'
        - in: query
          name: 'warehouse_id[in]'
          schema:
            type: string
            example: '2,5'
          description: Comma-separated physical warehouse IDs; consumption in any of them is counted.
        - in: query
          name: type
          schema:
            type: string
            example: 'sale,assembly'
          description: 'Comma-separated consumption sources to include (`sale`, `assembly`, `disassembly`, `adjustment`). Defaults to all four.'
        - in: query
          name: include_transfer_orders
          schema:
            type: boolean
            default: true
          description: Set to `0` to exclude sales orders auto-generated from internal transfer orders.
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 1000
          description: Number of items per page (max 1000)
        - in: query
          name: page
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination
      responses:
        '200':
          description: Consumption data with pagination metadata
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                      from:
                        type: integer
                        nullable: true
                      last_page:
                        type: integer
                      per_page:
                        type: integer
                      to:
                        type: integer
                        nullable: true
                      total:
                        type: integer
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /inventory/transactions/consumption/export:
    get:
      operationId: exportConsumption
      tags:
        - Consumption
      summary: Consumption report export
      description: |
        Export consumption report as CSV or Excel file. Same data as
        `GET /inventory/transactions/consumption`, unpaginated. Accepts the same `group`, `date`,
        `warehouse_group.id`, `warehouse_id`, `type` and `include_transfer_orders` parameters with the same meaning
        (see that endpoint for warehouse attribution). Product and channel filters are not applied
        on export.

        Warehouse-grouped files (`day_product_warehouse`, `product_warehouse`) end with a
        `Warehouse Type` column (`warehouse_group` or `warehouse`).
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: format
          schema:
            type: string
            enum:
              - csv
              - xlsx
            default: xlsx
          description: Export file format
        - in: query
          name: group
          schema:
            type: string
            enum:
              - day_product
              - product
              - day_product_warehouse
              - product_warehouse
              - transaction
            default: day_product
          description: Aggregation level for the exported data. `product_warehouse` returns one row per product per warehouse / warehouse group with all dates in the range combined.
        - in: query
          name: 'date[gte]'
          schema:
            type: string
            format: date
            example: '2026-07-01'
          description: Only consumption on or after this transaction date (Y-m-d).
        - in: query
          name: 'date[lte]'
          schema:
            type: string
            format: date
            example: '2026-09-30'
          description: Only consumption on or before this transaction date (Y-m-d).
        - in: query
          name: 'date[eq]'
          schema:
            type: string
            format: date
          description: Only consumption on this transaction date (Y-m-d).
        - in: query
          name: 'warehouse_group.id[eq]'
          schema:
            type: integer
            example: 2
          description: Only consumption attributed to this warehouse group. `warehouse_group.id=2` is equivalent.
        - in: query
          name: 'warehouse_group.id[in]'
          schema:
            type: string
            example: '2,5'
          description: Comma-separated warehouse group IDs; consumption in any of them is counted.
        - in: query
          name: 'warehouse_group.id[notin]'
          schema:
            type: string
            example: '7'
          description: Comma-separated warehouse group IDs to exclude.
        - in: query
          name: warehouse_id
          schema:
            type: integer
            example: 2
          description: 'Only consumption for this physical warehouse. `warehouse_id[eq]=2` is equivalent. Sales and kit rows match when the order''s warehouse group includes the warehouse.'
        - in: query
          name: 'warehouse_id[in]'
          schema:
            type: string
            example: '2,5'
          description: Comma-separated physical warehouse IDs; consumption in any of them is counted.
        - in: query
          name: type
          schema:
            type: string
            example: 'sale,assembly'
          description: 'Comma-separated consumption sources to include (`sale`, `assembly`, `disassembly`, `adjustment`). Defaults to all four.'
        - in: query
          name: include_transfer_orders
          schema:
            type: boolean
            default: true
          description: Set to `0` to exclude sales orders auto-generated from internal transfer orders.
      responses:
        '200':
          description: CSV or Excel file stream
          content:
            text/csv:
              schema:
                type: string
                format: binary
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /inventory/aging:
    get:
      operationId: getInventoryAging
      tags:
        - Inventory Aging
      summary: Inventory aging (paginated)
      description: |
        Cost-layer-based aging buckets per product. Use optional `as_of_date` for historical valuation.

        Additional filters are available on computed fields such as sku, product_name, category, subcategory,
        and bucket quantity/value fields via the standard filter system.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: as_of_date
          schema:
            type: string
            format: date
          description: Valuation date (Y-m-d). Defaults to today.
        - in: query
          name: per_page
          schema:
            type: integer
            default: 50
            maximum: 1000
          description: Number of items per page (max 1000)
        - in: query
          name: page
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination
        - in: query
          name: sort_field
          schema:
            type: string
          description: Field to sort by
        - in: query
          name: sort_direction
          schema:
            type: string
            enum:
              - asc
              - desc
          description: Sort direction
      responses:
        '200':
          description: Paginated inventory aging rows
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /inventory/aging/export:
    get:
      operationId: exportInventoryAging
      tags:
        - Inventory Aging
      summary: Inventory aging export
      description: Export inventory aging report as CSV or Excel file.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: as_of_date
          schema:
            type: string
            format: date
          description: Valuation date (Y-m-d). Defaults to today.
        - in: query
          name: export_format
          schema:
            type: string
            enum:
              - csv
              - xlsx
            default: csv
          description: Export file format
      responses:
        '200':
          description: CSV or XLSX file attachment
          content:
            text/csv:
              schema:
                type: string
                format: binary
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills/reports/aging:
    get:
      operationId: getBillsAging
      tags:
        - Bills Reports
      summary: AP bills aging by vendor
      description: |
        Accounts payable bills aging report grouped by vendor with per-bill breakdown and bucket totals.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: as_of_date
          schema:
            type: string
            format: date
          description: Reference date for overdue calculation. Defaults to today.
        - in: query
          name: vendor_id
          schema:
            type: integer
          description: Filter to a specific vendor
      responses:
        '200':
          description: Vendors with per-bill breakdown and bucket totals
          content:
            application/json:
              schema:
                type: object
                properties:
                  as_of_date:
                    type: string
                    format: date
                  vendors:
                    type: array
                    items:
                      type: object
                      properties:
                        vendor_id:
                          type: integer
                        vendor_name:
                          type: string
                        current:
                          type: number
                        bucket_1_30:
                          type: number
                        bucket_31_60:
                          type: number
                        bucket_61_90:
                          type: number
                        bucket_90_plus:
                          type: number
                        total:
                          type: number
                        bills:
                          type: array
                          items:
                            type: object
                            additionalProperties: true
                  totals:
                    type: object
                    properties:
                      current:
                        type: number
                      bucket_1_30:
                        type: number
                      bucket_31_60:
                        type: number
                      bucket_61_90:
                        type: number
                      bucket_90_plus:
                        type: number
                      total:
                        type: number
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /forecast-data:
    get:
      operationId: getForecastData
      tags:
        - Forecast
      summary: Materialized forecast rows (paginated)
      description: |
        Requires feature **forecast_materialized_table**. Returns **403** if the feature is not enabled.

        Filter and sort fields include id, rfq_id, product_name, internal_sku, type, preferred_supplier_name,
        various numeric metrics, refreshed_at, and more. Uses the standard filter system.

        Each row also includes `product_category` and `sub_category` (nullable strings), sourced from the
        related product. These appear in the response and in the CSV/Excel export.

        Each row also includes `qty_available_via_assembly` (nullable number): the quantity that can be built
        from component stock, read live from the related product (`null` only when the product no longer exists).
        It supports the standard numeric filter operators (e.g. `qty_available_via_assembly[gt]=0`), can be used
        as a sort field, and appears in the export as the **Qty Available Via Assembly** column (after **Qty Pending**).
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: page
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination
      responses:
        '200':
          description: Paginated forecast rows
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /forecast-data/export:
    get:
      operationId: exportForecastData
      tags:
        - Forecast
      summary: Materialized forecast export
      description: |
        Export materialized forecast data as CSV or Excel. Requires feature **forecast_materialized_table**.

        Includes a **Qty Available Via Assembly** column (after **Qty Pending**) with the quantity buildable
        from component stock for each product; blank when the product no longer exists.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: export_format
          schema:
            type: string
            enum:
              - csv
              - xlsx
            default: csv
          description: Export file format
      responses:
        '200':
          description: CSV or XLSX file
          content:
            text/csv:
              schema:
                type: string
                format: binary
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /forecast-data/refresh-status:
    get:
      operationId: getForecastDataRefreshStatus
      tags:
        - Forecast
      summary: Forecast table refresh metadata
      description: |
        Returns the last refresh timestamp, total record count, and staleness indicator.
        Requires feature **forecast_materialized_table**.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Forecast refresh status
          content:
            application/json:
              schema:
                type: object
                properties:
                  refreshed_at:
                    type: string
                    format: date-time
                    nullable: true
                  total_records:
                    type: integer
                  is_stale:
                    type: boolean
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/forecast-data/product/{rfqId}':
    get:
      operationId: getForecastDataByProduct
      tags:
        - Forecast
      summary: Forecast row by product (RFQ) ID
      description: |
        Retrieve a single forecast row by its product RFQ ID.
        Requires feature **forecast_materialized_table**.

        The row includes `qty_available_via_assembly` (nullable number), the quantity buildable from component
        stock, read live from the related product.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: rfqId
          required: true
          schema:
            type: integer
          description: Product RFQ ID
      responses:
        '200':
          description: Forecast row for the product
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/forecast-data/{id}':
    get:
      operationId: getForecastDataById
      tags:
        - Forecast
      summary: Forecast row by materialized row ID
      description: |
        Retrieve a single forecast row by its materialized table row ID.
        Requires feature **forecast_materialized_table**.

        The row includes `qty_available_via_assembly` (nullable number), the quantity buildable from component
        stock, read live from the related product.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Materialized forecast row ID
      responses:
        '200':
          description: Forecast row
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /forecast-warehouse-data:
    get:
      operationId: getForecastWarehouseData
      tags:
        - Forecast
      summary: Materialized forecast by warehouse group (paginated)
      description: |
        Warehouse-level materialized forecast data. Same feature gate as /forecast-data.
        Requires feature **forecast_materialized_table**.

        Each row also includes `product_category` and `sub_category` (nullable strings), sourced from the
        related product. These appear in the response and in the CSV/Excel export.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: page
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination
      responses:
        '200':
          description: Paginated warehouse forecast rows
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /forecast-warehouse-data/export:
    get:
      operationId: exportForecastWarehouseData
      tags:
        - Forecast
      summary: Warehouse forecast export
      description: |
        Export warehouse-level forecast data as CSV or Excel.
        Requires feature **forecast_materialized_table**.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: export_format
          schema:
            type: string
            enum:
              - csv
              - xlsx
            default: csv
          description: Export file format
      responses:
        '200':
          description: CSV or XLSX file
          content:
            text/csv:
              schema:
                type: string
                format: binary
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /forecast-warehouse-data/refresh-status:
    get:
      operationId: getForecastWarehouseDataRefreshStatus
      tags:
        - Forecast
      summary: Warehouse forecast refresh metadata
      description: |
        Returns the last refresh timestamp, total record count, and staleness indicator for warehouse forecast data.
        Requires feature **forecast_materialized_table**.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Warehouse forecast refresh status
          content:
            application/json:
              schema:
                type: object
                properties:
                  refreshed_at:
                    type: string
                    format: date-time
                    nullable: true
                  total_records:
                    type: integer
                  is_stale:
                    type: boolean
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/forecast-warehouse-data/product/{rfqId}':
    get:
      operationId: getForecastWarehouseDataByProduct
      tags:
        - Forecast
      summary: All warehouse-group forecast rows for a product
      description: |
        Retrieve all warehouse-group forecast rows for a given product RFQ ID.
        Requires feature **forecast_materialized_table**.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: rfqId
          required: true
          schema:
            type: integer
          description: Product RFQ ID
      responses:
        '200':
          description: Warehouse forecast rows for the product
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/forecast-warehouse-data/{id}':
    get:
      operationId: getForecastWarehouseDataById
      tags:
        - Forecast
      summary: Warehouse forecast row by ID
      description: |
        Retrieve a single warehouse forecast row by its materialized table row ID.
        Requires feature **forecast_materialized_table**.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Materialized warehouse forecast row ID
      responses:
        '200':
          description: Warehouse forecast row
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Feature not enabled for tenant
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/sales-by-company:
    get:
      operationId: getSalesByCompanyReport
      tags:
        - Reports
      summary: Sales by company report
      description: 'Aggregated sales totals per company over a date range, with a per-item breakdown grouped by SKU or product. Results are paginated by company. The date range is required and is matched against each invoice''s order date.'
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: 'order_date[gte]'
          required: true
          schema:
            type: string
            format: date
          description: 'Start of the order-date range (inclusive, YYYY-MM-DD).'
        - in: query
          name: 'order_date[lte]'
          required: true
          schema:
            type: string
            format: date
          description: 'End of the order-date range (inclusive, YYYY-MM-DD). Must be on or after `order_date[gte]`.'
        - in: query
          name: group_by
          schema:
            type: string
            enum:
              - sku
              - product
            default: sku
          description: How to group the per-company item breakdown. `sku` includes a `sku` field on each item; `product` aggregates by product.
        - in: query
          name: 'company_id[eq]'
          schema:
            type: integer
          description: Restrict the report to a single company.
        - in: query
          name: 'company_id[in]'
          schema:
            type: string
          description: 'Restrict the report to a comma-separated list of company IDs (e.g. `1,2,3`).'
        - in: query
          name: page
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination.
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
          description: Number of companies per page (max 100).
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        company_id:
                          type: integer
                        company_name:
                          type: string
                          nullable: true
                        total_quantity:
                          type: number
                          description: Total quantity sold to the company over the range.
                        total_amount:
                          type: number
                          description: Total net sales amount for the company over the range.
                        items:
                          type: array
                          description: Per-item breakdown for the company.
                          items:
                            type: object
                            properties:
                              product_id:
                                type: integer
                              product_name:
                                type: string
                                nullable: true
                              sku:
                                type: string
                                nullable: true
                                description: Present only when `group_by=sku`.
                              quantity:
                                type: number
                              amount:
                                type: number
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
                  links:
                    type: object
                    properties:
                      first:
                        type: string
                        nullable: true
                      last:
                        type: string
                        nullable: true
                      prev:
                        type: string
                        nullable: true
                      next:
                        type: string
                        nullable: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /reports/close-books/sales-summary:
    get:
      operationId: getCloseBooksSalesSummary
      tags:
        - Reports
      summary: Close the Books — sales summary by channel
      description: |
        Sales summary grouped by channel for the specified date range. Date range must be ≤ 3 months.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: from_date
          required: true
          schema:
            type: string
            format: date
          description: Start of range; span with end_date must be ≤ 3 months.
        - in: query
          name: end_date
          required: true
          schema:
            type: string
            format: date
          description: End of range
      responses:
        '200':
          description: 'Sales summary with channels, totalOrders, totalUnits, totalRevenue, etc.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
        '400':
          description: Validation or business rule error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/close-books/zero-cost-items:
    get:
      operationId: getCloseBookZeroCostItems
      tags:
        - Reports
      summary: Close the Books — zero-cost line items in range
      description: |
        Returns line items with zero cost within the specified date range. Date range must be ≤ 3 months.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: from_date
          required: true
          schema:
            type: string
            format: date
          description: Start of range; span with end_date must be ≤ 3 months.
        - in: query
          name: end_date
          required: true
          schema:
            type: string
            format: date
          description: End of range
      responses:
        '200':
          description: Zero-cost line items
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '400':
          description: Validation or business rule error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/close-books/zero-valuation-inventory:
    get:
      operationId: getCloseBookZeroValuationInventory
      tags:
        - Reports
      summary: Close the Books — zero valuation inventory
      description: Returns inventory items with zero valuation.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Zero valuation inventory items
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/close-books/invoice-sync-errors:
    get:
      operationId: getCloseBookInvoiceSyncErrors
      tags:
        - Reports
      summary: Close the Books — invoice sync errors
      description: |
        Returns invoice sync errors (e.g. QuickBooks) within the specified date range. Date range must be ≤ 3 months.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: from_date
          required: true
          schema:
            type: string
            format: date
          description: Start of range; span with end_date must be ≤ 3 months.
        - in: query
          name: end_date
          required: true
          schema:
            type: string
            format: date
          description: End of range
      responses:
        '200':
          description: Invoice sync error records
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '400':
          description: Validation or business rule error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/inventory-discrepancy:
    get:
      operationId: getInventoryDiscrepancy
      tags:
        - Reports
      summary: Stock / cost-layer discrepancy rows
      description: 'Returns stock and cost-layer discrepancy data, optionally filtered by warehouse.'
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: warehouse_id
          schema:
            type: integer
          description: Filter by warehouse ID
      responses:
        '200':
          description: Discrepancy rows
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/inventory-discrepancy/dashboard:
    get:
      operationId: getInventoryDiscrepancyDashboard
      tags:
        - Reports
      summary: Discrepancy dashboard summary
      description: 'Summary view of stock discrepancies, optionally filtered by warehouse.'
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: warehouse_id
          schema:
            type: integer
          description: Filter by warehouse ID
      responses:
        '200':
          description: Discrepancy dashboard summary
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/transaction-cogs:
    get:
      operationId: getTransactionCogs
      tags:
        - Reports
      summary: 'Transaction COGS (paginated, read-only)'
      description: |
        Transaction-level cost of goods sold data. Supports filtering by date range, product, channel, order number, and cost.

        Set `is_missed_cogs=true` (or `cost_per_unit=0`) to select the missed COGS query path.

        Each row includes `orderType`: the parent order's `type` (for example
        `INTERNAL_TRANSFER_ORDER`), the same values `GET /sales-orders` returns as `type`. It is
        `null` when the source order no longer exists. The nested `shipstationSalesItem` object
        carries the same `orderType` value.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: from_date
          schema:
            type: string
            format: date
          description: Start of date range
        - in: query
          name: to_date
          schema:
            type: string
            format: date
          description: End of date range
        - in: query
          name: product_name
          schema:
            type: string
          description: Filter by product name
        - in: query
          name: sku
          schema:
            type: string
          description: Filter by SKU
        - in: query
          name: channel
          schema:
            type: string
          description: Filter by sales channel
        - in: query
          name: order_number
          schema:
            type: string
          description: Filter by order number
        - in: query
          name: cost_per_unit
          schema:
            type: number
          description: Filter by cost per unit
        - in: query
          name: is_missed_cogs
          schema:
            type: boolean
          description: 'When true, selects the missed COGS query path'
        - in: query
          name: recognition_basis
          schema:
            type: string
            enum:
              - order_date
              - ship_date
              - per_shipment
            default: ship_date
          description: |
            Basis on which transaction COGS is recognized. `order_date` recognizes at the order date,
            `ship_date` at the ship date, and `per_shipment` per individual shipment. When omitted, the
            tenant's saved default is used (falling back to `ship_date`).
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: page
          schema:
            type: integer
            default: 1
            minimum: 1
          description: Page number for pagination
        - in: query
          name: sortField
          schema:
            type: string
          description: Field to sort by
        - in: query
          name: sortDirection
          schema:
            type: string
          description: Sort direction (asc or desc)
      responses:
        '200':
          description: Paginated transaction COGS rows
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                      properties:
                        orderType:
                          type: string
                          nullable: true
                          description: |
                            The parent order's `type` (e.g. `INTERNAL_TRANSFER_ORDER`), matching
                            `type` on `GET /sales-orders`. `null` if the source order is missing.
                            Also present on the nested `shipstationSalesItem`.
                          example: INTERNAL_TRANSFER_ORDER
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /transaction-cogs/update-costs:
    post:
      operationId: updateTransactionCogsCosts
      tags:
        - Reports
      summary: Update per-line COGS from unit cost
      description: |
        Applies `cost_per_unit` to matching sales lines: sets line total cost (quantity × unit cost), updates linked
        sales item cost layers, and rolls up parent order item costs. This is the same behavior as the admin
        Transaction COGS SKU-to-period import.

        Exactly one of three modes is selected via `mode`:

        ### Mode: `sales_item_ids`
        Directly target specific sales item IDs with a given cost per unit.

        ### Mode: `sku_date_range`
        Matches lines with the product SKU whose parent order **ship date** falls within
        `from_date`–`to_date` (inclusive).

        ### Mode: `order_ids`
        Targets specific internal sales order IDs. Optional `sku` limits to that product on those orders.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  title: By Sales Item IDs
                  required:
                    - mode
                    - sales_item_ids
                    - cost_per_unit
                  properties:
                    mode:
                      type: string
                      enum:
                        - sales_item_ids
                      description: Selection mode
                    sales_item_ids:
                      type: array
                      items:
                        type: integer
                      minItems: 1
                      description: Array of sales item IDs to update
                    cost_per_unit:
                      type: number
                      description: Cost per unit to apply
                - type: object
                  title: By SKU + Date Range
                  required:
                    - mode
                    - sku
                    - from_date
                    - to_date
                    - cost_per_unit
                  properties:
                    mode:
                      type: string
                      enum:
                        - sku_date_range
                      description: Selection mode
                    sku:
                      type: string
                      description: Product SKU (internal SKU)
                    from_date:
                      type: string
                      format: date
                      description: Start of ship date range (inclusive)
                    to_date:
                      type: string
                      format: date
                      description: End of ship date range (inclusive)
                    cost_per_unit:
                      type: number
                      description: Cost per unit to apply
                - type: object
                  title: By Order IDs
                  required:
                    - mode
                    - order_ids
                    - cost_per_unit
                  properties:
                    mode:
                      type: string
                      enum:
                        - order_ids
                      description: Selection mode
                    order_ids:
                      type: array
                      items:
                        type: integer
                      minItems: 1
                      description: Internal sales order IDs
                    sku:
                      type: string
                      description: Optional SKU to limit updates to a specific product on these orders
                    cost_per_unit:
                      type: number
                      description: Cost per unit to apply
            examples:
              by_sales_item_ids:
                summary: Update specific sales items
                value:
                  mode: sales_item_ids
                  sales_item_ids:
                    - 101
                    - 102
                    - 103
                  cost_per_unit: 12.5
              by_sku_date_range:
                summary: Update by SKU and date range
                value:
                  mode: sku_date_range
                  sku: WIDGET-001
                  from_date: '2025-01-01'
                  to_date: '2025-03-31'
                  cost_per_unit: 8.75
              by_order_ids:
                summary: Update by order IDs
                value:
                  mode: order_ids
                  order_ids:
                    - 5001
                    - 5002
                  sku: GADGET-XL
                  cost_per_unit: 22
      responses:
        '200':
          description: Number of sales lines updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - updated_count
                properties:
                  updated_count:
                    type: integer
                    minimum: 0
                    description: Number of sales lines that were updated
              example:
                updated_count: 47
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Business rule failure (e.g. SKU not found, no matching lines, invalid date range)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/edi:
    get:
      operationId: getEdiDocuments
      tags:
        - Reports
      summary: EDI documents (paginated)
      description: |
        Paginated list of EDI documents with filtering by type, status, direction, order, date range, and more.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: edi_type
          schema:
            type: string
          description: 'Comma-separated EDI transaction types (e.g. 850,856)'
        - in: query
          name: transaction_status
          schema:
            type: string
          description: Filter by transaction status
        - in: query
          name: direction
          schema:
            type: string
          description: Filter by direction
        - in: query
          name: order_id
          schema:
            type: integer
          description: Filter by order ID
        - in: query
          name: control_number
          schema:
            type: string
          description: Filter by control number
        - in: query
          name: has_received_997
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
          description: Filter by 997 acknowledgement status
        - in: query
          name: date_from
          schema:
            type: string
            format: date-time
          description: Start of date range
        - in: query
          name: date_to
          schema:
            type: string
            format: date-time
          description: End of date range
        - in: query
          name: sort_field
          schema:
            type: string
            default: created_at
          description: Field to sort by
        - in: query
          name: sort_direction
          schema:
            type: string
            default: desc
          description: Sort direction (asc or desc)
        - in: query
          name: per_page
          schema:
            type: integer
            default: 100
            maximum: 100
          description: Page size (max 100)
        - in: query
          name: limit
          schema:
            type: integer
          description: Alias for per_page
      responses:
        '200':
          description: Paginated EDI documents
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/edi/summary:
    get:
      operationId: getEdiSummary
      tags:
        - Reports
      summary: EDI aggregate summary
      description: Aggregate summary of EDI documents with counts by status and type.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: date_from
          schema:
            type: string
            format: date-time
          description: Start of date range
        - in: query
          name: date_to
          schema:
            type: string
            format: date-time
          description: End of date range
        - in: query
          name: edi_type
          schema:
            type: string
          description: Comma-separated types; defaults to core set
      responses:
        '200':
          description: EDI aggregate summary
          content:
            application/json:
              schema:
                type: object
                properties:
                  total:
                    type: integer
                  success_count:
                    type: integer
                  failed_count:
                    type: integer
                  pending_count:
                    type: integer
                  success_rate:
                    type: number
                  ack_997_count:
                    type: integer
                  ack_997_rate:
                    type: number
                  by_type:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /reports/edi/export:
    get:
      operationId: exportEdiDocuments
      tags:
        - Reports
      summary: EDI report CSV export
      description: |
        Export EDI documents as CSV. Same filters as GET /reports/edi. Rows capped at 50,000.
        Only CSV format is supported.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: export_format
          schema:
            type: string
            enum:
              - csv
            default: csv
          description: Export format (only csv is supported)
        - in: query
          name: edi_type
          schema:
            type: string
          description: Comma-separated EDI transaction types
        - in: query
          name: transaction_status
          schema:
            type: string
          description: Filter by transaction status
        - in: query
          name: direction
          schema:
            type: string
          description: Filter by direction
        - in: query
          name: order_id
          schema:
            type: integer
          description: Filter by order ID
        - in: query
          name: control_number
          schema:
            type: string
          description: Filter by control number
        - in: query
          name: has_received_997
          schema:
            type: string
          description: Filter by 997 acknowledgement status
        - in: query
          name: date_from
          schema:
            type: string
            format: date-time
          description: Start of date range
        - in: query
          name: date_to
          schema:
            type: string
            format: date-time
          description: End of date range
        - in: query
          name: sort_field
          schema:
            type: string
          description: Field to sort by
        - in: query
          name: sort_direction
          schema:
            type: string
          description: Sort direction (asc or desc)
      responses:
        '200':
          description: CSV file
          content:
            text/csv:
              schema:
                type: string
                format: binary
        '400':
          description: Validation or business rule error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /core/inventory-transactions:
    get:
      operationId: listCoreInventoryTransactions
      tags:
        - Core Inventory Ledger
      summary: List Core inventory transactions
      description: |
        List Luminous Core inventory ledger transactions (CITs) with offset pagination.

        Luminous Core is a detailed inventory cost-tracking ledger. Each transaction represents a
        quantity movement (receipt, shipment, adjustment, transfer, etc.) with its computed
        `unit_cost` and `total_cost`. Every row includes a `_links` object with URLs to the
        transaction detail.

        This is distinct from the legacy `GET /reports/transaction-cogs` report, which reports
        sales-item cost layers rather than Core ledger transactions.

        **Availability:** These endpoints return **404** for tenants that do not have Luminous Core
        enabled.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Page number (offset pagination).
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 100
          description: Rows per page (max 100).
        - in: query
          name: 'date[gte]'
          schema:
            type: string
            format: date
          description: Only transactions on or after this date.
        - in: query
          name: 'date[lte]'
          schema:
            type: string
            format: date
          description: Only transactions on or before this date.
        - in: query
          name: 'warehouse_id[in]'
          schema:
            type: string
          description: Comma-separated warehouse ids to include.
        - in: query
          name: 'transaction_type[in]'
          schema:
            type: string
          description: Comma-separated transaction types to include.
        - in: query
          name: linked_type
          schema:
            type: string
          description: 'Filter by the linked document type (e.g. `shipment`, `fulfillment_order`, `sales_order`, `adjustment`, `picklist`).'
        - in: query
          name: item_id
          schema:
            type: integer
          description: Filter by product (RFQ) id.
        - in: query
          name: reference
          schema:
            type: string
          description: Search by linked document reference / order number.
        - in: query
          name: qty_filter
          schema:
            type: string
            enum:
              - all
              - increase
              - decrease
            default: all
          description: Restrict to quantity increases or decreases.
        - in: query
          name: unit_cost_filter
          schema:
            type: string
            enum:
              - all
              - gt0
              - zero
            default: all
          description: Restrict to rows with a non-zero or zero unit cost.
        - in: query
          name: sort_by
          schema:
            type: string
            enum:
              - date
              - qty
              - qty_available
              - unit_cost
              - total_cost
              - linked_order_number
            default: date
          description: Sort column.
        - in: query
          name: sort_dir
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
          description: Sort direction.
      responses:
        '200':
          description: Paginated list of Core inventory transactions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A Core inventory ledger transaction (CIT) list row.
                      properties:
                        id:
                          type: integer
                        item_id:
                          type: integer
                          nullable: true
                          description: Product (RFQ) id.
                        transaction_type:
                          type: string
                          nullable: true
                        date:
                          type: string
                        stage_name:
                          type: string
                          nullable: true
                          description: Inventory stage name.
                        warehouse_name:
                          type: string
                          nullable: true
                        qty:
                          type: number
                        unit_cost:
                          type: number
                        total_cost:
                          type: number
                        qty_used:
                          type: number
                        qty_available:
                          type: number
                        is_stock_pull:
                          type: boolean
                        needs_cost_review:
                          type: boolean
                        product_sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        linked_type:
                          type: string
                          nullable: true
                          description: 'Linked document type (e.g. `shipment`, `fulfillment_order`, `sales_order`, `adjustment`, `picklist`).'
                        linked_id:
                          type: integer
                          nullable: true
                        linked_order_number:
                          type: string
                          nullable: true
                        channel:
                          type: string
                          nullable: true
                        po_number:
                          type: string
                          nullable: true
                        external_po_id:
                          type: integer
                          nullable: true
                        badges:
                          type: array
                          description: 'UI badges describing the row (e.g. stock pull, needs review).'
                          items:
                            type: object
                        _links:
                          type: object
                          properties:
                            self:
                              type: string
                              format: uri
                            detail:
                              type: string
                              format: uri
                  meta:
                    type: object
                    properties:
                      total:
                        type: integer
                      current_page:
                        type: integer
                      per_page:
                        type: integer
                      last_page:
                        type: integer
                      from:
                        type: integer
                        nullable: true
                      to:
                        type: integer
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Luminous Core is not enabled for this tenant.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /core/inventory-transactions/export:
    get:
      operationId: exportCoreInventoryTransactions
      tags:
        - Core Inventory Ledger
      summary: Export Core inventory transactions
      description: |
        Bulk export of Core inventory ledger transactions using cursor (keyset) pagination, intended
        for incremental syncs into an external system.

        The **first** page requires `since` (and, in `date_range` mode, `until`). Each response
        returns a `next_cursor`; pass it back as `cursor` (with no `since`) to fetch the next page
        until `has_more` is `false`.

        **Modes:**
        - `incremental` (default) — walks an `updated_at` window with a keyset on `(updated_at, id)`.
        - `date_range` — walks the transaction `date` window with a keyset on `(date, id)`; requires
          `until` on the first page.

        **Availability:** Returns **404** for tenants that do not have Luminous Core enabled.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: mode
          schema:
            type: string
            enum:
              - incremental
              - date_range
            default: incremental
          description: Export windowing mode.
        - in: query
          name: since
          schema:
            type: string
            format: date-time
          description: Start of the window. Required on the first page; omit when passing `cursor`.
        - in: query
          name: until
          schema:
            type: string
            format: date-time
          description: End of the window. Required on the first page when `mode=date_range`.
        - in: query
          name: cursor
          schema:
            type: string
          description: Opaque token from the previous response's `next_cursor`. Mutually exclusive with `since`.
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1000
          description: Maximum rows per page.
      responses:
        '200':
          description: A single export page.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A Core inventory transaction (CIT) export row.
                      properties:
                        id:
                          type: integer
                        item_id:
                          type: integer
                          nullable: true
                          description: Product (RFQ) id.
                        linked_type:
                          type: string
                          nullable: true
                        linked_id:
                          type: integer
                          nullable: true
                        linked_line_item_id:
                          type: integer
                          nullable: true
                        transaction_type:
                          type: string
                          nullable: true
                        date:
                          type: string
                          nullable: true
                        warehouse_id:
                          type: integer
                          nullable: true
                        location_id:
                          type: integer
                          nullable: true
                        stage_name:
                          type: string
                          nullable: true
                        product_sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        qty:
                          type: number
                        unit_cost:
                          type: number
                        total_cost:
                          type: number
                        qty_used:
                          type: number
                        qty_available:
                          type: number
                        is_stock_pull:
                          type: boolean
                        is_stock_move:
                          type: boolean
                        needs_cost_review:
                          type: boolean
                        cost_basis:
                          type: string
                          description: Cost basis for the transaction (e.g. `actual`).
                        tb_rfq_stock_qty_log_id:
                          type: integer
                          nullable: true
                        updated_at:
                          type: string
                          nullable: true
                        cost_summary:
                          type: object
                          nullable: true
                          description: Rollup of the transaction's allocated cost lines. Present when cost data is available.
                          properties:
                            line_count:
                              type: integer
                            product_line_total:
                              type: number
                            extra_cost_total:
                              type: number
                  next_cursor:
                    type: string
                    nullable: true
                    description: Pass back as `cursor` to fetch the next page. `null` on the last page.
                  has_more:
                    type: boolean
                  meta:
                    type: object
                    properties:
                      rows:
                        type: integer
                      total_count:
                        type: integer
                        nullable: true
        '400':
          description: Invalid or expired cursor.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Luminous Core is not enabled for this tenant.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Invalid query parameters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/core/inventory-transactions/{transactionId}':
    get:
      operationId: getCoreInventoryTransaction
      tags:
        - Core Inventory Ledger
      summary: Get a Core inventory transaction
      description: |
        Retrieve a single Core inventory ledger transaction (CIT) with its allocated cost lines,
        lineage, and a `unit_cost_breakdown` explaining how the transaction's unit cost is derived
        from its cost lines.

        **Availability:** Returns **404** for tenants that do not have Luminous Core enabled, or when
        the transaction does not exist.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: transactionId
          required: true
          schema:
            type: integer
          description: Core inventory transaction id.
      responses:
        '200':
          description: Core inventory transaction detail.
          content:
            application/json:
              schema:
                type: object
                properties:
                  transaction:
                    type: object
                    description: 'The transaction record (id, item, date, qty, unit_cost, total_cost, linkage, etc.).'
                  costs:
                    type: array
                    description: Allocated cost lines contributing to the transaction's total cost.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        inventory_cost_id:
                          type: integer
                          nullable: true
                        kind:
                          type: string
                          nullable: true
                        kind_label:
                          type: string
                          nullable: true
                        unit_cost:
                          type: number
                          nullable: true
                        total_cost:
                          type: number
                        _links:
                          type: object
                          properties:
                            inventory_cost:
                              type: string
                              format: uri
                  lineage_cards:
                    type: array
                    description: Related upstream/downstream transactions in this transaction's cost lineage.
                    items:
                      type: object
                  unit_cost_breakdown:
                    type: object
                    description: Explains how `unit_cost` is derived from the allocated cost lines.
                    properties:
                      qty:
                        type: number
                      abs_qty:
                        type: number
                      unit_cost:
                        type: number
                      total_cost:
                        type: number
                      sum_of_cost_lines:
                        type: number
                      computed_unit_cost_from_lines:
                        type: number
                        nullable: true
                      explanation:
                        type: string
                      lines:
                        type: array
                        items:
                          type: object
                          properties:
                            citc_id:
                              type: integer
                              nullable: true
                            inventory_cost_id:
                              type: integer
                              nullable: true
                            kind:
                              type: string
                              nullable: true
                            kind_label:
                              type: string
                              nullable: true
                            total_cost:
                              type: number
                            unit_cost:
                              type: number
                              nullable: true
                  _links:
                    type: object
                    properties:
                      self:
                        type: string
                        format: uri
                      detail:
                        type: string
                        format: uri
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Not found, or Luminous Core is not enabled for this tenant.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /core/inventory-costs:
    get:
      operationId: listCoreInventoryCosts
      tags:
        - Core Inventory Ledger
      summary: List Core inventory costs
      description: |
        List Luminous Core inventory cost records (CICs) with offset pagination. A cost record
        represents an amount (product cost or extra/landed cost) that is allocated across one or more
        inventory transactions.

        **Availability:** Returns **404** for tenants that do not have Luminous Core enabled.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
            default: 1
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 100
          description: Rows per page (max 100).
        - in: query
          name: 'date[gte]'
          schema:
            type: string
            format: date
          description: Only costs on or after this date.
        - in: query
          name: 'date[lte]'
          schema:
            type: string
            format: date
          description: Only costs on or before this date.
        - in: query
          name: linked_type
          schema:
            type: string
          description: 'Filter by linked document type (e.g. `shipment`, `fulfillment_order`, `sales_order`, `adjustment`, `picklist`).'
        - in: query
          name: cost_id
          schema:
            type: integer
          description: Filter by catalog cost (Core cost) id.
        - in: query
          name: item_id
          schema:
            type: integer
          description: Filter by product (RFQ) id.
        - in: query
          name: cost_basis
          schema:
            type: string
          description: Filter by cost basis (e.g. `actual`).
        - in: query
          name: search
          schema:
            type: string
          description: 'Search by product SKU, product name, cost name, or cost id.'
        - in: query
          name: sort
          schema:
            type: string
            enum:
              - date
              - id
              - total_amount
            default: date
        - in: query
          name: dir
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
      responses:
        '200':
          description: Paginated list of Core inventory costs.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A Core inventory cost (CIC) list row.
                      properties:
                        id:
                          type: integer
                        date:
                          type: string
                          nullable: true
                        allocation_type:
                          type: string
                          nullable: true
                        linked_type:
                          type: string
                          nullable: true
                        linked_id:
                          type: integer
                          nullable: true
                        linked_record:
                          type: string
                          description: Human-readable label for the linked document (e.g. `Sales Order
                        is_product_line:
                          type: boolean
                          description: True when this cost is a product line (item cost) rather than an extra/landed cost.
                        qty:
                          type: number
                        amount:
                          type: number
                          description: Per-unit amount.
                        total_amount:
                          type: number
                        cost_item_sku:
                          type: string
                          nullable: true
                        cost_item_name:
                          type: string
                          nullable: true
                        cost_item_rfq_id:
                          type: integer
                          nullable: true
                          description: Product (RFQ) id the cost applies to.
                        core_cost_id:
                          type: integer
                          nullable: true
                          description: Catalog (Core) cost id.
                        core_cost_name:
                          type: string
                          nullable: true
                        cost_basis:
                          type: string
                          nullable: true
                        parent_cost_id:
                          type: integer
                          nullable: true
                        created_at:
                          type: string
                          nullable: true
                        badges:
                          type: array
                          items:
                            type: object
                        _links:
                          type: object
                          properties:
                            self:
                              type: string
                              format: uri
                            detail:
                              type: string
                              format: uri
                  meta:
                    type: object
                    properties:
                      total:
                        type: integer
                      current_page:
                        type: integer
                      per_page:
                        type: integer
                      last_page:
                        type: integer
                      from:
                        type: integer
                        nullable: true
                      to:
                        type: integer
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Luminous Core is not enabled for this tenant.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /core/inventory-costs/export:
    get:
      operationId: exportCoreInventoryCosts
      tags:
        - Core Inventory Ledger
      summary: Export Core inventory costs
      description: |
        Bulk export of Core inventory cost records (CICs) using cursor (keyset) pagination, intended
        for incremental syncs into an external system.

        The **first** page requires `since` (and, in `date_range` mode, `until`). Each response
        returns a `next_cursor`; pass it back as `cursor` (with no `since`) to fetch the next page
        until `has_more` is `false`.

        **Modes:**
        - `incremental` (default) — walks an `updated_at` window.
        - `date_range` — walks the cost `date` window; requires `until` on the first page.

        **Availability:** Returns **404** for tenants that do not have Luminous Core enabled.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: mode
          schema:
            type: string
            enum:
              - incremental
              - date_range
            default: incremental
        - in: query
          name: since
          schema:
            type: string
            format: date-time
          description: Start of the window. Required on the first page; omit when passing `cursor`.
        - in: query
          name: until
          schema:
            type: string
            format: date-time
          description: End of the window. Required on the first page when `mode=date_range`.
        - in: query
          name: cursor
          schema:
            type: string
          description: Opaque token from the previous response's `next_cursor`. Mutually exclusive with `since`.
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1000
      responses:
        '200':
          description: A single export page.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A Core inventory cost (CIC) export row.
                      properties:
                        id:
                          type: integer
                        date:
                          type: string
                          nullable: true
                        item_id:
                          type: integer
                          nullable: true
                          description: Product (RFQ) id.
                        cost_id:
                          type: integer
                          nullable: true
                          description: Catalog (Core) cost id.
                        core_cost_name:
                          type: string
                          nullable: true
                        allocation_type:
                          type: string
                          nullable: true
                        linked_type:
                          type: string
                          nullable: true
                        linked_id:
                          type: integer
                          nullable: true
                        qty:
                          type: number
                        amount:
                          type: number
                          description: Per-unit amount.
                        total_amount:
                          type: number
                        cost_basis:
                          type: string
                          nullable: true
                        is_product_line:
                          type: boolean
                        product_sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        updated_at:
                          type: string
                          nullable: true
                  next_cursor:
                    type: string
                    nullable: true
                  has_more:
                    type: boolean
                  meta:
                    type: object
        '400':
          description: Invalid or expired cursor.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Luminous Core is not enabled for this tenant.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Invalid query parameters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/core/inventory-costs/{costId}':
    get:
      operationId: getCoreInventoryCost
      tags:
        - Core Inventory Ledger
      summary: Get a Core inventory cost
      description: |
        Retrieve a single Core inventory cost record (CIC) with its provenance (how the cost
        originated) and the transaction lines it is allocated across.

        **Availability:** Returns **404** for tenants that do not have Luminous Core enabled, or when
        the cost does not exist.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: costId
          required: true
          schema:
            type: integer
          description: Core inventory cost id.
      responses:
        '200':
          description: Core inventory cost detail.
          content:
            application/json:
              schema:
                type: object
                properties:
                  cost:
                    type: object
                    properties:
                      id:
                        type: integer
                      date:
                        type: string
                        nullable: true
                      cost_id:
                        type: integer
                        nullable: true
                      core_cost_name:
                        type: string
                        nullable: true
                      allocation_type:
                        type: string
                        nullable: true
                      item_id:
                        type: integer
                        nullable: true
                      linked_type:
                        type: string
                        nullable: true
                      linked_id:
                        type: integer
                        nullable: true
                      cost_basis:
                        type: string
                        nullable: true
                      cost_qty:
                        type: number
                      amount:
                        type: number
                      total_amount:
                        type: number
                  provenance:
                    type: object
                    description: |
                      Explains where the cost came from. `kind` is one of `trueup_variance`, `import`,
                      `baseline`, or an origin classification; `explanation` is a human-readable summary.
                      Additional fields vary by `kind` (e.g. `receipt_txn_id`, `estimate_unit_cost`,
                      `variance_total` for true-up variances).
                    properties:
                      kind:
                        type: string
                      explanation:
                        type: string
                      _links:
                        type: object
                        properties:
                          receipt_transaction:
                            type: string
                            format: uri
                  lines:
                    type: array
                    description: Transactions this cost is allocated across.
                    items:
                      type: object
                      properties:
                        inventory_transaction_id:
                          type: integer
                        allocated_amount:
                          type: number
                        product_sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        product_rfq_id:
                          type: integer
                          nullable: true
                        txn_qty:
                          type: number
                        _links:
                          type: object
                          properties:
                            self:
                              type: string
                              format: uri
                            detail:
                              type: string
                              format: uri
                  _links:
                    type: object
                    properties:
                      self:
                        type: string
                        format: uri
                      detail:
                        type: string
                        format: uri
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Not found, or Luminous Core is not enabled for this tenant.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /fulfillment-orders:
    get:
      operationId: getFulfillmentOrders
      tags:
        - Fulfillment Orders
      summary: Fulfillment orders
      description: |
        Get a paginated list of fulfillment orders with nested sales order, picklists, and line items.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).

        ## Available Filters

        ### ID Filters
        - `id`: Fulfillment order ID
        - `warehouse_group_id`: Warehouse group ID
        - `sales_order_id`: Sales order ID

        ### String Filters
        - `order_status`: Fulfillment order status. Common values: `pending`, `awaiting_shipment`, `shipped`, `cancelled`, `on_hold`, `Error` (set by Luminous when a push to the fulfillment channel fails — use this to build a daily error summary)
        - `order_number`: Fulfillment order number

        ### Boolean Filters
        - `has_picklist`: Whether the fulfillment order has a picklist
        - `packing_slip_printed`: `true` returns fulfillment orders whose packing slip has been printed (`packing_slip_printed_at` set); `false` returns those still unprinted. Example: `packing_slip_printed[eq]=true`

        ### DateTime Filters
        - `ship_by_date`: Ship by date
        - `created_at`: When the fulfillment order was created
        - `updated_at`: When the fulfillment order was last updated

        ### Sales Order Filters
        - `sales_order.picking_status`: Sales order picking status
        - `sales_order.order_status`: Sales order status
        - `sales_order.posted`: Whether the sales order is posted
        - `sales_order.order_number`: Sales order number
        - `sales_order.tag`: Sales order tags
        - `sales_order.ship_by_date`: Sales order ship by date
        - `sales_order.has_fulfillment_order`: Whether the sales order has a fulfillment order
        - `sales_order.channel_name`: Sales order channel name

        ### Custom Field Filters
        Fulfillment orders can be filtered by their custom fields. Custom field filters are
        dynamically generated based on the custom fields defined for fulfillment orders (and
        their shipments) in your system.

        Custom field filters use the format `custom_fields.{field_label}` where `{field_label}`
        is the exact label of the custom field as defined in your system. The available operators
        depend on the custom field type:

        - **String/Dropdown fields**: `eq`, `neq`, `contains`, `notcontains`, `in`, `notin`, `set`, `notset`
        - **Number fields**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `notin`, `set`, `notset`
        - **Date fields**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `set`, `notset`

        **Note**: Custom field labels may contain spaces or special characters. When using them in
        URLs, ensure proper URL encoding (e.g., spaces become `%20` or `+`).

        ```
        # Filter by custom field (string) - exact match
        ?custom_fields.Priority[eq]=Rush

        # Filter by custom field (string) - contains
        ?custom_fields.Notes[contains]=fragile

        # Filter by custom field - has value set
        ?custom_fields.Priority[set]=true

        # Combine a custom field filter with other filters
        ?order_status[eq]=awaiting_shipment&custom_fields.Priority[eq]=Rush
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: id
          schema:
            type: integer
          description: Filter by fulfillment order ID
        - in: query
          name: order_status
          schema:
            type: string
            enum:
              - pending
              - awaiting_shipment
              - shipped
              - cancelled
              - on_hold
              - Error
          description: |
            Filter by fulfillment order status. `Error` is Luminous's internal status —
            it is set when a push to the fulfillment channel fails and indicates the order
            needs attention. Use `order_status=Error` to pull all errored FOs for a daily
            error summary. (MySQL collation is case-insensitive, so `error` also works.)
        - in: query
          name: order_number
          schema:
            type: string
          description: Filter by order number
        - in: query
          name: warehouse_group_id
          schema:
            type: integer
          description: Filter by warehouse group ID
        - in: query
          name: sales_order_id
          schema:
            type: integer
          description: Filter by sales order ID
        - in: query
          name: has_picklist
          schema:
            type: boolean
          description: Filter by whether the fulfillment order has a picklist
        - in: query
          name: packing_slip_printed
          schema:
            type: boolean
          description: Filter by whether the fulfillment order's packing slip has been printed (exported or sent to a print station)
        - in: query
          name: ship_by_date
          schema:
            type: string
            format: date-time
          description: Filter by ship by date
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: 'Filter by creation date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: 'Filter by last update date (YYYY-MM-DD HH:mm:ss)'
        - in: query
          name: sales_order.picking_status
          schema:
            type: string
          description: Filter by sales order picking status
        - in: query
          name: sales_order.order_status
          schema:
            type: string
          description: Filter by sales order status
        - in: query
          name: sales_order.posted
          schema:
            type: boolean
          description: Filter by whether the sales order is posted
        - in: query
          name: sales_order.order_number
          schema:
            type: string
          description: Filter by sales order number
        - in: query
          name: sales_order.tag
          schema:
            type: string
          description: Filter by sales order tags
        - in: query
          name: sales_order.ship_by_date
          schema:
            type: string
            format: date-time
          description: Filter by sales order ship by date
        - in: query
          name: sales_order.has_fulfillment_order
          schema:
            type: boolean
          description: Filter by whether the sales order has a fulfillment order
        - in: query
          name: sales_order.channel_name
          schema:
            type: string
          description: Filter by sales order channel name
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Fulfillment order ID
                        order_number:
                          type: string
                          description: Fulfillment order number
                        order_key:
                          type: string
                          nullable: true
                          description: Fulfillment order key
                        order_status:
                          type: string
                          description: Fulfillment order status
                        sales_order_id:
                          type: integer
                          description: Associated sales order ID
                        warehouse_group_id:
                          type: integer
                          nullable: true
                          description: Warehouse group ID
                        destination_oms_id:
                          type: integer
                          nullable: true
                          description: Destination app integration account ID
                        destination_oms_store_id:
                          type: integer
                          nullable: true
                        fulfillment_channel_id:
                          type: integer
                          nullable: true
                        pushed_at:
                          type: string
                          format: date-time
                          nullable: true
                        packing_slip_printed_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                        error_message:
                          type: string
                          nullable: true
                          description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                        ship_by_date:
                          type: string
                          format: date
                          nullable: true
                          description: Ship by date
                        total:
                          type: number
                          format: float
                          nullable: true
                          description: Order total
                        bill_to:
                          type: object
                          nullable: true
                          description: Billing address
                          properties:
                            name:
                              type: string
                            company:
                              type: string
                            street1:
                              type: string
                            street2:
                              type: string
                            street3:
                              type: string
                            city:
                              type: string
                            state:
                              type: string
                            postal_code:
                              type: string
                            country:
                              type: string
                            phone:
                              type: string
                        ship_to:
                          type: object
                          nullable: true
                          description: Shipping address
                          properties:
                            name:
                              type: string
                            company:
                              type: string
                            street1:
                              type: string
                            street2:
                              type: string
                            street3:
                              type: string
                            city:
                              type: string
                            state:
                              type: string
                            postal_code:
                              type: string
                            country:
                              type: string
                            phone:
                              type: string
                        invoice_to:
                          type: object
                          nullable: true
                          description: Invoice address
                          properties:
                            name:
                              type: string
                            company:
                              type: string
                            street1:
                              type: string
                            street2:
                              type: string
                            street3:
                              type: string
                            city:
                              type: string
                            state:
                              type: string
                            postal_code:
                              type: string
                            country:
                              type: string
                            phone:
                              type: string
                        sales_order:
                          type: object
                          nullable: true
                          description: Nested sales order data
                        picklists:
                          type: array
                          description: Associated picklists
                          items:
                            type: object
                        fulfillment_order_items:
                          type: array
                          description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                nullable: true
                                description: Fulfillment order line ID. `null` for synthetic kit component rows.
                              shipment_id:
                                type: integer
                                nullable: true
                                description: ID of the fulfillment order this line belongs to.
                              status:
                                nullable: true
                                description: Line status.
                              sales_order_item_id:
                                type: integer
                                nullable: true
                                description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                              product_id:
                                type: integer
                                nullable: true
                                description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                              sku:
                                type: string
                                nullable: true
                              name:
                                type: string
                                nullable: true
                              weight:
                                nullable: true
                                description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                              dimensions:
                                nullable: true
                                description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                              quantity:
                                type: number
                                description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                              unit_price:
                                type: number
                                description: Unit price. Always `0` on synthetic component rows.
                              lot_id:
                                type: integer
                                nullable: true
                              lot_number:
                                type: string
                                nullable: true
                              expiry_date:
                                type: string
                                nullable: true
                                description: Lot expiry date.
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              is_kit_component:
                                type: boolean
                                description: True when the row is a component of a kit (stored or synthetic).
                              parent_fulfillment_order_item_id:
                                type: integer
                                nullable: true
                                description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                              kit_sales_order_item_id:
                                type: integer
                                nullable: true
                                description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                              is_synthetic:
                                type: boolean
                                description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                        total_weight:
                          type: object
                          nullable: true
                          description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                          properties:
                            total_oz:
                              type: number
                              format: float
                              description: Total weight in ounces
                            total_lb:
                              type: number
                              format: float
                              description: Total weight in pounds
                            line_count:
                              type: integer
                              description: Number of fulfillment order lines
                            weighed_line_count:
                              type: integer
                              description: Number of lines that had a usable weight and contributed to the total
                            is_complete:
                              type: boolean
                              description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                        tags:
                          type: array
                          description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the tag
                              name:
                                type: string
                                description: Name of the tag
                              description:
                                type: string
                                nullable: true
                                description: Description of the tag
                              icon:
                                type: string
                                nullable: true
                                description: Icon identifier or URL for the tag
                              color:
                                type: string
                                nullable: true
                                description: Color code for the tag
                            required:
                              - id
                              - name
                        purchase_orders:
                          type: array
                          description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              order_status:
                                type: string
                                nullable: true
                                enum:
                                  - active
                                  - deleted
                                  - completed
                        source_reference_identifier:
                          type: string
                          nullable: true
                          description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                        held_for_item_change:
                          type: boolean
                          description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                        created_at:
                          type: string
                          format: date-time
                          description: When the fulfillment order was created
                        updated_at:
                          type: string
                          format: date-time
                          description: When the fulfillment order was last updated
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /fulfillment-orders/simulate:
    post:
      operationId: simulateFulfillmentOrders
      tags:
        - Fulfillment Orders
      summary: Simulate fulfillment-order generation (bulk)
      description: |
        Dry-run fulfillment-order generation for up to **50** sales orders at once. Read-only —
        no database writes and no inventory allocation take place. Returns, per order, which
        fulfillment orders *would* be generated and whether stock shortages would occur.

        For a single order you can use `POST /sales-orders/{salesOrderId}/simulate-fulfillment`,
        which returns the same shape.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sales_order_ids
              properties:
                sales_order_ids:
                  type: array
                  description: Sales order IDs to simulate (1–50).
                  minItems: 1
                  maxItems: 50
                  items:
                    type: integer
                    minimum: 1
                  example:
                    - 12345
                    - 12346
                skip_status_check:
                  type: boolean
                  default: true
                  description: 'When true (default), skip the sales order status gate.'
      responses:
        '200':
          description: Simulation completed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: Result of a dry-run fulfillment-order simulation.
                    properties:
                      results:
                        type: array
                        description: One entry per simulated sales order.
                        items:
                          type: object
                          properties:
                            sales_order_id:
                              type: integer
                              example: 12345
                            order_number:
                              type: string
                              nullable: true
                              example: SO-1001
                            channel_id:
                              type: integer
                              nullable: true
                            channel_name:
                              type: string
                              nullable: true
                            status:
                              type: string
                              description: |
                                Outcome for this order:
                                - `SUCCESS` — one or more fulfillment orders would be generated
                                - `NO_STOCK` — nothing could be generated due to insufficient stock
                                - `ERROR` — the order was not found, is inactive, or an error occurred
                              enum:
                                - SUCCESS
                                - NO_STOCK
                                - ERROR
                            message:
                              type: string
                              example: 1 Fulfillment Order(s) would be generated.
                            simulated:
                              type: boolean
                              example: true
                            simulated_fulfillment_orders:
                              type: array
                              description: The fulfillment orders that would be created (not persisted).
                              items:
                                type: object
                                additionalProperties: true
                            has_shortages:
                              type: boolean
                            shortage_items:
                              type: array
                              items:
                                type: object
                                additionalProperties: true
                            detailed_decisions:
                              type: array
                              description: Per-line routing / allocation decisions made during the simulation.
                              items:
                                type: object
                                additionalProperties: true
                      summary:
                        type: object
                        properties:
                          total_orders_simulated:
                            type: integer
                            example: 1
                          orders_with_fos:
                            type: integer
                            description: Count of orders with status `SUCCESS`.
                            example: 1
                          orders_without_stock:
                            type: integer
                            description: Count of orders with status `NO_STOCK`.
                            example: 0
                          orders_with_errors:
                            type: integer
                            description: Count of orders with status `ERROR`.
                            example: 0
                          total_simulated_fulfillment_orders:
                            type: integer
                            description: Total fulfillment orders that would be generated across all orders.
                            example: 1
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (e.g. more than 50 IDs, or a non-integer ID)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /fulfillment-orders/bulk-delete:
    post:
      operationId: bulkDeleteFulfillmentOrders
      tags:
        - Fulfillment Orders
      summary: Bulk delete fulfillment orders
      description: |
        Delete up to 50 fulfillment orders in one call. Each fulfillment order follows the same
        rules as `DELETE /fulfillment-orders/{id}`: a pushed order is removed from its fulfillment
        channel first, `skip_unpush` deletes in Luminous only, and an order on a picklist or with a
        shipped shipment is refused, and each affected sales order's status is updated the same way. Orders are handled one at a time, so one refusal or failure does not stop the rest.

        The response is `200` whenever the request itself is valid. Check each entry in `results`
        for its outcome. An ID that does not match a fulfillment order is returned as `not_found`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ids
              properties:
                ids:
                  type: array
                  minItems: 1
                  maxItems: 50
                  items:
                    type: integer
                    minimum: 1
                  description: IDs of the fulfillment orders to delete (1 to 50). Duplicates are processed once.
                skip_unpush:
                  type: boolean
                  default: false
                  description: 'Delete in Luminous only, without removing the orders from their fulfillment channels'
              example:
                ids:
                  - 101
                  - 102
      responses:
        '200':
          description: 'Request processed; one result per fulfillment order ID, in the order given'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      summary:
                        type: object
                        description: Count of fulfillment orders per result
                        properties:
                          deleted:
                            type: integer
                          refused:
                            type: integer
                          not_found:
                            type: integer
                          failed:
                            type: integer
                      results:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Fulfillment order ID
                            result:
                              type: string
                              enum:
                                - deleted
                                - refused
                                - not_found
                                - failed
                              description: |
                                `refused`: the order is on a picklist, has a shipped shipment, the channel
                                refused to remove it, or it is being pushed right now (the message says to try again). `failed`: an
                                unexpected error; retry that ID.
                            message:
                              type: string
                            can_skip_unpush:
                              type: boolean
                              description: |
                                `true` when the channel refused to remove the order. Retry with
                                `skip_unpush: true` only once the order is confirmed gone from the warehouse.
              example:
                data:
                  summary:
                    deleted: 1
                    refused: 1
                    not_found: 0
                    failed: 0
                  results:
                    - id: 101
                      result: deleted
                      message: Fulfillment order successfully deleted.
                      can_skip_unpush: false
                    - id: 102
                      result: refused
                      message: 'Cannot delete fulfillment order: failed to remove it from the fulfillment channel.'
                      can_skip_unpush: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (`ids` missing, empty, longer than 50, or not integers)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{id}':
    get:
      operationId: getFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Get fulfillment order
      description: |
        Return one fulfillment order by ID, including destination OMS, fulfillment channel,
        push timestamps, and the last `error_message` from a failed push.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Fulfillment order ID (`sales_orders_shipments.id`)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Fulfillment order ID
                      order_number:
                        type: string
                        description: Fulfillment order number
                      order_key:
                        type: string
                        nullable: true
                        description: Fulfillment order key
                      order_status:
                        type: string
                        description: Fulfillment order status
                      sales_order_id:
                        type: integer
                        description: Associated sales order ID
                      warehouse_group_id:
                        type: integer
                        nullable: true
                        description: Warehouse group ID
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination app integration account ID
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                      pushed_at:
                        type: string
                        format: date-time
                        nullable: true
                      packing_slip_printed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                      error_message:
                        type: string
                        nullable: true
                        description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                      ship_by_date:
                        type: string
                        format: date
                        nullable: true
                        description: Ship by date
                      total:
                        type: number
                        format: float
                        nullable: true
                        description: Order total
                      bill_to:
                        type: object
                        nullable: true
                        description: Billing address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      invoice_to:
                        type: object
                        nullable: true
                        description: Invoice address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      sales_order:
                        type: object
                        nullable: true
                        description: Nested sales order data
                      picklists:
                        type: array
                        description: Associated picklists
                        items:
                          type: object
                      fulfillment_order_items:
                        type: array
                        description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Fulfillment order line ID. `null` for synthetic kit component rows.
                            shipment_id:
                              type: integer
                              nullable: true
                              description: ID of the fulfillment order this line belongs to.
                            status:
                              nullable: true
                              description: Line status.
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                            product_id:
                              type: integer
                              nullable: true
                              description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                            sku:
                              type: string
                              nullable: true
                            name:
                              type: string
                              nullable: true
                            weight:
                              nullable: true
                              description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                            dimensions:
                              nullable: true
                              description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                            quantity:
                              type: number
                              description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                            unit_price:
                              type: number
                              description: Unit price. Always `0` on synthetic component rows.
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              nullable: true
                              description: Lot expiry date.
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            is_kit_component:
                              type: boolean
                              description: True when the row is a component of a kit (stored or synthetic).
                            parent_fulfillment_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                            kit_sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                            is_synthetic:
                              type: boolean
                              description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                      total_weight:
                        type: object
                        nullable: true
                        description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                        properties:
                          total_oz:
                            type: number
                            format: float
                            description: Total weight in ounces
                          total_lb:
                            type: number
                            format: float
                            description: Total weight in pounds
                          line_count:
                            type: integer
                            description: Number of fulfillment order lines
                          weighed_line_count:
                            type: integer
                            description: Number of lines that had a usable weight and contributed to the total
                          is_complete:
                            type: boolean
                            description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                      tags:
                        type: array
                        description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      purchase_orders:
                        type: array
                        description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                              enum:
                                - active
                                - deleted
                                - completed
                      source_reference_identifier:
                        type: string
                        nullable: true
                        description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                      held_for_item_change:
                        type: boolean
                        description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                      created_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Delete fulfillment order
      description: |
        Delete a fulfillment order, the same way deleting it in the Luminous web app does. The
        fulfillment order is removed from its sales order and the quantities it held on the sales
        order lines are freed, so new fulfillment orders can be generated for them (for example with
        `POST /sales-orders/{salesOrderId}/auto-generate-fulfillment-orders` to re-route to another
        warehouse). Unlike `POST /fulfillment-orders/{fulfillmentOrderId}/cancel`, nothing stays on
        the sales order.

        - If the fulfillment order was pushed, Luminous first removes it from its fulfillment
          channel. If the channel refuses, nothing is deleted and the request returns `422` with
          `can_skip_unpush: true`.
        - Send `skip_unpush: true` to delete in Luminous only, without contacting the channel
          (the web app's "Delete in Luminous only"). Use it only when the order is already gone
          from the warehouse.
        - A fulfillment order that is on a picklist cannot be deleted (`422` with
          `can_skip_unpush: false`).
        - A fulfillment order with a shipped shipment cannot be deleted (`422` with
          `can_skip_unpush: false`; the message lists the shipment IDs). Nothing is removed from the
          channel in that case.

        After the delete, the sales order's status is worked out again from its lines when it is
        `pending`, `awaiting_shipment` or `partially_shipped`. For example, deleting the last
        unshipped fulfillment order while another one has shipped moves the sales order to `shipped`.
        Any other status (on hold, cancelled, shipped, and so on) is left as it is.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Fulfillment order ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                skip_unpush:
                  type: boolean
                  default: false
                  description: 'Delete in Luminous only, without removing the order from its fulfillment channel'
      responses:
        '200':
          description: Fulfillment order deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: true
                      message:
                        type: string
                        example: Fulfillment order successfully deleted.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Delete refused: the fulfillment channel refused to remove the order, the order is on a
            picklist, the order has a shipped shipment, or the order is being pushed right now (retry
            later). Nothing was deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  can_skip_unpush:
                    type: boolean
                    description: |
                      `true` when the channel refused to remove the order. Retry with
                      `skip_unpush: true` only once the order is confirmed gone from the warehouse.
        '500':
          description: Unexpected error while deleting; retry
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{id}/push':
    post:
      operationId: pushFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Push fulfillment order to OMS
      description: |
        Push this fulfillment order to its destination OMS (fulfillment channel). The destination is determined by the
        fulfillment order's existing channel mapping; no destination is taken from the request body.

        Optionally enable per-request HTTP debug capture by sending `{ "debug": true }` — the debug payload is returned
        inline alongside the result. Same behavior as the admin bulk push action.

        **Unmapped lines:** before the push, any physical, non-ignored line that is not mapped to
        a product is removed from the fulfillment order and returned to the sales order as
        unfulfilled. It is not sent to the destination. The mapped lines still push, and the
        success `message` ends with a notice naming the removed lines (`... not mapped to a product
        — removed from this fulfillment order and returned to the sales order as unfulfilled. Map
        before fulfilling.`). If the push is refused for another reason, nothing is removed. If
        every line is unmapped, the push is refused with `422` (`Blocked push: ... is not mapped to
        a product. Map it before pushing this fulfillment order.`) and nothing changes.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                debug:
                  type: boolean
                  description: 'When true, capture and return outbound OMS HTTP traffic in `data.debug`.'
                  default: false
      responses:
        '200':
          description: Push succeeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      data:
                        type: object
                        description: Provider-specific response payload (only present when the OMS returned data).
                        additionalProperties: true
                      debug:
                        type: object
                        description: Present only when `debug=true` was sent in the request body.
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Push failed (validation error or OMS rejected the push). A cancelled fulfillment order is
            never pushed: the request fails with message `Skipped push: fulfillment order is cancelled.`.
            A fulfillment order whose lines are all unmapped fails with `Blocked push: ... is not mapped to a product. ...`.
            When the failure is due to a duplicate-push / desync state, the response includes a `data.links.reconcile` URL pointing
            to the reconcile-source-reference endpoint for this fulfillment order.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: false
                      message:
                        type: string
                      data:
                        type: object
                        additionalProperties: true
                      links:
                        type: object
                        description: Present when the failure can be resolved by reconciling the source reference.
                        properties:
                          reconcile:
                            type: string
                            description: URL to POST to in order to reconcile the source reference.
                          docs:
                            type: string
                            description: Documentation URL for the reconcile endpoint.
                      debug:
                        type: object
                        additionalProperties: true
  '/fulfillment-orders/{id}/unpush':
    post:
      operationId: unpushFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Unpush fulfillment order from OMS
      description: |
        Remove this fulfillment order from its destination OMS, when the destination supports unpushing. Optionally
        enable per-request HTTP debug capture by sending `{ "debug": true }`.

        After a successful unpush the fulfillment order returns to `pending`, unless it is cancelled (or it is not a
        merged FO and its sales order is cancelled) — in that case it stays (or becomes) `cancelled` and its pending
        inventory is released, so it cannot be pushed again.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                debug:
                  type: boolean
                  description: 'When true, capture and return outbound OMS HTTP traffic in `data.debug`.'
                  default: false
      responses:
        '200':
          description: Unpush succeeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      data:
                        type: object
                        additionalProperties: true
                      debug:
                        type: object
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Unpush failed (validation error or OMS rejected the unpush)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: false
                      message:
                        type: string
                      data:
                        type: object
                        additionalProperties: true
                      debug:
                        type: object
                        additionalProperties: true
  '/fulfillment-orders/{id}/reconcile-source-reference':
    post:
      operationId: reconcileFulfillmentOrderSourceReference
      tags:
        - Fulfillment Orders
      summary: Reconcile source reference
      description: |
        Bind an existing remote OMS order ID to a fulfillment order's `source_reference_identifier`,
        resolving push failures caused by duplicate-push errors (HTTP 409) or other desync states
        where Luminous lost track of the remote order it already created.

        **Modes**

        - **Auto** (default) — omit or set `source_reference_identifier` to `null`. Luminous queries the
          remote OMS for orders matching this fulfillment order's order number, validates line items,
          and binds the first match.
        - **Manual** — provide `source_reference_identifier`. Luminous fetches that specific remote order,
          validates line items, and binds it. Add `"force": true` to skip line-item validation when
          SKU mappings can't be resolved.

        After a successful bind the fulfillment order status is set to `awaiting_fulfillment`, its error
        message is cleared, and a sales order refresh job is dispatched (unless `trigger_order_refresh`
        is `false` or `dry_run` is `true`).

        The push endpoint's 422 response body includes a `links.reconcile` URL pointing directly here
        when a push fails.

        **Supported integrations** — currently TrackStar. Other OMS integrations return a 422 with
        an `app` field naming the unsupported integration.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                source_reference_identifier:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: |
                    The remote OMS order ID to bind. Omit or pass `null` for **auto** mode.
                    Provide a value for **manual** mode.
                force:
                  type: boolean
                  default: false
                  description: |
                    Manual mode only. When `true`, skip line-item quantity/SKU validation and bind
                    the remote order regardless. Has no effect in auto mode and returns a 422 if
                    used without `source_reference_identifier`.
                dry_run:
                  type: boolean
                  default: false
                  description: |
                    When `true`, validate and return what would happen without writing to the database
                    or dispatching a refresh job.
                trigger_order_refresh:
                  type: boolean
                  default: true
                  description: |
                    When `true` (default), dispatch a sales order refresh job after a successful bind.
                    Ignored when `dry_run` is `true`.
                debug:
                  type: boolean
                  default: false
                  description: 'When `true`, capture and return outbound OMS HTTP traffic in `data.debug`.'
      responses:
        '200':
          description: |
            Reconciliation succeeded (or was already reconciled / dry run). Check `data.data.mode` to
            distinguish: `"auto"`, `"manual"`, `"noop"` (already reconciled), or the `dry_run` flag.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: true
                      message:
                        type: string
                        example: Fulfillment order reconciled with remote order.
                      data:
                        type: object
                        properties:
                          fulfillment_order_id:
                            type: integer
                          source_reference_identifier:
                            type: string
                            description: The remote OMS order ID that was bound.
                          mode:
                            type: string
                            enum:
                              - auto
                              - manual
                              - noop
                            description: |
                              `auto` — lookup found a match automatically.
                              `manual` — caller provided the remote ID.
                              `noop` — FO already had a source reference identifier; no change made.
                          line_items_matched:
                            type: boolean
                            description: Whether Luminous line items matched the remote order's line items.
                          forced:
                            type: boolean
                            description: True when `force=true` was passed and line items did not match.
                          candidates_considered:
                            type: integer
                            nullable: true
                            description: Number of remote candidates evaluated (auto mode only; null in manual mode).
                          dry_run:
                            type: boolean
                            description: Present and true when `dry_run=true` was requested.
                          already_reconciled:
                            type: boolean
                            description: Present and true when the FO already had a source reference (noop mode).
                      debug:
                        type: object
                        description: Present only when `debug=true` was sent in the request body.
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Reconciliation failed. Common reasons: no matching remote order found, line items do not
            match (use `force=true` to override in manual mode), remote ID already claimed by another
            FO, integration app does not support remote lookup, or `force=true` sent without
            `source_reference_identifier`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: false
                      message:
                        type: string
                      data:
                        type: object
                        description: Error context (fields vary by error type).
                        additionalProperties: true
                      debug:
                        type: object
                        additionalProperties: true
  '/fulfillment-orders/{id}/remove-so-item':
    post:
      operationId: removeSalesOrderItemFromFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Remove sales order line from fulfillment order
      description: |
        Detach a sales order line from this fulfillment order. The pivot allocation is removed and FO line quantities
        are resynced. Fails 422 if the FO has been picked or pushed (use `allow_pushed=true` to override the pushed
        guard).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sales_order_item_id
              properties:
                sales_order_item_id:
                  type: integer
                  minimum: 1
                allow_pushed:
                  type: boolean
                  default: false
                  description: 'When true, allows removal even if the FO has already been pushed to its destination OMS.'
      responses:
        '200':
          description: Removed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order or sales order line not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Cannot remove (pivot guard, picklist, or pushed status)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{id}/shipments':
    post:
      operationId: createFulfillmentOrderShipment
      tags:
        - Fulfillment Orders
      summary: Create Shipment
      description: |
        Create a carrier shipment bound to a specific fulfillment order. The fulfillment order's parent sales order is
        resolved from the path, so callers do not need to look up the sales order first.

        The shipment is linked to the fulfillment order (populating the fulfillment-order/shipment pivot and the legacy
        `sales_order_shipment_id` FK). Reposts with the same `tracking_number` + `carrier_code` are idempotent and will
        attach any missing pivot rows.

        Once the shipment is added, the parent sales order status will automatically be updated to either `shipped` or
        `partially_shipped`, and any shipment costs will be added to the sales order total.

        NOTE: At this time, inventory adjustments will not be made automatically.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ship_date
                - tracking_number
                - carrier_code
                - ship_to
                - items
              properties:
                ship_date:
                  type: string
                  format: date
                  description: Date when the shipment will be sent (YYYY-MM-DD)
                tracking_number:
                  type: string
                  description: Tracking number for the shipment
                bol_number:
                  type: string
                  description: Bill of Lading Number for logistics tracking
                  example: BOL-123456789
                pro_number:
                  type: string
                  description: Progressive Rotating Order Number (common in LTL shipping)
                  example: PRO-987654321
                partner_reference_number:
                  type: string
                  description: General reference number from/for the shipping partner
                  example: PARTNER-REF-001
                is_return:
                  type: boolean
                  description: Whether this is a return shipment
                carrier_code:
                  type: string
                  description: Code identifying the carrier
                  example: fedex
                service_code:
                  type: string
                  description: Code identifying the shipping service
                  example: ups_ground
                shipment_cost:
                  type: number
                  format: float
                  description: Cost of shipping
                insurance_cost:
                  type: number
                  format: float
                  description: Cost of insurance
                package_code:
                  type: string
                  description: Code identifying the package type
                  example: flat_rate_envelope
                warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the warehouse shipping from
                ship_to:
                  type: object
                  required:
                    - name
                    - street1
                    - city
                    - state
                    - postalCode
                    - country
                    - residential
                  properties:
                    name:
                      type: string
                      description: Recipient name
                    company:
                      type: string
                      description: Company name
                    street1:
                      type: string
                      description: Primary street address
                    street2:
                      type: string
                      description: Secondary street address
                    street3:
                      type: string
                      description: Additional street address
                    city:
                      type: string
                      description: City
                    state:
                      type: string
                      description: State/province
                    postalCode:
                      type: string
                      description: Postal/ZIP code
                    country:
                      type: string
                      description: Country
                    phone:
                      type: string
                      description: Contact phone number
                    residential:
                      type: boolean
                      description: Whether this is a residential address
                weight:
                  type: object
                  required:
                    - value
                    - units
                  properties:
                    value:
                      type: number
                      format: float
                      description: Weight value
                    units:
                      type: string
                      enum:
                        - ounces
                        - pounds
                        - grams
                        - kilograms
                      description: Unit of weight measurement
                dimensions:
                  type: object
                  required:
                    - units
                    - length
                    - width
                    - height
                  properties:
                    units:
                      type: string
                      enum:
                        - inches
                        - centimeters
                      description: Unit of dimensional measurement
                    length:
                      type: number
                      format: float
                      description: Length of the package
                    width:
                      type: number
                      format: float
                      description: Width of the package
                    height:
                      type: number
                      format: float
                      description: Height of the package
                items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - product_id
                      - order_item_id
                      - quantity
                      - unit_price
                    properties:
                      product_id:
                        type: integer
                        description: ID of the product being shipped
                      order_item_id:
                        type: integer
                        description: Luminous sales order line-item ID. Use the `sales_order_item_id` returned on the shipment/fulfillment-order read endpoints; for kit/bundle component lines pass the component's own `sales_order_item_id`.
                      weight:
                        type: object
                        required:
                          - value
                          - units
                        properties:
                          value:
                            type: number
                            format: float
                            description: Weight value
                          units:
                            type: string
                            enum:
                              - ounces
                              - pounds
                              - grams
                              - kilograms
                            description: Unit of weight measurement
                      quantity:
                        type: integer
                        minimum: 1
                        description: Quantity to ship
                      unit_price:
                        type: number
                        format: float
                        minimum: 0
                        description: Price per unit
                      lot_id:
                        type: integer
                        nullable: true
                        description: 'ID of the lot to deduct this line from (CS-10083). Required when the product is lot-tracked (`product.lot_tracking`); optional and ignored otherwise. Must be a lot on the same product, staged in this order''s picklist WIP bin with enough quantity. When the fulfillment order has no picklist of its own, the WIP bin of a sales-order picklist already holding the shipped quantity is used instead; with neither, the lot must be on hand in the shipping warehouse. Send two items with the same `order_item_id` and different `lot_id` to split one line across lots. When omitted, Luminous falls back to its FEFO/FIFO lot-deduction strategy. Lot problems return `422` keyed `items.N.lot_id`.'
                  description: Items to be included in this shipment
      responses:
        '201':
          description: Shipment created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Unique identifier for the shipment
                  sales_order_id:
                    type: integer
                    description: ID of the associated sales order
                  shipped_by_user:
                    description: 'Luminous user who marked the parent sales order shipped, or `null` when not set. Who picked and packed is not stored on the shipment; see `picked_by_user` / `packed_by_user` on picklists.'
                    type: object
                    nullable: true
                    properties:
                      id:
                        type: integer
                      name:
                        type: string
                        nullable: true
                  ship_date:
                    type: string
                    format: date
                    description: Date when the shipment was or will be sent
                  tracking_number:
                    type: string
                    description: Tracking number for the shipment
                  tracking_url:
                    type: string
                    nullable: true
                    description: |
                      Tracking URL for the shipment. This is the stored URL, or a carrier URL built from the
                      tracking number when carrier tracking links are enabled for the tenant.
                  delivery_status:
                    type: string
                    nullable: true
                    enum:
                      - pre_transit
                      - in_transit
                      - out_for_delivery
                      - delivered
                      - exception
                      - null
                    description: |
                      Carrier delivery status from the Luminous label-tracking record that shares this
                      shipment's tracking number (and fulfillment order, when the shipment is bound to one).
                      `available_for_pickup` is reported as `out_for_delivery`; `failure`, `return_to_sender`,
                      `error`, and `cancelled` are reported as `exception`. `null` when Luminous has no
                      label-tracking record for the shipment (for example a tracking number imported from
                      ShipStation) or the carrier status is unknown.
                  delivered_at:
                    type: string
                    format: date-time
                    nullable: true
                    description: |
                      Delivery timestamp from the same label-tracking record as `delivery_status`. `null` when
                      there is no tracking record or the shipment has not been delivered.
                  bol_number:
                    type: string
                    description: Bill of Lading Number for logistics tracking
                    example: BOL-123456789
                  pro_number:
                    type: string
                    description: Progressive Rotating Order Number (common in LTL shipping)
                    example: PRO-987654321
                  partner_reference_number:
                    type: string
                    description: General reference number from/for the shipping partner
                    example: PARTNER-REF-001
                  is_return:
                    type: boolean
                    description: Whether this is a return shipment
                  carrier_code:
                    type: string
                    description: 'Code identifying the carrier (e.g., ups, fedex)'
                  scac:
                    type: string
                    nullable: true
                    description: Standard Carrier Alpha Code (SCAC) for the shipment's carrier; included on outbound EDI 856/810 documents
                  service_code:
                    type: string
                    description: Code identifying the shipping service
                  package_code:
                    type: string
                    description: Code identifying the package type
                  shipment_cost:
                    type: number
                    format: float
                    description: Cost of shipping
                  insurance_cost:
                    type: number
                    format: float
                    description: Cost of insurance
                  warehouse_group_id:
                    type: integer
                    nullable: true
                    description: ID of the warehouse group associated with this shipment (from the linked fulfillment order)
                  status:
                    type: integer
                    description: Status of the shipment
                  ship_to:
                    type: object
                    properties:
                      name:
                        type: string
                        description: Recipient name
                      company:
                        type: string
                        description: Company name
                      street1:
                        type: string
                        description: Primary street address
                      street2:
                        type: string
                        description: Secondary street address
                      street3:
                        type: string
                        description: Additional street address
                      city:
                        type: string
                        description: City
                      state:
                        type: string
                        description: State/province
                      postalCode:
                        type: string
                        description: Postal/ZIP code
                      country:
                        type: string
                        description: Country
                      phone:
                        type: string
                        description: Contact phone number
                      residential:
                        type: boolean
                        description: Whether this is a residential address
                  weight:
                    type: object
                    required:
                      - value
                      - units
                    properties:
                      value:
                        type: number
                        format: float
                        description: Weight value
                      units:
                        type: string
                        enum:
                          - ounces
                          - pounds
                          - grams
                          - kilograms
                        description: Unit of weight measurement
                  dimensions:
                    type: object
                    required:
                      - units
                      - length
                      - width
                      - height
                    properties:
                      units:
                        type: string
                        enum:
                          - inches
                          - centimeters
                        description: Unit of dimensional measurement
                      length:
                        type: number
                        format: float
                        description: Length of the package
                      width:
                        type: number
                        format: float
                        description: Width of the package
                      height:
                        type: number
                        format: float
                        description: Height of the package
                  items:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the shipment item
                        shipment_id:
                          type: integer
                          description: ID of the parent shipment
                        product_id:
                          type: integer
                          description: ID of the product being shipped
                        sales_order_item_id:
                          type: integer
                          description: 'Luminous sales order line-item ID (the internal item primary key) for the line being shipped. This is the value to pass back as `order_item_id` when creating a shipment for this order. For kit/bundle component lines that share a single upstream channel line, each component is still returned with its own distinct `sales_order_item_id`.'
                        quantity:
                          type: number
                          description: 'Quantity being shipped, expressed in the same unit of measure the associated sales order line was ordered in (the selling UoM, e.g. cartons) rather than internal base units. When the originating order line cannot be resolved, the stored quantity is returned as-is.'
                        weight:
                          type: object
                          required:
                            - value
                            - units
                          properties:
                            value:
                              type: number
                              format: float
                              description: Weight value
                            units:
                              type: string
                              enum:
                                - ounces
                                - pounds
                                - grams
                                - kilograms
                              description: Unit of weight measurement
                        unit_price:
                          type: number
                          format: float
                          description: Price per unit
                        lot_id:
                          type: integer
                          nullable: true
                          description: ID of the lot this shipment item was deducted from (CS-10083). `null` when the line has no lot. Populated from the `lot_id` submitted on shipment create; Luminous no longer re-infers a lot by FEFO/FIFO once a lot is named.
                        lot_number:
                          type: string
                          nullable: true
                          description: 'Lot number stamped on the item, falling back to the referenced lot''s number when only `lot_id` was submitted. `null` when the line has no lot.'
                        expiry_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Expiry date of the lot (`YYYY-MM-DD`), falling back to the referenced lot. `null` when the line has no lot.'
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the item was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the item was last updated
                    description: Items included in this shipment
                  created_at:
                    type: string
                    format: date-time
                    description: Timestamp when the shipment was created
                  updated_at:
                    type: string
                    format: date-time
                    description: Timestamp when the shipment was last updated
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/custom-fields':
    put:
      operationId: setFulfillmentOrderCustomFields
      tags:
        - Fulfillment Orders
      summary: Set custom field values on a fulfillment order
      description: |
        Sets one or more custom field values on a fulfillment order. Each key in the
        `fields` object must match the **label** of a pre-configured `CustomField`
        definition that is set up for `FulfillmentOrder` records.

        **Unlike** the tote-ID endpoint, this endpoint does **not** auto-create
        field definitions — tenants must configure them in advance under
        Settings → Custom Fields.

        When `set_on_sales_order=true`, the same field values are also written to the
        associated sales order (if a matching `SalesOrder` custom field definition exists).

        Returns **404** if any label has no matching definition, or the matched
        definition isn't configured for the target record type.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: Fulfillment order ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - fields
              properties:
                fields:
                  type: object
                  minProperties: 1
                  description: |
                    Map of custom field label → value. The label must exactly match a
                    pre-configured `CustomField` definition for `FulfillmentOrder`.
                  additionalProperties: {}
                  example:
                    Tote ID: TOTE-001
                    Priority: High
                set_on_sales_order:
                  type: boolean
                  default: false
                  description: |
                    When `true`, also write the same field values to the associated
                    sales order (requires matching definitions on `SalesOrder`).
      responses:
        '200':
          description: Custom fields set successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  data:
                    type: object
                    properties:
                      fulfillment_order_id:
                        type: integer
                      sales_order_id:
                        type: integer
                        nullable: true
                      order_key:
                        type: string
                        nullable: true
                      set_on_sales_order:
                        type: boolean
                      fields:
                        type: object
                        additionalProperties: {}
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Fulfillment order not found, or no custom field definition matches a given label'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Type validation error (e.g. invalid dropdown option)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/push-readiness':
    get:
      operationId: getFulfillmentOrderPushReadiness
      tags:
        - Fulfillment Orders
      summary: Check fulfillment-order push readiness
      description: |
        Structured pre-push checklist for a fulfillment order. Evaluates, without pushing:

        - **OMS product mapping** per line item — whether each SKU resolves to a product in
          the destination OMS.
        - **Address blockers** — missing `ship_to.postal_code` / `ship_to.state`, or fields
          the destination mapping preview flags as required.
        - **Channel restriction eligibility** — whether the fulfillment channel's restriction
          rules would allow this order.

        Use this before calling `POST /fulfillment-orders/{id}/push` to identify what needs
        fixing. The `resolution_hints` array suggests the next API calls to make.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      responses:
        '200':
          description: Push-readiness assessment
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      ready:
                        type: boolean
                        description: 'True when all lines are mapped, there are no address issues, and channel restrictions pass.'
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Target integration account.
                      mapping_id:
                        type: integer
                        nullable: true
                        description: PUSH_ORDERS integration mapping from the fulfillment channel (if attached).
                      line_items:
                        type: array
                        items:
                          type: object
                          properties:
                            sku:
                              type: string
                            lum_product_id:
                              type: integer
                              nullable: true
                            oms_mapped:
                              type: boolean
                            remote_reference_identifier:
                              type: string
                              description: Present when the line is mapped to an OMS product.
                            issue:
                              type: string
                              description: Present when the line is not mapped.
                              example: not_mapped_to_oms
                      address_issues:
                        type: array
                        items:
                          type: object
                          properties:
                            field:
                              type: string
                              example: ship_to.postal_code
                            issue:
                              type: string
                              enum:
                                - missing
                                - required_by_destination
                      channel_restriction:
                        type: object
                        properties:
                          eligible:
                            type: boolean
                          message:
                            type: string
                            nullable: true
                          reason_code:
                            type: string
                            nullable: true
                      resolution_hints:
                        type: array
                        description: Suggested next API calls to resolve the issues found.
                        items:
                          type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/activity-logs':
    get:
      operationId: getFulfillmentOrderActivityLogs
      tags:
        - Fulfillment Orders
      summary: List fulfillment-order activity logs
      description: |
        Paginated activity timeline scoped to a single fulfillment order (audit trail of
        changes, pushes, errors, and system events). The subject is fixed to this fulfillment
        order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
        - in: query
          name: page
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
        - in: query
          name: limit
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 25
          description: Entries per page (max 50).
        - in: query
          name: user_type
          required: false
          schema:
            type: string
            enum:
              - user
              - system
          description: Filter to human (`user`) or automated (`system`) activity.
        - in: query
          name: date_sort
          required: false
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
          description: Sort direction by created date.
      responses:
        '200':
          description: Activity log entries (paginated)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                  links:
                    type: object
                    additionalProperties: true
                  meta:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/push-preview':
    post:
      operationId: previewFulfillmentOrderPush
      tags:
        - Fulfillment Orders
      summary: Preview fulfillment-order push mapping
      description: |
        Fulfillment-order-scoped mapping preview. Resolves the PUSH_ORDERS integration mapping
        from the fulfillment order's fulfillment channel and renders the output that *would* be
        sent to the destination OMS — without pushing.

        Optionally send an unsaved `mapping_config` draft to preview changes before saving them.
        Useful for diagnosing why a push is producing empty or invalid fields.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                mapping_config:
                  type: array
                  description: |
                    Optional unsaved draft mapping to preview instead of the saved mapping.
                    Each entry must include a `pushField`.
                  items:
                    type: object
                    required:
                      - pushField
                    properties:
                      pushField:
                        type: string
                    additionalProperties: true
      responses:
        '200':
          description: Mapping preview
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      mapping_id:
                        type: integer
                        description: The resolved PUSH_ORDERS integration mapping id.
                      output:
                        description: The rendered mapping output that would be pushed.
                        additionalProperties: true
                      rows:
                        type: array
                        description: Per-field mapping rows with resolved values and status.
                        items:
                          type: object
                          additionalProperties: true
                      summary:
                        type: object
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            The fulfillment channel has no PUSH_ORDERS integration mapping attached, or the
            provided `mapping_config` is invalid.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/repair-and-push':
    post:
      operationId: repairAndPushFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Repair address and push fulfillment order
      description: |
        Harness-safe recovery action for a fulfillment order that failed to push because of
        address gaps (e.g. a UAE/Israel-style order missing `postal_code` or `state`). In one
        call it will:

        1. Apply the supplied `ship_to` fields to the fulfillment order (merged onto the
           existing address), optionally mirroring them to the sales order.
        2. Clear the `error_message` and reset an `Error` status back to `planned`.
        3. Unpush the order first if it was already pushed (`pushed_at` set).
        4. Push the order to its destination OMS.

        Cannot repair a fulfillment order in a terminal status, or one that already has a
        picklist.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                ship_to:
                  type: object
                  description: Address fields to apply (snake_case). Omitted fields are left unchanged.
                  properties:
                    postal_code:
                      type: string
                      nullable: true
                    state:
                      type: string
                      nullable: true
                    city:
                      type: string
                      nullable: true
                    country:
                      type: string
                      nullable: true
                    street1:
                      type: string
                      nullable: true
                    street2:
                      type: string
                      nullable: true
                sync_ship_to_to_sales_order:
                  type: boolean
                  default: false
                  description: 'When true, also write the repaired `ship_to` to the sales order.'
                debug:
                  type: boolean
                  default: false
                  description: 'When true, capture and return outbound OMS HTTP traffic in `data.debug`.'
      responses:
        '200':
          description: Repair and push completed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: true
                      message:
                        type: string
                        example: Repair and push completed.
                      repaired_fields:
                        type: object
                        description: 'The fields that were changed during repair (e.g. `ship_to`, `error_message`, `unpushed`).'
                        additionalProperties: true
                      push:
                        type: object
                        properties:
                          success:
                            type: boolean
                          message:
                            type: string
                          data:
                            type: object
                            additionalProperties: true
                      debug:
                        type: object
                        description: Present only when `debug=true` was sent.
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Repair or push failed — e.g. the fulfillment order is in a terminal status, has a
            picklist, unpush failed, or the OMS rejected the push. The `data.success` field is
            `false`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        example: false
                      message:
                        type: string
                      repaired_fields:
                        type: object
                        additionalProperties: true
  '/fulfillment-orders/{fulfillmentOrderId}/notes':
    patch:
      operationId: updateFulfillmentOrderNotes
      tags:
        - Fulfillment Orders
      summary: Update fulfillment order notes
      description: |
        Update the customer-facing and/or internal notes on a fulfillment order. Send either
        field on its own to change one without clobbering the other; send `null` to clear a
        note. At least one of the two fields must be present, or the request is rejected.

        Returns the updated fulfillment order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customer_notes:
                  type: string
                  nullable: true
                  description: Customer-facing notes. Send `null` to clear.
                internal_notes:
                  type: string
                  nullable: true
                  description: Internal notes. Send `null` to clear.
      responses:
        '200':
          description: Notes updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Fulfillment order ID
                      order_number:
                        type: string
                        description: Fulfillment order number
                      order_key:
                        type: string
                        nullable: true
                        description: Fulfillment order key
                      order_status:
                        type: string
                        description: Fulfillment order status
                      sales_order_id:
                        type: integer
                        description: Associated sales order ID
                      warehouse_group_id:
                        type: integer
                        nullable: true
                        description: Warehouse group ID
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination app integration account ID
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                      pushed_at:
                        type: string
                        format: date-time
                        nullable: true
                      packing_slip_printed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                      error_message:
                        type: string
                        nullable: true
                        description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                      ship_by_date:
                        type: string
                        format: date
                        nullable: true
                        description: Ship by date
                      total:
                        type: number
                        format: float
                        nullable: true
                        description: Order total
                      bill_to:
                        type: object
                        nullable: true
                        description: Billing address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      invoice_to:
                        type: object
                        nullable: true
                        description: Invoice address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      sales_order:
                        type: object
                        nullable: true
                        description: Nested sales order data
                      picklists:
                        type: array
                        description: Associated picklists
                        items:
                          type: object
                      fulfillment_order_items:
                        type: array
                        description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Fulfillment order line ID. `null` for synthetic kit component rows.
                            shipment_id:
                              type: integer
                              nullable: true
                              description: ID of the fulfillment order this line belongs to.
                            status:
                              nullable: true
                              description: Line status.
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                            product_id:
                              type: integer
                              nullable: true
                              description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                            sku:
                              type: string
                              nullable: true
                            name:
                              type: string
                              nullable: true
                            weight:
                              nullable: true
                              description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                            dimensions:
                              nullable: true
                              description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                            quantity:
                              type: number
                              description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                            unit_price:
                              type: number
                              description: Unit price. Always `0` on synthetic component rows.
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              nullable: true
                              description: Lot expiry date.
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            is_kit_component:
                              type: boolean
                              description: True when the row is a component of a kit (stored or synthetic).
                            parent_fulfillment_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                            kit_sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                            is_synthetic:
                              type: boolean
                              description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                      total_weight:
                        type: object
                        nullable: true
                        description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                        properties:
                          total_oz:
                            type: number
                            format: float
                            description: Total weight in ounces
                          total_lb:
                            type: number
                            format: float
                            description: Total weight in pounds
                          line_count:
                            type: integer
                            description: Number of fulfillment order lines
                          weighed_line_count:
                            type: integer
                            description: Number of lines that had a usable weight and contributed to the total
                          is_complete:
                            type: boolean
                            description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                      tags:
                        type: array
                        description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      purchase_orders:
                        type: array
                        description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                              enum:
                                - active
                                - deleted
                                - completed
                      source_reference_identifier:
                        type: string
                        nullable: true
                        description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                      held_for_item_change:
                        type: boolean
                        description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                      created_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: No writable field was supplied
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/tags':
    get:
      operationId: getFulfillmentOrderTags
      tags:
        - Fulfillment Orders
      summary: Get tags on a fulfillment order
      description: |
        Retrieve the tags attached directly to this fulfillment order.

        A fulfillment order may also display tags inherited from its parent sales
        order in the UI; those are not included here and cannot be removed through
        this endpoint. Only the fulfillment order's own tags are returned.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: Fulfillment order ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the tag
                        name:
                          type: string
                          description: Name of the tag
                        description:
                          type: string
                          nullable: true
                          description: Description of the tag
                        icon:
                          type: string
                          nullable: true
                          description: Icon identifier or URL for the tag
                        color:
                          type: string
                          nullable: true
                          description: Color code for the tag
                      required:
                        - id
                        - name
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: attachFulfillmentOrderTag
      tags:
        - Fulfillment Orders
      summary: Attach tag(s) to a fulfillment order
      description: |
        Attach one or more tags to a fulfillment order. Existing tags are not
        removed — use `PUT` to replace the full tag set.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: Fulfillment order ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              oneOf:
                - required:
                    - tag
                  properties:
                    tag:
                      type: string
                      description: Single tag name to attach
                - required:
                    - tags
                  properties:
                    tags:
                      type: array
                      items:
                        type: string
                      description: Multiple tag names to attach
      responses:
        '201':
          description: Tag(s) attached successfully
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: replaceFulfillmentOrderTags
      tags:
        - Fulfillment Orders
      summary: Replace all tags on a fulfillment order
      description: |
        Replace the entire tag set on a fulfillment order with the provided list.
        Tags not in the new list are removed; tags already present that are in the
        list are kept. Send an empty array to clear all tags.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: Fulfillment order ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - tags
              properties:
                tags:
                  type: array
                  items:
                    type: string
                  description: New complete set of tag names
      responses:
        '200':
          description: Tags replaced successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Tags replaced successfully
                  tags:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the tag
                        name:
                          type: string
                          description: Name of the tag
                        description:
                          type: string
                          nullable: true
                          description: Description of the tag
                        icon:
                          type: string
                          nullable: true
                          description: Icon identifier or URL for the tag
                        color:
                          type: string
                          nullable: true
                          description: Color code for the tag
                      required:
                        - id
                        - name
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/tags/{tag}':
    delete:
      operationId: detachFulfillmentOrderTag
      tags:
        - Fulfillment Orders
      summary: Detach a tag from a fulfillment order
      description: |
        Remove a specific tag from a fulfillment order by tag name or ID. Only tags
        attached directly to the fulfillment order can be removed; tags inherited
        from the parent sales order will silently do nothing.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: Fulfillment order ID
        - in: path
          name: tag
          required: true
          schema:
            oneOf:
              - type: string
              - type: integer
          description: Tag name or ID to detach
      responses:
        '204':
          description: Tag detached successfully
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order or tag not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/hold':
    post:
      operationId: holdFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Hold fulfillment order
      description: |
        Put a fulfillment order on hold. The order must be in a state from which a hold is
        allowed; otherwise the request is rejected with `422` and a message explaining why the
        transition was refused.

        Returns the updated fulfillment order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      responses:
        '200':
          description: Fulfillment order placed on hold
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Fulfillment order ID
                      order_number:
                        type: string
                        description: Fulfillment order number
                      order_key:
                        type: string
                        nullable: true
                        description: Fulfillment order key
                      order_status:
                        type: string
                        description: Fulfillment order status
                      sales_order_id:
                        type: integer
                        description: Associated sales order ID
                      warehouse_group_id:
                        type: integer
                        nullable: true
                        description: Warehouse group ID
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination app integration account ID
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                      pushed_at:
                        type: string
                        format: date-time
                        nullable: true
                      packing_slip_printed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                      error_message:
                        type: string
                        nullable: true
                        description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                      ship_by_date:
                        type: string
                        format: date
                        nullable: true
                        description: Ship by date
                      total:
                        type: number
                        format: float
                        nullable: true
                        description: Order total
                      bill_to:
                        type: object
                        nullable: true
                        description: Billing address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      invoice_to:
                        type: object
                        nullable: true
                        description: Invoice address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      sales_order:
                        type: object
                        nullable: true
                        description: Nested sales order data
                      picklists:
                        type: array
                        description: Associated picklists
                        items:
                          type: object
                      fulfillment_order_items:
                        type: array
                        description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Fulfillment order line ID. `null` for synthetic kit component rows.
                            shipment_id:
                              type: integer
                              nullable: true
                              description: ID of the fulfillment order this line belongs to.
                            status:
                              nullable: true
                              description: Line status.
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                            product_id:
                              type: integer
                              nullable: true
                              description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                            sku:
                              type: string
                              nullable: true
                            name:
                              type: string
                              nullable: true
                            weight:
                              nullable: true
                              description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                            dimensions:
                              nullable: true
                              description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                            quantity:
                              type: number
                              description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                            unit_price:
                              type: number
                              description: Unit price. Always `0` on synthetic component rows.
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              nullable: true
                              description: Lot expiry date.
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            is_kit_component:
                              type: boolean
                              description: True when the row is a component of a kit (stored or synthetic).
                            parent_fulfillment_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                            kit_sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                            is_synthetic:
                              type: boolean
                              description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                      total_weight:
                        type: object
                        nullable: true
                        description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                        properties:
                          total_oz:
                            type: number
                            format: float
                            description: Total weight in ounces
                          total_lb:
                            type: number
                            format: float
                            description: Total weight in pounds
                          line_count:
                            type: integer
                            description: Number of fulfillment order lines
                          weighed_line_count:
                            type: integer
                            description: Number of lines that had a usable weight and contributed to the total
                          is_complete:
                            type: boolean
                            description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                      tags:
                        type: array
                        description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      purchase_orders:
                        type: array
                        description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                              enum:
                                - active
                                - deleted
                                - completed
                      source_reference_identifier:
                        type: string
                        nullable: true
                        description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                      held_for_item_change:
                        type: boolean
                        description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                      created_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The order cannot be held from its current state
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/release':
    post:
      operationId: releaseFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Release fulfillment order from hold
      description: |
        Release a fulfillment order from hold, returning it to pending. The order must be on
        hold; otherwise the request is rejected with `422` and a message explaining why the
        transition was refused.

        Returns the updated fulfillment order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      responses:
        '200':
          description: Fulfillment order released
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Fulfillment order ID
                      order_number:
                        type: string
                        description: Fulfillment order number
                      order_key:
                        type: string
                        nullable: true
                        description: Fulfillment order key
                      order_status:
                        type: string
                        description: Fulfillment order status
                      sales_order_id:
                        type: integer
                        description: Associated sales order ID
                      warehouse_group_id:
                        type: integer
                        nullable: true
                        description: Warehouse group ID
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination app integration account ID
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                      pushed_at:
                        type: string
                        format: date-time
                        nullable: true
                      packing_slip_printed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                      error_message:
                        type: string
                        nullable: true
                        description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                      ship_by_date:
                        type: string
                        format: date
                        nullable: true
                        description: Ship by date
                      total:
                        type: number
                        format: float
                        nullable: true
                        description: Order total
                      bill_to:
                        type: object
                        nullable: true
                        description: Billing address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      invoice_to:
                        type: object
                        nullable: true
                        description: Invoice address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      sales_order:
                        type: object
                        nullable: true
                        description: Nested sales order data
                      picklists:
                        type: array
                        description: Associated picklists
                        items:
                          type: object
                      fulfillment_order_items:
                        type: array
                        description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Fulfillment order line ID. `null` for synthetic kit component rows.
                            shipment_id:
                              type: integer
                              nullable: true
                              description: ID of the fulfillment order this line belongs to.
                            status:
                              nullable: true
                              description: Line status.
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                            product_id:
                              type: integer
                              nullable: true
                              description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                            sku:
                              type: string
                              nullable: true
                            name:
                              type: string
                              nullable: true
                            weight:
                              nullable: true
                              description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                            dimensions:
                              nullable: true
                              description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                            quantity:
                              type: number
                              description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                            unit_price:
                              type: number
                              description: Unit price. Always `0` on synthetic component rows.
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              nullable: true
                              description: Lot expiry date.
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            is_kit_component:
                              type: boolean
                              description: True when the row is a component of a kit (stored or synthetic).
                            parent_fulfillment_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                            kit_sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                            is_synthetic:
                              type: boolean
                              description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                      total_weight:
                        type: object
                        nullable: true
                        description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                        properties:
                          total_oz:
                            type: number
                            format: float
                            description: Total weight in ounces
                          total_lb:
                            type: number
                            format: float
                            description: Total weight in pounds
                          line_count:
                            type: integer
                            description: Number of fulfillment order lines
                          weighed_line_count:
                            type: integer
                            description: Number of lines that had a usable weight and contributed to the total
                          is_complete:
                            type: boolean
                            description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                      tags:
                        type: array
                        description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      purchase_orders:
                        type: array
                        description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                              enum:
                                - active
                                - deleted
                                - completed
                      source_reference_identifier:
                        type: string
                        nullable: true
                        description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                      held_for_item_change:
                        type: boolean
                        description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                      created_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The order cannot be released from its current state
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/cancel':
    post:
      operationId: cancelFulfillmentOrder
      tags:
        - Fulfillment Orders
      summary: Cancel fulfillment order
      description: |
        Cancel a fulfillment order. The order must be in a state from which cancellation is
        allowed; otherwise the request is rejected with `422` and a message explaining why the
        transition was refused.

        A `partially_shipped` order can be cancelled only when nothing on it actually shipped
        (no live shipment covers any of its lines and no line has a shipped quantity). Once any
        line has shipped, the request is rejected with `422` and the message
        `Fulfillment order has shipped lines and cannot be cancelled.`

        Returns the updated fulfillment order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      responses:
        '200':
          description: Fulfillment order cancelled
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Fulfillment order ID
                      order_number:
                        type: string
                        description: Fulfillment order number
                      order_key:
                        type: string
                        nullable: true
                        description: Fulfillment order key
                      order_status:
                        type: string
                        description: Fulfillment order status
                      sales_order_id:
                        type: integer
                        description: Associated sales order ID
                      warehouse_group_id:
                        type: integer
                        nullable: true
                        description: Warehouse group ID
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination app integration account ID
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                      pushed_at:
                        type: string
                        format: date-time
                        nullable: true
                      packing_slip_printed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                      error_message:
                        type: string
                        nullable: true
                        description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                      ship_by_date:
                        type: string
                        format: date
                        nullable: true
                        description: Ship by date
                      total:
                        type: number
                        format: float
                        nullable: true
                        description: Order total
                      bill_to:
                        type: object
                        nullable: true
                        description: Billing address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      invoice_to:
                        type: object
                        nullable: true
                        description: Invoice address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      sales_order:
                        type: object
                        nullable: true
                        description: Nested sales order data
                      picklists:
                        type: array
                        description: Associated picklists
                        items:
                          type: object
                      fulfillment_order_items:
                        type: array
                        description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Fulfillment order line ID. `null` for synthetic kit component rows.
                            shipment_id:
                              type: integer
                              nullable: true
                              description: ID of the fulfillment order this line belongs to.
                            status:
                              nullable: true
                              description: Line status.
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                            product_id:
                              type: integer
                              nullable: true
                              description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                            sku:
                              type: string
                              nullable: true
                            name:
                              type: string
                              nullable: true
                            weight:
                              nullable: true
                              description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                            dimensions:
                              nullable: true
                              description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                            quantity:
                              type: number
                              description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                            unit_price:
                              type: number
                              description: Unit price. Always `0` on synthetic component rows.
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              nullable: true
                              description: Lot expiry date.
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            is_kit_component:
                              type: boolean
                              description: True when the row is a component of a kit (stored or synthetic).
                            parent_fulfillment_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                            kit_sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                            is_synthetic:
                              type: boolean
                              description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                      total_weight:
                        type: object
                        nullable: true
                        description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                        properties:
                          total_oz:
                            type: number
                            format: float
                            description: Total weight in ounces
                          total_lb:
                            type: number
                            format: float
                            description: Total weight in pounds
                          line_count:
                            type: integer
                            description: Number of fulfillment order lines
                          weighed_line_count:
                            type: integer
                            description: Number of lines that had a usable weight and contributed to the total
                          is_complete:
                            type: boolean
                            description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                      tags:
                        type: array
                        description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      purchase_orders:
                        type: array
                        description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                              enum:
                                - active
                                - deleted
                                - completed
                      source_reference_identifier:
                        type: string
                        nullable: true
                        description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                      held_for_item_change:
                        type: boolean
                        description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                      created_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'The order cannot be cancelled from its current state, or it is `partially_shipped` and at least one line has shipped'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/mark-shipped':
    post:
      operationId: markFulfillmentOrderShipped
      tags:
        - Fulfillment Orders
      summary: Mark fulfillment order as shipped
      description: |
        Mark a fulfillment order as shipped, optionally recording carrier details. This mints
        the shipment through the same path the web app uses, so it carries the existing
        transition checks — if the order cannot be shipped from its current state the request
        is rejected with `422`.

        The request is also rejected with `422`, and the order's status is left unchanged, when:

        - the order's sales order is not posted yet (`Sales order is not posted yet; mark it
          shipped once the sales order posts.`), or
        - no shipment was actually created for any of the order's shippable lines (`No shipment
          was created, so the fulfillment order was not marked shipped.`). Orders with no
          shippable (physical, uncancelled) lines are still marked shipped as before.

        **Lines already shipped on the sales order.** When the order's sales order is already
        shipped and every line this order still has open was fully shipped on that sales order
        by a live shipment bound to another fulfillment order (for example, a split channel
        order's sibling), the order is closed **without creating a new shipment** and with no
        on-hand change: only those open lines are marked shipped and have their pending
        quantity released. `tracking_number` and `carrier_code` are ignored in this case. This
        path does not apply when the order has been pushed to a warehouse, carries lines of
        another sales order, or has a line its own shipment shipped only in part — those go
        through the normal manual-shipment path. If the close fails, the request is rejected
        with `422` (`The fulfillment order could not be closed. Please try again or contact
        support.`).

        Returns the updated fulfillment order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                tracking_number:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Carrier tracking number to record on the shipment.
                carrier_code:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Carrier code to record on the shipment.
      responses:
        '200':
          description: Fulfillment order marked as shipped
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Fulfillment order ID
                      order_number:
                        type: string
                        description: Fulfillment order number
                      order_key:
                        type: string
                        nullable: true
                        description: Fulfillment order key
                      order_status:
                        type: string
                        description: Fulfillment order status
                      sales_order_id:
                        type: integer
                        description: Associated sales order ID
                      warehouse_group_id:
                        type: integer
                        nullable: true
                        description: Warehouse group ID
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination app integration account ID
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                      pushed_at:
                        type: string
                        format: date-time
                        nullable: true
                      packing_slip_printed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                      error_message:
                        type: string
                        nullable: true
                        description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                      ship_by_date:
                        type: string
                        format: date
                        nullable: true
                        description: Ship by date
                      total:
                        type: number
                        format: float
                        nullable: true
                        description: Order total
                      bill_to:
                        type: object
                        nullable: true
                        description: Billing address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      invoice_to:
                        type: object
                        nullable: true
                        description: Invoice address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      sales_order:
                        type: object
                        nullable: true
                        description: Nested sales order data
                      picklists:
                        type: array
                        description: Associated picklists
                        items:
                          type: object
                      fulfillment_order_items:
                        type: array
                        description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Fulfillment order line ID. `null` for synthetic kit component rows.
                            shipment_id:
                              type: integer
                              nullable: true
                              description: ID of the fulfillment order this line belongs to.
                            status:
                              nullable: true
                              description: Line status.
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                            product_id:
                              type: integer
                              nullable: true
                              description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                            sku:
                              type: string
                              nullable: true
                            name:
                              type: string
                              nullable: true
                            weight:
                              nullable: true
                              description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                            dimensions:
                              nullable: true
                              description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                            quantity:
                              type: number
                              description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                            unit_price:
                              type: number
                              description: Unit price. Always `0` on synthetic component rows.
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              nullable: true
                              description: Lot expiry date.
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            is_kit_component:
                              type: boolean
                              description: True when the row is a component of a kit (stored or synthetic).
                            parent_fulfillment_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                            kit_sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                            is_synthetic:
                              type: boolean
                              description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                      total_weight:
                        type: object
                        nullable: true
                        description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                        properties:
                          total_oz:
                            type: number
                            format: float
                            description: Total weight in ounces
                          total_lb:
                            type: number
                            format: float
                            description: Total weight in pounds
                          line_count:
                            type: integer
                            description: Number of fulfillment order lines
                          weighed_line_count:
                            type: integer
                            description: Number of lines that had a usable weight and contributed to the total
                          is_complete:
                            type: boolean
                            description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                      tags:
                        type: array
                        description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      purchase_orders:
                        type: array
                        description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                              enum:
                                - active
                                - deleted
                                - completed
                      source_reference_identifier:
                        type: string
                        nullable: true
                        description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                      held_for_item_change:
                        type: boolean
                        description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                      created_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'The order cannot be marked shipped from its current state, its sales order is not posted, or no shipment was created'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/status':
    put:
      operationId: updateFulfillmentOrderStatus
      tags:
        - Fulfillment Orders
      summary: Set fulfillment order status
      description: |
        Set a fulfillment order's status. Intended for external systems (for example a 3PL or
        file-based fulfillment partner) that report back what happened to an order. Three
        statuses are accepted:

        - `awaiting_shipment` — records that the order was sent to the fulfillment partner. No
          shipment is created, and the order leaves the `pending` queue.
        - `shipped` — records a shipment with the given tracking number, carrier and ship date.
          The shipment is created first; if it cannot be created the request fails with `400`
          (`Failed to create shipment: ...`) and the order's status is left unchanged. When some
          shippable lines end up without a shipment, the order is set to `partially_shipped`
          instead of `shipped`.
        - `cancelled` — cancels the order through the same path as other cancellations.

        The status is written as given; unlike `POST /fulfillment-orders/{fulfillmentOrderId}/mark-shipped`,
        this endpoint does not check the order's current status first.

        Returns the updated fulfillment order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - order_status
              properties:
                order_status:
                  type: string
                  enum:
                    - awaiting_shipment
                    - shipped
                    - cancelled
                  description: Status to set.
                tracking_number:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Carrier tracking number. Required when `order_status` is `shipped`.
                carrier_code:
                  type: string
                  nullable: true
                  maxLength: 255
                  description: Carrier code. Required when `order_status` is `shipped`.
                ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: 'Date the shipment left, `Y-m-d`. Required when `order_status` is `shipped`.'
                  example: '2026-11-05'
            examples:
              sent:
                summary: Mark the order sent
                value:
                  order_status: awaiting_shipment
              shipped:
                summary: Mark the order shipped
                value:
                  order_status: shipped
                  tracking_number: 1Z999AA10123456784
                  carrier_code: ups
                  ship_date: '2026-11-05'
      responses:
        '200':
          description: Fulfillment order status updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Fulfillment order ID
                      order_number:
                        type: string
                        description: Fulfillment order number
                      order_key:
                        type: string
                        nullable: true
                        description: Fulfillment order key
                      order_status:
                        type: string
                        description: Fulfillment order status
                      sales_order_id:
                        type: integer
                        description: Associated sales order ID
                      warehouse_group_id:
                        type: integer
                        nullable: true
                        description: Warehouse group ID
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination app integration account ID
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                      pushed_at:
                        type: string
                        format: date-time
                        nullable: true
                      packing_slip_printed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                      error_message:
                        type: string
                        nullable: true
                        description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                      ship_by_date:
                        type: string
                        format: date
                        nullable: true
                        description: Ship by date
                      total:
                        type: number
                        format: float
                        nullable: true
                        description: Order total
                      bill_to:
                        type: object
                        nullable: true
                        description: Billing address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      invoice_to:
                        type: object
                        nullable: true
                        description: Invoice address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      sales_order:
                        type: object
                        nullable: true
                        description: Nested sales order data
                      picklists:
                        type: array
                        description: Associated picklists
                        items:
                          type: object
                      fulfillment_order_items:
                        type: array
                        description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Fulfillment order line ID. `null` for synthetic kit component rows.
                            shipment_id:
                              type: integer
                              nullable: true
                              description: ID of the fulfillment order this line belongs to.
                            status:
                              nullable: true
                              description: Line status.
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                            product_id:
                              type: integer
                              nullable: true
                              description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                            sku:
                              type: string
                              nullable: true
                            name:
                              type: string
                              nullable: true
                            weight:
                              nullable: true
                              description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                            dimensions:
                              nullable: true
                              description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                            quantity:
                              type: number
                              description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                            unit_price:
                              type: number
                              description: Unit price. Always `0` on synthetic component rows.
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              nullable: true
                              description: Lot expiry date.
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            is_kit_component:
                              type: boolean
                              description: True when the row is a component of a kit (stored or synthetic).
                            parent_fulfillment_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                            kit_sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                            is_synthetic:
                              type: boolean
                              description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                      total_weight:
                        type: object
                        nullable: true
                        description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                        properties:
                          total_oz:
                            type: number
                            format: float
                            description: Total weight in ounces
                          total_lb:
                            type: number
                            format: float
                            description: Total weight in pounds
                          line_count:
                            type: integer
                            description: Number of fulfillment order lines
                          weighed_line_count:
                            type: integer
                            description: Number of lines that had a usable weight and contributed to the total
                          is_complete:
                            type: boolean
                            description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                      tags:
                        type: array
                        description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      purchase_orders:
                        type: array
                        description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                              enum:
                                - active
                                - deleted
                                - completed
                      source_reference_identifier:
                        type: string
                        nullable: true
                        description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                      held_for_item_change:
                        type: boolean
                        description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                      created_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was last updated
        '400':
          description: 'The shipment could not be created (status left unchanged), or the order could not be updated'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error — `order_status` missing or not one of the accepted values, or `tracking_number`, `carrier_code` or `ship_date` missing when `order_status` is `shipped`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/ship-by-date':
    patch:
      operationId: updateFulfillmentOrderShipByDate
      tags:
        - Fulfillment Orders
      summary: Update ship-by date
      description: |
        Change a fulfillment order's ship-by date. The date is stored as a UTC instant (send an ISO-8601
        timestamp; a bare date is treated as midnight UTC).

        Same rule as the web app's bulk update: an order already pushed to its warehouse, shipped or
        cancelled is not changed — that case is a `422` here rather than a silent no-op. Re-sending the
        same date is not an error.

        Returns the updated fulfillment order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ship_by_date
              properties:
                ship_by_date:
                  type: string
                  format: date-time
                  description: 'New ship-by date/time, e.g. `2026-10-22T18:00:00.000Z`.'
      responses:
        '200':
          description: Ship-by date updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Fulfillment order ID
                      order_number:
                        type: string
                        description: Fulfillment order number
                      order_key:
                        type: string
                        nullable: true
                        description: Fulfillment order key
                      order_status:
                        type: string
                        description: Fulfillment order status
                      sales_order_id:
                        type: integer
                        description: Associated sales order ID
                      warehouse_group_id:
                        type: integer
                        nullable: true
                        description: Warehouse group ID
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Destination app integration account ID
                      destination_oms_store_id:
                        type: integer
                        nullable: true
                      fulfillment_channel_id:
                        type: integer
                        nullable: true
                      pushed_at:
                        type: string
                        format: date-time
                        nullable: true
                      packing_slip_printed_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                      error_message:
                        type: string
                        nullable: true
                        description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                      ship_by_date:
                        type: string
                        format: date
                        nullable: true
                        description: Ship by date
                      total:
                        type: number
                        format: float
                        nullable: true
                        description: Order total
                      bill_to:
                        type: object
                        nullable: true
                        description: Billing address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      ship_to:
                        type: object
                        nullable: true
                        description: Shipping address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      invoice_to:
                        type: object
                        nullable: true
                        description: Invoice address
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          street1:
                            type: string
                          street2:
                            type: string
                          street3:
                            type: string
                          city:
                            type: string
                          state:
                            type: string
                          postal_code:
                            type: string
                          country:
                            type: string
                          phone:
                            type: string
                      sales_order:
                        type: object
                        nullable: true
                        description: Nested sales order data
                      picklists:
                        type: array
                        description: Associated picklists
                        items:
                          type: object
                      fulfillment_order_items:
                        type: array
                        description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              nullable: true
                              description: Fulfillment order line ID. `null` for synthetic kit component rows.
                            shipment_id:
                              type: integer
                              nullable: true
                              description: ID of the fulfillment order this line belongs to.
                            status:
                              nullable: true
                              description: Line status.
                            sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                            product_id:
                              type: integer
                              nullable: true
                              description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                            sku:
                              type: string
                              nullable: true
                            name:
                              type: string
                              nullable: true
                            weight:
                              nullable: true
                              description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                            dimensions:
                              nullable: true
                              description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                            quantity:
                              type: number
                              description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                            unit_price:
                              type: number
                              description: Unit price. Always `0` on synthetic component rows.
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              nullable: true
                              description: Lot expiry date.
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            is_kit_component:
                              type: boolean
                              description: True when the row is a component of a kit (stored or synthetic).
                            parent_fulfillment_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                            kit_sales_order_item_id:
                              type: integer
                              nullable: true
                              description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                            is_synthetic:
                              type: boolean
                              description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                      total_weight:
                        type: object
                        nullable: true
                        description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                        properties:
                          total_oz:
                            type: number
                            format: float
                            description: Total weight in ounces
                          total_lb:
                            type: number
                            format: float
                            description: Total weight in pounds
                          line_count:
                            type: integer
                            description: Number of fulfillment order lines
                          weighed_line_count:
                            type: integer
                            description: Number of lines that had a usable weight and contributed to the total
                          is_complete:
                            type: boolean
                            description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                      tags:
                        type: array
                        description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      purchase_orders:
                        type: array
                        description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            order_status:
                              type: string
                              nullable: true
                              enum:
                                - active
                                - deleted
                                - completed
                      source_reference_identifier:
                        type: string
                        nullable: true
                        description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                      held_for_item_change:
                        type: boolean
                        description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                      created_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was created
                      updated_at:
                        type: string
                        format: date-time
                        description: When the fulfillment order was last updated
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Missing/invalid `ship_by_date`, or the order is already pushed, shipped or cancelled'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: 'The ship-by date cannot change once the order is pushed to its warehouse, shipped or cancelled.'
  '/fulfillment-orders/{fulfillmentOrderId}/freight/defaults':
    get:
      operationId: getFulfillmentOrderFreightDefaults
      tags:
        - Fulfillment Orders
      summary: Freight account and booking defaults
      description: |
        The Freightview (LTL) integration account a fulfillment order will quote with, and that account's
        booking defaults (location types, destination accessorials, pickup window).

        The account is resolved in order: the order's warehouse group's freight account (`warehouse_group`),
        then the order's destination OMS if it is itself a Freightview account (`destination_oms`), then the
        tenant's only Freightview account (`sole_account`). When none applies, `account_source` is
        `unresolved`, `app_integration_account_id` and `defaults` are `null`, and
        `POST /fulfillment-orders/{id}/freight/quotes` needs an explicit `app_integration_account_id`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      responses:
        '200':
          description: Resolved account and defaults
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      app_integration_account_id:
                        type: integer
                        nullable: true
                      account_source:
                        type: string
                        enum:
                          - warehouse_group
                          - destination_oms
                          - sole_account
                          - unresolved
                      defaults:
                        type: object
                        nullable: true
                        description: 'The account''s saved defaults, or the system fallback (`source.level` = `default`). `null` when no account resolved.'
                        properties:
                          origin_location_type:
                            type: string
                            enum:
                              - business_dock
                              - business_no_dock
                              - residential
                          destination_location_type:
                            type: string
                            enum:
                              - business_dock
                              - business_no_dock
                              - residential
                          destination_accessorials:
                            type: array
                            items:
                              type: string
                              enum:
                                - liftgate
                                - inside_delivery
                                - call_before
                                - appointment
                                - sort_segregate
                                - protect_from_freezing
                          pickup_window_start:
                            type: string
                            nullable: true
                            description: '24-hour `HH:MM`; `null` lets Freightview apply its own default window.'
                          pickup_window_end:
                            type: string
                            nullable: true
                          pickup_instructions:
                            type: string
                            nullable: true
                            description: 'Saved pickup instructions for this account, or `null` when none. Up to 500 characters.'
                          delivery_instructions:
                            type: string
                            nullable: true
                            description: 'Saved delivery instructions for this account, or `null` when none. Up to 500 characters.'
                          source:
                            type: object
                            properties:
                              level:
                                type: string
                                enum:
                                  - integration
                                  - default
              example:
                data:
                  app_integration_account_id: 7
                  account_source: warehouse_group
                  defaults:
                    origin_location_type: business_dock
                    destination_location_type: residential
                    destination_accessorials:
                      - liftgate
                      - call_before
                    pickup_window_start: null
                    pickup_window_end: null
                    pickup_instructions: null
                    delivery_instructions: null
                    source:
                      level: default
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/freight/shipments':
    get:
      operationId: getFulfillmentOrderFreightShipments
      tags:
        - Fulfillment Orders
      summary: Freight record and active shipments
      description: |
        The fulfillment order's latest freight record — an open quote session to book from before quoting
        again (`bookedAt` is `null`, `quotes` included), or the booking — plus the order's active Luminous
        shipments. Check this before `POST /fulfillment-orders/{id}/freight/quotes`, since every quote call
        creates another Freightview shipment.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      latest_freight_shipment:
                        nullable: true
                        allOf:
                          - type: object
                            description: |
                              A Freightview freight shipment record ("metadata") for a fulfillment order: the quote session and, once
                              booked, the booking references. Field names are camelCase. `quotes` and `documents` are present when loaded
                              (single-record and fulfillment-order reads load `quotes`).
                            properties:
                              id:
                                type: integer
                                description: 'Freight shipment record ID — the `metadataId` in `/freight/shipments/{metadataId}` routes.'
                              provider:
                                type: string
                                example: freightview
                              providerShipmentId:
                                type: string
                                nullable: true
                                description: Freightview's shipment ID.
                              shipstationShipmentId:
                                type: integer
                                nullable: true
                                description: 'The Luminous shipment created by booking, or `null` before booking (and for self-arranged 3PL bookings, where the references below live on this record instead).'
                              fulfillmentOrderId:
                                type: integer
                              appIntegrationAccountId:
                                type: integer
                                description: The Freightview integration account used.
                              providerStatus:
                                type: string
                                nullable: true
                                description: 'Freightview''s shipment status; refresh with `POST /freight/shipments/{metadataId}/sync-status`.'
                              selectedQuoteId:
                                type: string
                                nullable: true
                                description: '`providerQuoteId` of the booked quote.'
                              pickupConfirmation:
                                type: string
                                nullable: true
                              bolNumber:
                                type: string
                                nullable: true
                              proNumber:
                                type: string
                                nullable: true
                              carrierScac:
                                type: string
                                nullable: true
                              trackingNumber:
                                type: string
                                nullable: true
                              serviceCode:
                                type: string
                                nullable: true
                              shipmentCost:
                                type: number
                                nullable: true
                              pickupDate:
                                type: string
                                format: date
                                nullable: true
                              pickupWindowStart:
                                type: string
                                nullable: true
                                description: '24-hour `HH:MM`.'
                              pickupWindowEnd:
                                type: string
                                nullable: true
                                description: '24-hour `HH:MM`.'
                              pickupInstructions:
                                type: string
                                nullable: true
                                description: Pickup instructions sent with the shipment.
                              deliveryInstructions:
                                type: string
                                nullable: true
                                description: Delivery instructions sent with the shipment.
                              errorMessage:
                                type: string
                                nullable: true
                                description: 'Last provider error, if any.'
                              bookedAt:
                                type: string
                                format: date-time
                                nullable: true
                                description: '`null` while the record is still an open quote session.'
                              pollingStatus:
                                type: string
                                nullable: true
                                description: Rating progress — `completed` once all carriers have answered.
                              pollingStartedAt:
                                type: string
                                format: date-time
                                nullable: true
                              pollingCompletedAt:
                                type: string
                                format: date-time
                                nullable: true
                              originAddress:
                                type: object
                                nullable: true
                                additionalProperties: true
                              destinationAddress:
                                type: object
                                nullable: true
                                additionalProperties: true
                              freightItems:
                                type: array
                                nullable: true
                                description: The handling units that were quoted.
                                items:
                                  type: object
                                  additionalProperties: true
                              originLocationType:
                                type: string
                                nullable: true
                                enum:
                                  - business_dock
                                  - business_no_dock
                                  - residential
                              destinationLocationType:
                                type: string
                                nullable: true
                                enum:
                                  - business_dock
                                  - business_no_dock
                                  - residential
                              destinationAccessorials:
                                type: array
                                nullable: true
                                items:
                                  type: string
                              createdAt:
                                type: string
                                format: date-time
                              updatedAt:
                                type: string
                                format: date-time
                              quotes:
                                type: array
                                description: Present when loaded. Carriers that failed to rate are listed last with status error.
                                items:
                                  type: object
                                  description: One carrier rate on a freight shipment. Field names are camelCase.
                                  properties:
                                    id:
                                      type: integer
                                    providerQuoteId:
                                      type: string
                                      description: Freightview's quote ID — the value to send as `quote_id` when booking.
                                    carrier:
                                      type: string
                                      nullable: true
                                    carrierScac:
                                      type: string
                                      nullable: true
                                    service:
                                      type: string
                                      nullable: true
                                    price:
                                      type: number
                                      nullable: true
                                      description: Quoted price. A carrier that failed to rate is stored as a 0 price with status error — do not book it.
                                    transitDaysMin:
                                      type: integer
                                      nullable: true
                                    transitDaysMax:
                                      type: integer
                                      nullable: true
                                    isSelected:
                                      type: boolean
                                      nullable: true
                                      description: True on the quote that was booked.
                                    isAppointment:
                                      type: boolean
                                      nullable: true
                                    expiresAt:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    status:
                                      type: string
                                      nullable: true
                                      description: 'Freightview''s rate status, e.g. `active`, or `error` when the carrier failed to rate.'
                                    errors:
                                      type: array
                                      description: Carrier error messages when `status` is `error`; empty otherwise.
                                      items:
                                        type: string
                              documents:
                                type: array
                                description: 'Present when loaded. Prefer `GET /freight/shipments/{metadataId}/documents`.'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    documentType:
                                      type: string
                                    fileName:
                                      type: string
                                      nullable: true
                                    fileUrl:
                                      type: string
                                      nullable: true
                                    providerUrl:
                                      type: string
                                      nullable: true
                                    mimeType:
                                      type: string
                                      nullable: true
                        description: 'The most recent freight record for the order, with `quotes`; `null` when the order has never been quoted.'
                      active_shipments:
                        type: array
                        description: Non-cancelled Luminous shipments on the order.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            lum_status:
                              type: string
                              nullable: true
                            carrier_code:
                              type: string
                              nullable: true
                            service_code:
                              type: string
                              nullable: true
                            tracking_number:
                              type: string
                              nullable: true
                            bol_number:
                              type: string
                              nullable: true
                            pro_number:
                              type: string
                              nullable: true
                            shipment_cost:
                              type: number
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/freight/package-plan':
    post:
      operationId: planFulfillmentOrderFreightPackages
      tags:
        - Fulfillment Orders
      summary: Build a package plan
      description: |
        Package Builder's "Auto-create Structure" for a fulfillment order: packs the order's lines into
        pallets/cases/boxes using the products' pallet standards, carton sizes and weights, and the
        tenant's saved auto-create defaults. The plan is **not saved**. Use `freight_items` as the `items` of
        `POST /fulfillment-orders/{id}/freight/quotes`, and `packages` as the body of
        `POST /sales-orders/{id}/shipments/{id}/packages` once the shipment exists.

        `config` keys override the tenant defaults for this call only. With `generate_sscc: true` every
        package gets an SSCC — each one consumes a tenant serial whether or not the plan is saved, so leave
        it off unless you will save the packages.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                config:
                  type: object
                  nullable: true
                  description: 'Auto-create overrides (camelCase, as saved in the tenant''s defaults). Unknown or mistyped keys are ignored.'
                  properties:
                    maxBoxWeight:
                      type: number
                      description: Pounds. Default `50`.
                    maxItemsPerBox:
                      type: number
                      description: 'Default is the order''s suggested max units, else `10`.'
                    useBoxes:
                      type: boolean
                    useCases:
                      type: boolean
                    usePallets:
                      type: boolean
                    useSkuPalletStandards:
                      type: boolean
                      description: Use each SKU's units-per-pallet and pallet dimensions.
                    defaultPalletTareWeight:
                      type: number
                      description: Pounds. Default `75`.
                    defaultFreightClass:
                      type: string
                      description: NMFC freight class stamped on pallets and used for quote items whose package has none. A numeric string greater than 0 (e.g. `"50"`). Default `55`.
                    defaultNmfcNumber:
                      type: string
                      description: NMFC number stamped on pallets and used for quote items whose package has none. Non-empty string. Default `37860`.
                    groupBy:
                      type: string
                      enum:
                        - sku
                        - category
                        - none
                    keepSkusTogether:
                      type: boolean
                    allowMixedCategories:
                      type: boolean
                generate_sscc:
                  type: boolean
                  default: false
      responses:
        '200':
          description: Package plan built
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      fulfillment_order_id:
                        type: integer
                      config:
                        type: object
                        description: The effective configuration used.
                        additionalProperties: true
                      packages:
                        type: array
                        items:
                          type: object
                          description: 'One top-level package from the package plan — the shape `POST /sales-orders/{id}/shipments/{id}/packages` takes, so it can be saved on the booked shipment as-is.'
                          properties:
                            external_package_id:
                              type: string
                              example: auto-1
                            sscc:
                              type: string
                              nullable: true
                              description: Only set when `generate_sscc` was true.
                            package_type:
                              type: string
                              enum:
                                - pallet
                                - case
                                - box
                            package_quantity:
                              type: integer
                            length_in:
                              type: number
                            width_in:
                              type: number
                            height_in:
                              type: number
                            weight_lb:
                              type: number
                              description: Gross weight including tare.
                            tare_weight_lb:
                              type: number
                              nullable: true
                            freight_class:
                              type: string
                              nullable: true
                            nmfc_number:
                              type: string
                              nullable: true
                            contained_items:
                              type: array
                              items:
                                type: object
                                properties:
                                  fulfillment_order_item_id:
                                    type: integer
                                  order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'The sales-order line, which is what the packages endpoint validates and matches on.'
                                  sku:
                                    type: string
                                    nullable: true
                                  description:
                                    type: string
                                    nullable: true
                                  line_item_key:
                                    type: string
                                    nullable: true
                                  quantity:
                                    type: number
                                  lot_id:
                                    type: integer
                                    nullable: true
                                  lot_number:
                                    type: string
                                    nullable: true
                                  expiration_date:
                                    type: string
                                    nullable: true
                      freight_items:
                        type: array
                        description: 'One quote item per top-level package. A package without a freight class or NMFC number falls back to `defaultFreightClass` / `defaultNmfcNumber` (the tenant''s saved defaults, else `55` / `37860`).'
                        items:
                          type: object
                          description: 'One handling unit (pallet, crate, box, drum) to be quoted. The package plan''s `freight_items` are in this shape.'
                          required:
                            - quantity
                            - weight
                            - freight_class
                            - type
                            - length
                            - width
                            - height
                          properties:
                            quantity:
                              type: integer
                              minimum: 1
                              description: Number of identical handling units.
                            weight:
                              type: number
                              minimum: 0
                              description: 'Weight of one handling unit, in pounds.'
                            freight_class:
                              type: number
                              description: 'NMFC freight class (e.g. `55`, `70`, `125`).'
                            type:
                              type: string
                              enum:
                                - pallet
                                - case
                                - crate
                                - box
                                - drum
                              description: Handling-unit type. `case` is accepted and sent to Freightview as `box`.
                            length:
                              type: number
                              minimum: 0
                              description: Inches.
                            width:
                              type: number
                              minimum: 0
                              description: Inches.
                            height:
                              type: number
                              minimum: 0
                              description: Inches.
                            nmfc_number:
                              type: string
                              nullable: true
                            stackable:
                              type: boolean
                              nullable: true
                            pieces:
                              type: integer
                              minimum: 1
                              nullable: true
                              description: 'Pieces on one handling unit, sent to Freightview as the unit''s contents.'
                            contents:
                              type: string
                              nullable: true
                              description: Short contents summary (e.g. `36 x Nakan Signature / Micro / Box`).
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Fulfillment order not found, or it has no items to pack'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-orders/{fulfillmentOrderId}/freight/quotes':
    post:
      operationId: createFulfillmentOrderFreightQuotes
      tags:
        - Fulfillment Orders
      summary: Create freight shipment and request quotes
      description: |
        Create a Freightview LTL shipment for the fulfillment order and start rating. The response is the new
        freight record (`id` is the `metadataId` for the `/freight/shipments/{metadataId}` routes); poll
        `GET /freight/shipments/{metadataId}/quotes` until `polling_status` is `completed`, then book with
        `POST /freight/shipments/{metadataId}/book`.

        **Every call creates another Freightview shipment.** Check
        `GET /fulfillment-orders/{id}/freight/shipments` first and reuse an open session (`bookedAt: null`).

        What the web app pre-fills is optional here: `origin` defaults to the order's warehouse group address,
        `destination` to the order's ship-to, and `app_integration_account_id` to the account from
        `GET /fulfillment-orders/{id}/freight/defaults` (`422` when none resolves). An address that **is**
        sent must be complete. `items` is required — send the package plan's `freight_items`.

        Validation failures use the `400 {"error": "..."}` shape.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - pickup_date
                - items
              properties:
                pickup_date:
                  type: string
                  format: date
                  description: Today or later.
                pickup_window_start:
                  type: string
                  nullable: true
                  description: '24-hour `HH:MM`. Send both window fields or neither; end must be after start.'
                pickup_window_end:
                  type: string
                  nullable: true
                pickup_instructions:
                  type: string
                  nullable: true
                  maxLength: 500
                  description: 'Instructions for the carrier at pickup, sent to Freightview with the shipment and kept on the freight record.'
                delivery_instructions:
                  type: string
                  nullable: true
                  maxLength: 500
                  description: 'Instructions for the carrier at delivery, sent to Freightview with the shipment and kept on the freight record.'
                app_integration_account_id:
                  type: integer
                  nullable: true
                  description: Freightview integration account. Defaults to the order's resolved account.
                origin:
                  nullable: true
                  allOf:
                    - type: object
                      description: |
                        A freight origin or destination. When sent, the address must be complete (`company`, `address`, `city`,
                        `state`, `postal_code`, `country`; an origin also needs `contact_name` and `contact_phone`).
                      properties:
                        company:
                          type: string
                        address:
                          type: string
                          description: Street address line 1.
                        address2:
                          type: string
                          nullable: true
                        city:
                          type: string
                        state:
                          type: string
                        postal_code:
                          type: string
                        country:
                          type: string
                        contact_name:
                          type: string
                          description: Required on an origin address.
                        contact_phone:
                          type: string
                          description: Required on an origin address.
                        contact_email:
                          type: string
                          format: email
                          nullable: true
                  description: Defaults to the order's warehouse group. Must be complete when sent (including `contact_name` and `contact_phone`).
                destination:
                  nullable: true
                  allOf:
                    - type: object
                      description: |
                        A freight origin or destination. When sent, the address must be complete (`company`, `address`, `city`,
                        `state`, `postal_code`, `country`; an origin also needs `contact_name` and `contact_phone`).
                      properties:
                        company:
                          type: string
                        address:
                          type: string
                          description: Street address line 1.
                        address2:
                          type: string
                          nullable: true
                        city:
                          type: string
                        state:
                          type: string
                        postal_code:
                          type: string
                        country:
                          type: string
                        contact_name:
                          type: string
                          description: Required on an origin address.
                        contact_phone:
                          type: string
                          description: Required on an origin address.
                        contact_email:
                          type: string
                          format: email
                          nullable: true
                  description: Defaults to the order's ship-to. Must be complete when sent.
                items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    description: 'One handling unit (pallet, crate, box, drum) to be quoted. The package plan''s `freight_items` are in this shape.'
                    required:
                      - quantity
                      - weight
                      - freight_class
                      - type
                      - length
                      - width
                      - height
                    properties:
                      quantity:
                        type: integer
                        minimum: 1
                        description: Number of identical handling units.
                      weight:
                        type: number
                        minimum: 0
                        description: 'Weight of one handling unit, in pounds.'
                      freight_class:
                        type: number
                        description: 'NMFC freight class (e.g. `55`, `70`, `125`).'
                      type:
                        type: string
                        enum:
                          - pallet
                          - case
                          - crate
                          - box
                          - drum
                        description: Handling-unit type. `case` is accepted and sent to Freightview as `box`.
                      length:
                        type: number
                        minimum: 0
                        description: Inches.
                      width:
                        type: number
                        minimum: 0
                        description: Inches.
                      height:
                        type: number
                        minimum: 0
                        description: Inches.
                      nmfc_number:
                        type: string
                        nullable: true
                      stackable:
                        type: boolean
                        nullable: true
                      pieces:
                        type: integer
                        minimum: 1
                        nullable: true
                        description: 'Pieces on one handling unit, sent to Freightview as the unit''s contents.'
                      contents:
                        type: string
                        nullable: true
                        description: Short contents summary (e.g. `36 x Nakan Signature / Micro / Box`).
                shipment_id:
                  type: integer
                  nullable: true
                  description: Existing Luminous shipment to attach the freight record to.
                origin_location_type:
                  type: string
                  nullable: true
                  enum:
                    - business_dock
                    - business_no_dock
                    - residential
                destination_location_type:
                  type: string
                  nullable: true
                  enum:
                    - business_dock
                    - business_no_dock
                    - residential
                origin_accessorials:
                  type: array
                  nullable: true
                  items:
                    type: string
                destination_accessorials:
                  type: array
                  nullable: true
                  items:
                    type: string
                    enum:
                      - liftgate
                      - inside_delivery
                      - call_before
                      - appointment
                      - sort_segregate
                      - protect_from_freezing
                  description: '`call_before` and `appointment` cannot be combined.'
            example:
              pickup_date: '2026-10-22'
              items:
                - quantity: 1
                  weight: 1911
                  freight_class: 55
                  type: pallet
                  length: 74
                  width: 40
                  height: 21
                  nmfc_number: '37860'
                  stackable: false
                  pieces: 36
                  contents: 36 x Nakan Signature / Micro / Box
      responses:
        '201':
          description: Freight shipment created; rating in progress
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A Freightview freight shipment record ("metadata") for a fulfillment order: the quote session and, once
                      booked, the booking references. Field names are camelCase. `quotes` and `documents` are present when loaded
                      (single-record and fulfillment-order reads load `quotes`).
                    properties:
                      id:
                        type: integer
                        description: 'Freight shipment record ID — the `metadataId` in `/freight/shipments/{metadataId}` routes.'
                      provider:
                        type: string
                        example: freightview
                      providerShipmentId:
                        type: string
                        nullable: true
                        description: Freightview's shipment ID.
                      shipstationShipmentId:
                        type: integer
                        nullable: true
                        description: 'The Luminous shipment created by booking, or `null` before booking (and for self-arranged 3PL bookings, where the references below live on this record instead).'
                      fulfillmentOrderId:
                        type: integer
                      appIntegrationAccountId:
                        type: integer
                        description: The Freightview integration account used.
                      providerStatus:
                        type: string
                        nullable: true
                        description: 'Freightview''s shipment status; refresh with `POST /freight/shipments/{metadataId}/sync-status`.'
                      selectedQuoteId:
                        type: string
                        nullable: true
                        description: '`providerQuoteId` of the booked quote.'
                      pickupConfirmation:
                        type: string
                        nullable: true
                      bolNumber:
                        type: string
                        nullable: true
                      proNumber:
                        type: string
                        nullable: true
                      carrierScac:
                        type: string
                        nullable: true
                      trackingNumber:
                        type: string
                        nullable: true
                      serviceCode:
                        type: string
                        nullable: true
                      shipmentCost:
                        type: number
                        nullable: true
                      pickupDate:
                        type: string
                        format: date
                        nullable: true
                      pickupWindowStart:
                        type: string
                        nullable: true
                        description: '24-hour `HH:MM`.'
                      pickupWindowEnd:
                        type: string
                        nullable: true
                        description: '24-hour `HH:MM`.'
                      pickupInstructions:
                        type: string
                        nullable: true
                        description: Pickup instructions sent with the shipment.
                      deliveryInstructions:
                        type: string
                        nullable: true
                        description: Delivery instructions sent with the shipment.
                      errorMessage:
                        type: string
                        nullable: true
                        description: 'Last provider error, if any.'
                      bookedAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: '`null` while the record is still an open quote session.'
                      pollingStatus:
                        type: string
                        nullable: true
                        description: Rating progress — `completed` once all carriers have answered.
                      pollingStartedAt:
                        type: string
                        format: date-time
                        nullable: true
                      pollingCompletedAt:
                        type: string
                        format: date-time
                        nullable: true
                      originAddress:
                        type: object
                        nullable: true
                        additionalProperties: true
                      destinationAddress:
                        type: object
                        nullable: true
                        additionalProperties: true
                      freightItems:
                        type: array
                        nullable: true
                        description: The handling units that were quoted.
                        items:
                          type: object
                          additionalProperties: true
                      originLocationType:
                        type: string
                        nullable: true
                        enum:
                          - business_dock
                          - business_no_dock
                          - residential
                      destinationLocationType:
                        type: string
                        nullable: true
                        enum:
                          - business_dock
                          - business_no_dock
                          - residential
                      destinationAccessorials:
                        type: array
                        nullable: true
                        items:
                          type: string
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
                      quotes:
                        type: array
                        description: Present when loaded. Carriers that failed to rate are listed last with status error.
                        items:
                          type: object
                          description: One carrier rate on a freight shipment. Field names are camelCase.
                          properties:
                            id:
                              type: integer
                            providerQuoteId:
                              type: string
                              description: Freightview's quote ID — the value to send as `quote_id` when booking.
                            carrier:
                              type: string
                              nullable: true
                            carrierScac:
                              type: string
                              nullable: true
                            service:
                              type: string
                              nullable: true
                            price:
                              type: number
                              nullable: true
                              description: Quoted price. A carrier that failed to rate is stored as a 0 price with status error — do not book it.
                            transitDaysMin:
                              type: integer
                              nullable: true
                            transitDaysMax:
                              type: integer
                              nullable: true
                            isSelected:
                              type: boolean
                              nullable: true
                              description: True on the quote that was booked.
                            isAppointment:
                              type: boolean
                              nullable: true
                            expiresAt:
                              type: string
                              format: date-time
                              nullable: true
                            status:
                              type: string
                              nullable: true
                              description: 'Freightview''s rate status, e.g. `active`, or `error` when the carrier failed to rate.'
                            errors:
                              type: array
                              description: Carrier error messages when `status` is `error`; empty otherwise.
                              items:
                                type: string
                      documents:
                        type: array
                        description: 'Present when loaded. Prefer `GET /freight/shipments/{metadataId}/documents`.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            documentType:
                              type: string
                            fileName:
                              type: string
                              nullable: true
                            fileUrl:
                              type: string
                              nullable: true
                            providerUrl:
                              type: string
                              nullable: true
                            mimeType:
                              type: string
                              nullable: true
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: At least one freight item is required.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'No default Freightview account for this fulfillment order, or Freightview rejected the shipment'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: No default Freightview account for this fulfillment order; send app_integration_account_id.
  '/fulfillment-orders/{fulfillmentOrderId}/packing-slip':
    get:
      operationId: getFulfillmentOrderPackingSlip
      tags:
        - Fulfillment Orders
      summary: Packing slip PDF
      description: |
        The tenant's packing slip for a fulfillment order, rendered as a PDF. By default one page set per
        package (`per_package=true`); pass `per_package=false` for a single slip. `template_id` selects a
        specific packing-slip export template.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          schema:
            type: integer
          description: ID of the fulfillment order
        - in: query
          name: per_package
          schema:
            type: boolean
            default: true
          description: One page set per package.
        - in: query
          name: template_id
          schema:
            type: integer
          description: Export template ID to render with.
      responses:
        '200':
          description: PDF document
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The packing slip could not be rendered
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/freight/shipments/{metadataId}':
    get:
      operationId: getFreightShipment
      tags:
        - Freight
      summary: Single freight shipment
      description: |
        A freight shipment record by ID: status, booking references (BOL, PRO, tracking, carrier), pickup
        details, the last provider error, and its quotes. `providerStatus` is as of the last sync; call
        `POST /freight/shipments/{metadataId}/sync-status` to refresh it from Freightview.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: metadataId
          required: true
          schema:
            type: integer
          description: Freight shipment record ID (the `id` returned by the quotes call)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A Freightview freight shipment record ("metadata") for a fulfillment order: the quote session and, once
                      booked, the booking references. Field names are camelCase. `quotes` and `documents` are present when loaded
                      (single-record and fulfillment-order reads load `quotes`).
                    properties:
                      id:
                        type: integer
                        description: 'Freight shipment record ID — the `metadataId` in `/freight/shipments/{metadataId}` routes.'
                      provider:
                        type: string
                        example: freightview
                      providerShipmentId:
                        type: string
                        nullable: true
                        description: Freightview's shipment ID.
                      shipstationShipmentId:
                        type: integer
                        nullable: true
                        description: 'The Luminous shipment created by booking, or `null` before booking (and for self-arranged 3PL bookings, where the references below live on this record instead).'
                      fulfillmentOrderId:
                        type: integer
                      appIntegrationAccountId:
                        type: integer
                        description: The Freightview integration account used.
                      providerStatus:
                        type: string
                        nullable: true
                        description: 'Freightview''s shipment status; refresh with `POST /freight/shipments/{metadataId}/sync-status`.'
                      selectedQuoteId:
                        type: string
                        nullable: true
                        description: '`providerQuoteId` of the booked quote.'
                      pickupConfirmation:
                        type: string
                        nullable: true
                      bolNumber:
                        type: string
                        nullable: true
                      proNumber:
                        type: string
                        nullable: true
                      carrierScac:
                        type: string
                        nullable: true
                      trackingNumber:
                        type: string
                        nullable: true
                      serviceCode:
                        type: string
                        nullable: true
                      shipmentCost:
                        type: number
                        nullable: true
                      pickupDate:
                        type: string
                        format: date
                        nullable: true
                      pickupWindowStart:
                        type: string
                        nullable: true
                        description: '24-hour `HH:MM`.'
                      pickupWindowEnd:
                        type: string
                        nullable: true
                        description: '24-hour `HH:MM`.'
                      pickupInstructions:
                        type: string
                        nullable: true
                        description: Pickup instructions sent with the shipment.
                      deliveryInstructions:
                        type: string
                        nullable: true
                        description: Delivery instructions sent with the shipment.
                      errorMessage:
                        type: string
                        nullable: true
                        description: 'Last provider error, if any.'
                      bookedAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: '`null` while the record is still an open quote session.'
                      pollingStatus:
                        type: string
                        nullable: true
                        description: Rating progress — `completed` once all carriers have answered.
                      pollingStartedAt:
                        type: string
                        format: date-time
                        nullable: true
                      pollingCompletedAt:
                        type: string
                        format: date-time
                        nullable: true
                      originAddress:
                        type: object
                        nullable: true
                        additionalProperties: true
                      destinationAddress:
                        type: object
                        nullable: true
                        additionalProperties: true
                      freightItems:
                        type: array
                        nullable: true
                        description: The handling units that were quoted.
                        items:
                          type: object
                          additionalProperties: true
                      originLocationType:
                        type: string
                        nullable: true
                        enum:
                          - business_dock
                          - business_no_dock
                          - residential
                      destinationLocationType:
                        type: string
                        nullable: true
                        enum:
                          - business_dock
                          - business_no_dock
                          - residential
                      destinationAccessorials:
                        type: array
                        nullable: true
                        items:
                          type: string
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
                      quotes:
                        type: array
                        description: Present when loaded. Carriers that failed to rate are listed last with status error.
                        items:
                          type: object
                          description: One carrier rate on a freight shipment. Field names are camelCase.
                          properties:
                            id:
                              type: integer
                            providerQuoteId:
                              type: string
                              description: Freightview's quote ID — the value to send as `quote_id` when booking.
                            carrier:
                              type: string
                              nullable: true
                            carrierScac:
                              type: string
                              nullable: true
                            service:
                              type: string
                              nullable: true
                            price:
                              type: number
                              nullable: true
                              description: Quoted price. A carrier that failed to rate is stored as a 0 price with status error — do not book it.
                            transitDaysMin:
                              type: integer
                              nullable: true
                            transitDaysMax:
                              type: integer
                              nullable: true
                            isSelected:
                              type: boolean
                              nullable: true
                              description: True on the quote that was booked.
                            isAppointment:
                              type: boolean
                              nullable: true
                            expiresAt:
                              type: string
                              format: date-time
                              nullable: true
                            status:
                              type: string
                              nullable: true
                              description: 'Freightview''s rate status, e.g. `active`, or `error` when the carrier failed to rate.'
                            errors:
                              type: array
                              description: Carrier error messages when `status` is `error`; empty otherwise.
                              items:
                                type: string
                      documents:
                        type: array
                        description: 'Present when loaded. Prefer `GET /freight/shipments/{metadataId}/documents`.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            documentType:
                              type: string
                            fileName:
                              type: string
                              nullable: true
                            fileUrl:
                              type: string
                              nullable: true
                            providerUrl:
                              type: string
                              nullable: true
                            mimeType:
                              type: string
                              nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Freight shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/freight/shipments/{metadataId}/quotes':
    get:
      operationId: getFreightShipmentQuotes
      tags:
        - Freight
      summary: Freight quotes
      description: |
        The carrier rates on a freight shipment, refreshed from Freightview. Rating is finished when
        `polling_status` is `completed`; poll until then. Carriers that failed to rate come last with
        `status: error` and their messages in `errors`, whatever their `price` — skip them when choosing the
        cheapest quote (booking one returns `422`).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: metadataId
          required: true
          schema:
            type: integer
          description: Freight shipment record ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      polling_status:
                        type: string
                        nullable: true
                        description: '`completed` once every carrier has answered.'
                      polling_started_at:
                        type: string
                        format: date-time
                        nullable: true
                      polling_completed_at:
                        type: string
                        format: date-time
                        nullable: true
                      quotes:
                        type: array
                        items:
                          type: object
                          description: One carrier rate on a freight shipment. Field names are camelCase.
                          properties:
                            id:
                              type: integer
                            providerQuoteId:
                              type: string
                              description: Freightview's quote ID — the value to send as `quote_id` when booking.
                            carrier:
                              type: string
                              nullable: true
                            carrierScac:
                              type: string
                              nullable: true
                            service:
                              type: string
                              nullable: true
                            price:
                              type: number
                              nullable: true
                              description: Quoted price. A carrier that failed to rate is stored as a 0 price with status error — do not book it.
                            transitDaysMin:
                              type: integer
                              nullable: true
                            transitDaysMax:
                              type: integer
                              nullable: true
                            isSelected:
                              type: boolean
                              nullable: true
                              description: True on the quote that was booked.
                            isAppointment:
                              type: boolean
                              nullable: true
                            expiresAt:
                              type: string
                              format: date-time
                              nullable: true
                            status:
                              type: string
                              nullable: true
                              description: 'Freightview''s rate status, e.g. `active`, or `error` when the carrier failed to rate.'
                            errors:
                              type: array
                              description: Carrier error messages when `status` is `error`; empty otherwise.
                              items:
                                type: string
              example:
                data:
                  polling_status: completed
                  polling_started_at: '2026-10-21T15:02:10Z'
                  polling_completed_at: '2026-10-21T15:02:41Z'
                  quotes:
                    - id: 3
                      providerQuoteId: q-3
                      carrier: Estes
                      carrierScac: EXLA
                      service: Standard LTL
                      price: 298.1
                      transitDaysMin: 2
                      transitDaysMax: 3
                      isSelected: false
                      isAppointment: false
                      expiresAt: null
                      status: active
                      errors: []
                    - id: 1
                      providerQuoteId: q-1
                      carrier: Dugan Truck Line
                      carrierScac: DUGN
                      service: null
                      price: 0
                      transitDaysMin: null
                      transitDaysMax: null
                      isSelected: false
                      isAppointment: false
                      expiresAt: null
                      status: error
                      errors:
                        - Dugan Truck Line is currently unable to return rates.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Freight shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/freight/shipments/{metadataId}/book':
    post:
      operationId: bookFreightShipment
      tags:
        - Freight
      summary: Book a freight quote
      description: |
        Book one of the shipment's quotes with the carrier. **This creates a real carrier pickup that cannot
        be cancelled from Luminous.** Booking the same record twice is refused (`409`), as is a quote that is
        not on the record or whose carrier failed to rate (`422`).

        Booking creates (or, for a self-arranged 3PL order, records on the freight record) the Luminous
        shipment with the BOL, PRO and tracking references; `shipment_id` is that shipment, or `null` when
        the references live on the freight record only. `lum_status` sets the Luminous shipment's status —
        `shipped` (default) or `pending`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: metadataId
          required: true
          schema:
            type: integer
          description: Freight shipment record ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - quote_id
              properties:
                quote_id:
                  type: string
                  description: The quote's `providerQuoteId`.
                schedule_pickup:
                  type: boolean
                  default: true
                  description: Ask the carrier to schedule the pickup.
                lum_status:
                  type: string
                  enum:
                    - shipped
                    - pending
                  default: shipped
                  description: Status of the Luminous shipment created by the booking.
            example:
              quote_id: q-3
              lum_status: shipped
      responses:
        '200':
          description: Booked
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      freight_shipment:
                        type: object
                        description: |
                          A Freightview freight shipment record ("metadata") for a fulfillment order: the quote session and, once
                          booked, the booking references. Field names are camelCase. `quotes` and `documents` are present when loaded
                          (single-record and fulfillment-order reads load `quotes`).
                        properties:
                          id:
                            type: integer
                            description: 'Freight shipment record ID — the `metadataId` in `/freight/shipments/{metadataId}` routes.'
                          provider:
                            type: string
                            example: freightview
                          providerShipmentId:
                            type: string
                            nullable: true
                            description: Freightview's shipment ID.
                          shipstationShipmentId:
                            type: integer
                            nullable: true
                            description: 'The Luminous shipment created by booking, or `null` before booking (and for self-arranged 3PL bookings, where the references below live on this record instead).'
                          fulfillmentOrderId:
                            type: integer
                          appIntegrationAccountId:
                            type: integer
                            description: The Freightview integration account used.
                          providerStatus:
                            type: string
                            nullable: true
                            description: 'Freightview''s shipment status; refresh with `POST /freight/shipments/{metadataId}/sync-status`.'
                          selectedQuoteId:
                            type: string
                            nullable: true
                            description: '`providerQuoteId` of the booked quote.'
                          pickupConfirmation:
                            type: string
                            nullable: true
                          bolNumber:
                            type: string
                            nullable: true
                          proNumber:
                            type: string
                            nullable: true
                          carrierScac:
                            type: string
                            nullable: true
                          trackingNumber:
                            type: string
                            nullable: true
                          serviceCode:
                            type: string
                            nullable: true
                          shipmentCost:
                            type: number
                            nullable: true
                          pickupDate:
                            type: string
                            format: date
                            nullable: true
                          pickupWindowStart:
                            type: string
                            nullable: true
                            description: '24-hour `HH:MM`.'
                          pickupWindowEnd:
                            type: string
                            nullable: true
                            description: '24-hour `HH:MM`.'
                          pickupInstructions:
                            type: string
                            nullable: true
                            description: Pickup instructions sent with the shipment.
                          deliveryInstructions:
                            type: string
                            nullable: true
                            description: Delivery instructions sent with the shipment.
                          errorMessage:
                            type: string
                            nullable: true
                            description: 'Last provider error, if any.'
                          bookedAt:
                            type: string
                            format: date-time
                            nullable: true
                            description: '`null` while the record is still an open quote session.'
                          pollingStatus:
                            type: string
                            nullable: true
                            description: Rating progress — `completed` once all carriers have answered.
                          pollingStartedAt:
                            type: string
                            format: date-time
                            nullable: true
                          pollingCompletedAt:
                            type: string
                            format: date-time
                            nullable: true
                          originAddress:
                            type: object
                            nullable: true
                            additionalProperties: true
                          destinationAddress:
                            type: object
                            nullable: true
                            additionalProperties: true
                          freightItems:
                            type: array
                            nullable: true
                            description: The handling units that were quoted.
                            items:
                              type: object
                              additionalProperties: true
                          originLocationType:
                            type: string
                            nullable: true
                            enum:
                              - business_dock
                              - business_no_dock
                              - residential
                          destinationLocationType:
                            type: string
                            nullable: true
                            enum:
                              - business_dock
                              - business_no_dock
                              - residential
                          destinationAccessorials:
                            type: array
                            nullable: true
                            items:
                              type: string
                          createdAt:
                            type: string
                            format: date-time
                          updatedAt:
                            type: string
                            format: date-time
                          quotes:
                            type: array
                            description: Present when loaded. Carriers that failed to rate are listed last with status error.
                            items:
                              type: object
                              description: One carrier rate on a freight shipment. Field names are camelCase.
                              properties:
                                id:
                                  type: integer
                                providerQuoteId:
                                  type: string
                                  description: Freightview's quote ID — the value to send as `quote_id` when booking.
                                carrier:
                                  type: string
                                  nullable: true
                                carrierScac:
                                  type: string
                                  nullable: true
                                service:
                                  type: string
                                  nullable: true
                                price:
                                  type: number
                                  nullable: true
                                  description: Quoted price. A carrier that failed to rate is stored as a 0 price with status error — do not book it.
                                transitDaysMin:
                                  type: integer
                                  nullable: true
                                transitDaysMax:
                                  type: integer
                                  nullable: true
                                isSelected:
                                  type: boolean
                                  nullable: true
                                  description: True on the quote that was booked.
                                isAppointment:
                                  type: boolean
                                  nullable: true
                                expiresAt:
                                  type: string
                                  format: date-time
                                  nullable: true
                                status:
                                  type: string
                                  nullable: true
                                  description: 'Freightview''s rate status, e.g. `active`, or `error` when the carrier failed to rate.'
                                errors:
                                  type: array
                                  description: Carrier error messages when `status` is `error`; empty otherwise.
                                  items:
                                    type: string
                          documents:
                            type: array
                            description: 'Present when loaded. Prefer `GET /freight/shipments/{metadataId}/documents`.'
                            items:
                              type: object
                              properties:
                                id:
                                  type: integer
                                documentType:
                                  type: string
                                fileName:
                                  type: string
                                  nullable: true
                                fileUrl:
                                  type: string
                                  nullable: true
                                providerUrl:
                                  type: string
                                  nullable: true
                                mimeType:
                                  type: string
                                  nullable: true
                      shipment_id:
                        type: integer
                        nullable: true
                        description: 'The Luminous shipment created by the booking, or `null` for a self-arranged 3PL booking.'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Freight shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: 'The freight shipment is already booked, or a booking is already in progress'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: This freight shipment is already booked.
        '422':
          description: 'Missing `quote_id`, the quote is not on this shipment, its carrier failed to rate, or Freightview refused the booking'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: This carrier failed to rate; choose another quote.
  '/freight/shipments/{metadataId}/sync-status':
    post:
      operationId: syncFreightShipmentStatus
      tags:
        - Freight
      summary: Sync status from Freightview
      description: Pull the freight shipment's latest status from Freightview and return the updated record.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: metadataId
          required: true
          schema:
            type: integer
          description: Freight shipment record ID
      responses:
        '200':
          description: Status refreshed
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A Freightview freight shipment record ("metadata") for a fulfillment order: the quote session and, once
                      booked, the booking references. Field names are camelCase. `quotes` and `documents` are present when loaded
                      (single-record and fulfillment-order reads load `quotes`).
                    properties:
                      id:
                        type: integer
                        description: 'Freight shipment record ID — the `metadataId` in `/freight/shipments/{metadataId}` routes.'
                      provider:
                        type: string
                        example: freightview
                      providerShipmentId:
                        type: string
                        nullable: true
                        description: Freightview's shipment ID.
                      shipstationShipmentId:
                        type: integer
                        nullable: true
                        description: 'The Luminous shipment created by booking, or `null` before booking (and for self-arranged 3PL bookings, where the references below live on this record instead).'
                      fulfillmentOrderId:
                        type: integer
                      appIntegrationAccountId:
                        type: integer
                        description: The Freightview integration account used.
                      providerStatus:
                        type: string
                        nullable: true
                        description: 'Freightview''s shipment status; refresh with `POST /freight/shipments/{metadataId}/sync-status`.'
                      selectedQuoteId:
                        type: string
                        nullable: true
                        description: '`providerQuoteId` of the booked quote.'
                      pickupConfirmation:
                        type: string
                        nullable: true
                      bolNumber:
                        type: string
                        nullable: true
                      proNumber:
                        type: string
                        nullable: true
                      carrierScac:
                        type: string
                        nullable: true
                      trackingNumber:
                        type: string
                        nullable: true
                      serviceCode:
                        type: string
                        nullable: true
                      shipmentCost:
                        type: number
                        nullable: true
                      pickupDate:
                        type: string
                        format: date
                        nullable: true
                      pickupWindowStart:
                        type: string
                        nullable: true
                        description: '24-hour `HH:MM`.'
                      pickupWindowEnd:
                        type: string
                        nullable: true
                        description: '24-hour `HH:MM`.'
                      pickupInstructions:
                        type: string
                        nullable: true
                        description: Pickup instructions sent with the shipment.
                      deliveryInstructions:
                        type: string
                        nullable: true
                        description: Delivery instructions sent with the shipment.
                      errorMessage:
                        type: string
                        nullable: true
                        description: 'Last provider error, if any.'
                      bookedAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: '`null` while the record is still an open quote session.'
                      pollingStatus:
                        type: string
                        nullable: true
                        description: Rating progress — `completed` once all carriers have answered.
                      pollingStartedAt:
                        type: string
                        format: date-time
                        nullable: true
                      pollingCompletedAt:
                        type: string
                        format: date-time
                        nullable: true
                      originAddress:
                        type: object
                        nullable: true
                        additionalProperties: true
                      destinationAddress:
                        type: object
                        nullable: true
                        additionalProperties: true
                      freightItems:
                        type: array
                        nullable: true
                        description: The handling units that were quoted.
                        items:
                          type: object
                          additionalProperties: true
                      originLocationType:
                        type: string
                        nullable: true
                        enum:
                          - business_dock
                          - business_no_dock
                          - residential
                      destinationLocationType:
                        type: string
                        nullable: true
                        enum:
                          - business_dock
                          - business_no_dock
                          - residential
                      destinationAccessorials:
                        type: array
                        nullable: true
                        items:
                          type: string
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
                      quotes:
                        type: array
                        description: Present when loaded. Carriers that failed to rate are listed last with status error.
                        items:
                          type: object
                          description: One carrier rate on a freight shipment. Field names are camelCase.
                          properties:
                            id:
                              type: integer
                            providerQuoteId:
                              type: string
                              description: Freightview's quote ID — the value to send as `quote_id` when booking.
                            carrier:
                              type: string
                              nullable: true
                            carrierScac:
                              type: string
                              nullable: true
                            service:
                              type: string
                              nullable: true
                            price:
                              type: number
                              nullable: true
                              description: Quoted price. A carrier that failed to rate is stored as a 0 price with status error — do not book it.
                            transitDaysMin:
                              type: integer
                              nullable: true
                            transitDaysMax:
                              type: integer
                              nullable: true
                            isSelected:
                              type: boolean
                              nullable: true
                              description: True on the quote that was booked.
                            isAppointment:
                              type: boolean
                              nullable: true
                            expiresAt:
                              type: string
                              format: date-time
                              nullable: true
                            status:
                              type: string
                              nullable: true
                              description: 'Freightview''s rate status, e.g. `active`, or `error` when the carrier failed to rate.'
                            errors:
                              type: array
                              description: Carrier error messages when `status` is `error`; empty otherwise.
                              items:
                                type: string
                      documents:
                        type: array
                        description: 'Present when loaded. Prefer `GET /freight/shipments/{metadataId}/documents`.'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            documentType:
                              type: string
                            fileName:
                              type: string
                              nullable: true
                            fileUrl:
                              type: string
                              nullable: true
                            providerUrl:
                              type: string
                              nullable: true
                            mimeType:
                              type: string
                              nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Freight shipment not found, or Freightview could not be reached'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/freight/shipments/{metadataId}/documents':
    get:
      operationId: listFreightShipmentDocuments
      tags:
        - Freight
      summary: Freight documents
      description: |
        The documents Freightview holds for the shipment — bill of lading, labels, proof of delivery.
        Documents already mirrored into Luminous are returned as-is when the shipment can gain no more;
        otherwise (or with `refresh=1`) the provider's list is re-pulled and merged. Download a document with
        `GET /freight/shipments/{metadataId}/documents/{documentId}/download`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: metadataId
          required: true
          schema:
            type: integer
          description: Freight shipment record ID
        - in: query
          name: refresh
          schema:
            type: boolean
            default: false
          description: Re-pull the document list from Freightview.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        document_type:
                          type: string
                          description: 'e.g. `bol`, `label`, `proof-of-delivery`.'
                        file_name:
                          type: string
                          nullable: true
                        mime_type:
                          type: string
                          nullable: true
              example:
                data:
                  - id: 5
                    document_type: proof-of-delivery
                    file_name: POD
                    mime_type: application/pdf
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Freight shipment not found, or it has no provider shipment yet'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/freight/shipments/{metadataId}/documents/{documentId}/download':
    get:
      operationId: downloadFreightShipmentDocument
      tags:
        - Freight
      summary: Download a freight document
      description: 'Stream a freight document (BOL, label, POD) from Freightview. The `Content-Type` is the document''s own MIME type, typically `application/pdf`.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: metadataId
          required: true
          schema:
            type: integer
          description: Freight shipment record ID
        - in: path
          name: documentId
          required: true
          schema:
            type: integer
          description: Document ID from the documents list; must belong to this freight shipment
      responses:
        '200':
          description: The document bytes
          content:
            application/pdf:
              schema:
                type: string
                format: binary
            application/octet-stream:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Freight shipment or document not found (including a document that belongs to another shipment)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /fulfillment-priority-lists:
    get:
      operationId: listFulfillmentPriorityLists
      tags:
        - Fulfillment Priority Lists
      summary: List fulfillment priority lists
      description: |
        Paginated list of fulfillment priority lists (routing priority lists). Each list holds
        an ordered set of routing lines used to decide how a sales order's fulfillment orders
        are routed to warehouse groups, fulfillment channels, and destination OMS accounts.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          required: false
          schema:
            type: integer
            default: 1
        - in: query
          name: per_page
          required: false
          schema:
            type: integer
            default: 10
            maximum: 100
        - in: query
          name: id
          required: false
          schema:
            type: integer
          description: Filter by exact list id.
        - in: query
          name: name
          required: false
          schema:
            type: string
          description: Filter by name.
      responses:
        '200':
          description: A paginated list of fulfillment priority lists
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A fulfillment priority list (routing priority list). Defines the ordered set of
                        routing lines used to decide which warehouse group / fulfillment channel / destination
                        OMS a sales order's fulfillment orders are routed to.
                      properties:
                        id:
                          type: integer
                          example: 42
                        name:
                          type: string
                          example: Flexport
                        description:
                          type: string
                          nullable: true
                          example: Primary routing
                        is_location_aware:
                          type: boolean
                          description: 'When true, routing decisions take the order''s location into account.'
                          example: false
                        lines:
                          type: array
                          description: Ordered routing lines. Present when the `lines` relation is loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                example: 101
                              order:
                                type: integer
                                nullable: true
                                description: Zero-based priority rank of this line within the list.
                                example: 0
                              warehouse_group_id:
                                type: integer
                                nullable: true
                                example: 1
                              destination_oms_id:
                                type: integer
                                nullable: true
                                description: Target integration account (`app_integration_accounts.id`).
                                example: 3
                              destination_store_id:
                                type: integer
                                nullable: true
                                description: Optional ShipStation store id (`mt_shipstation_stores.id`).
                                example: null
                              fulfillment_channel_id:
                                type: integer
                                nullable: true
                                description: Fulfillment channel (`mt_channels.id`).
                                example: 11
                              prefer_before_proximity:
                                type: boolean
                                description: |
                                  When true on a location-aware list, this line is tried before the
                                  proximity-ranked lines, in its static `order`. Lines without it are
                                  ranked by distance to the ship-to address. Has no effect on lists
                                  that are not location-aware.
                                example: false
                              warehouse_group:
                                type: object
                                nullable: true
                                description: Present only when the `warehouseGroup` relation is eager-loaded.
                                properties:
                                  id:
                                    type: integer
                                  label:
                                    type: string
                                    nullable: true
                              fulfillment_channel:
                                type: object
                                nullable: true
                                description: Present only when the `fulfillmentChannel` relation is eager-loaded.
                                properties:
                                  id:
                                    type: integer
                                  label:
                                    type: string
                                    nullable: true
                              destination_oms:
                                type: object
                                nullable: true
                                description: Present only when the destination integration account relation is eager-loaded.
                                properties:
                                  id:
                                    type: integer
                                  label:
                                    type: string
                                    nullable: true
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                  links:
                    type: object
                    additionalProperties: true
                  meta:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createFulfillmentPriorityList
      tags:
        - Fulfillment Priority Lists
      summary: Create a fulfillment priority list
      description: |
        Create a routing priority list with one or more ordered lines. `destination_oms_id`
        maps to `app_integration_accounts.id`. A line's `warehouse_group_id` may be omitted
        only when the fulfillment channel defines a default warehouse group.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Request body for creating or updating a fulfillment priority list.
              required:
                - name
                - lines
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: 'Unique list name (per tenant, among non-deleted lists).'
                  example: Flexport
                description:
                  type: string
                  nullable: true
                  example: Primary routing
                is_location_aware:
                  type: boolean
                  default: false
                  description: 'When true, routing decisions take the order''s location into account.'
                lines:
                  type: array
                  description: Ordered routing lines (at least one).
                  minItems: 1
                  items:
                    type: object
                    required:
                      - warehouse_group_id
                      - fulfillment_channel_id
                    properties:
                      order:
                        type: integer
                        minimum: 0
                        nullable: true
                        description: Zero-based priority rank of this line within the list.
                        example: 0
                      warehouse_group_id:
                        type: integer
                        description: |
                          Warehouse group (`warehouse_groups.id`). May be omitted only when the
                          fulfillment channel defines a default warehouse group.
                        example: 1
                      fulfillment_channel_id:
                        type: integer
                        description: Fulfillment channel (`mt_channels.id`).
                        example: 11
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Target integration account (`app_integration_accounts.id`).
                        example: 3
                      destination_store_id:
                        type: integer
                        nullable: true
                        description: Optional ShipStation store id (`mt_shipstation_stores.id`).
                        example: null
                      prefer_before_proximity:
                        type: boolean
                        nullable: true
                        default: false
                        description: |
                          Location-aware lists only: pin this line ahead of distance ranking.
                          Preferred lines are tried first in their static `order`; the remaining
                          lines are ranked by distance from the warehouse group to the order's
                          ship-to address (warehouses without coordinates go last). Ignored when
                          `is_location_aware` is false.
                        example: false
      responses:
        '201':
          description: Priority list created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A fulfillment priority list (routing priority list). Defines the ordered set of
                      routing lines used to decide which warehouse group / fulfillment channel / destination
                      OMS a sales order's fulfillment orders are routed to.
                    properties:
                      id:
                        type: integer
                        example: 42
                      name:
                        type: string
                        example: Flexport
                      description:
                        type: string
                        nullable: true
                        example: Primary routing
                      is_location_aware:
                        type: boolean
                        description: 'When true, routing decisions take the order''s location into account.'
                        example: false
                      lines:
                        type: array
                        description: Ordered routing lines. Present when the `lines` relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 101
                            order:
                              type: integer
                              nullable: true
                              description: Zero-based priority rank of this line within the list.
                              example: 0
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              example: 1
                            destination_oms_id:
                              type: integer
                              nullable: true
                              description: Target integration account (`app_integration_accounts.id`).
                              example: 3
                            destination_store_id:
                              type: integer
                              nullable: true
                              description: Optional ShipStation store id (`mt_shipstation_stores.id`).
                              example: null
                            fulfillment_channel_id:
                              type: integer
                              nullable: true
                              description: Fulfillment channel (`mt_channels.id`).
                              example: 11
                            prefer_before_proximity:
                              type: boolean
                              description: |
                                When true on a location-aware list, this line is tried before the
                                proximity-ranked lines, in its static `order`. Lines without it are
                                ranked by distance to the ship-to address. Has no effect on lists
                                that are not location-aware.
                              example: false
                            warehouse_group:
                              type: object
                              nullable: true
                              description: Present only when the `warehouseGroup` relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                            fulfillment_channel:
                              type: object
                              nullable: true
                              description: Present only when the `fulfillmentChannel` relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                            destination_oms:
                              type: object
                              nullable: true
                              description: Present only when the destination integration account relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (e.g. duplicate name, missing lines, unknown foreign keys)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/fulfillment-priority-lists/{fulfillmentPriorityListId}':
    get:
      operationId: getFulfillmentPriorityList
      tags:
        - Fulfillment Priority Lists
      summary: Get a fulfillment priority list
      description: Retrieve a single fulfillment priority list with its routing lines.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentPriorityListId
          required: true
          schema:
            type: integer
          description: Fulfillment priority list ID
      responses:
        '200':
          description: The fulfillment priority list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A fulfillment priority list (routing priority list). Defines the ordered set of
                      routing lines used to decide which warehouse group / fulfillment channel / destination
                      OMS a sales order's fulfillment orders are routed to.
                    properties:
                      id:
                        type: integer
                        example: 42
                      name:
                        type: string
                        example: Flexport
                      description:
                        type: string
                        nullable: true
                        example: Primary routing
                      is_location_aware:
                        type: boolean
                        description: 'When true, routing decisions take the order''s location into account.'
                        example: false
                      lines:
                        type: array
                        description: Ordered routing lines. Present when the `lines` relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 101
                            order:
                              type: integer
                              nullable: true
                              description: Zero-based priority rank of this line within the list.
                              example: 0
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              example: 1
                            destination_oms_id:
                              type: integer
                              nullable: true
                              description: Target integration account (`app_integration_accounts.id`).
                              example: 3
                            destination_store_id:
                              type: integer
                              nullable: true
                              description: Optional ShipStation store id (`mt_shipstation_stores.id`).
                              example: null
                            fulfillment_channel_id:
                              type: integer
                              nullable: true
                              description: Fulfillment channel (`mt_channels.id`).
                              example: 11
                            prefer_before_proximity:
                              type: boolean
                              description: |
                                When true on a location-aware list, this line is tried before the
                                proximity-ranked lines, in its static `order`. Lines without it are
                                ranked by distance to the ship-to address. Has no effect on lists
                                that are not location-aware.
                              example: false
                            warehouse_group:
                              type: object
                              nullable: true
                              description: Present only when the `warehouseGroup` relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                            fulfillment_channel:
                              type: object
                              nullable: true
                              description: Present only when the `fulfillmentChannel` relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                            destination_oms:
                              type: object
                              nullable: true
                              description: Present only when the destination integration account relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Fulfillment priority list not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateFulfillmentPriorityList
      tags:
        - Fulfillment Priority Lists
      summary: Update a fulfillment priority list
      description: |
        Replace a fulfillment priority list's attributes and routing lines. The `lines` array
        is required and replaces the existing set.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentPriorityListId
          required: true
          schema:
            type: integer
          description: Fulfillment priority list ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Request body for creating or updating a fulfillment priority list.
              required:
                - name
                - lines
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: 'Unique list name (per tenant, among non-deleted lists).'
                  example: Flexport
                description:
                  type: string
                  nullable: true
                  example: Primary routing
                is_location_aware:
                  type: boolean
                  default: false
                  description: 'When true, routing decisions take the order''s location into account.'
                lines:
                  type: array
                  description: Ordered routing lines (at least one).
                  minItems: 1
                  items:
                    type: object
                    required:
                      - warehouse_group_id
                      - fulfillment_channel_id
                    properties:
                      order:
                        type: integer
                        minimum: 0
                        nullable: true
                        description: Zero-based priority rank of this line within the list.
                        example: 0
                      warehouse_group_id:
                        type: integer
                        description: |
                          Warehouse group (`warehouse_groups.id`). May be omitted only when the
                          fulfillment channel defines a default warehouse group.
                        example: 1
                      fulfillment_channel_id:
                        type: integer
                        description: Fulfillment channel (`mt_channels.id`).
                        example: 11
                      destination_oms_id:
                        type: integer
                        nullable: true
                        description: Target integration account (`app_integration_accounts.id`).
                        example: 3
                      destination_store_id:
                        type: integer
                        nullable: true
                        description: Optional ShipStation store id (`mt_shipstation_stores.id`).
                        example: null
                      prefer_before_proximity:
                        type: boolean
                        nullable: true
                        default: false
                        description: |
                          Location-aware lists only: pin this line ahead of distance ranking.
                          Preferred lines are tried first in their static `order`; the remaining
                          lines are ranked by distance from the warehouse group to the order's
                          ship-to address (warehouses without coordinates go last). Ignored when
                          `is_location_aware` is false.
                        example: false
      responses:
        '200':
          description: Priority list updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A fulfillment priority list (routing priority list). Defines the ordered set of
                      routing lines used to decide which warehouse group / fulfillment channel / destination
                      OMS a sales order's fulfillment orders are routed to.
                    properties:
                      id:
                        type: integer
                        example: 42
                      name:
                        type: string
                        example: Flexport
                      description:
                        type: string
                        nullable: true
                        example: Primary routing
                      is_location_aware:
                        type: boolean
                        description: 'When true, routing decisions take the order''s location into account.'
                        example: false
                      lines:
                        type: array
                        description: Ordered routing lines. Present when the `lines` relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 101
                            order:
                              type: integer
                              nullable: true
                              description: Zero-based priority rank of this line within the list.
                              example: 0
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              example: 1
                            destination_oms_id:
                              type: integer
                              nullable: true
                              description: Target integration account (`app_integration_accounts.id`).
                              example: 3
                            destination_store_id:
                              type: integer
                              nullable: true
                              description: Optional ShipStation store id (`mt_shipstation_stores.id`).
                              example: null
                            fulfillment_channel_id:
                              type: integer
                              nullable: true
                              description: Fulfillment channel (`mt_channels.id`).
                              example: 11
                            prefer_before_proximity:
                              type: boolean
                              description: |
                                When true on a location-aware list, this line is tried before the
                                proximity-ranked lines, in its static `order`. Lines without it are
                                ranked by distance to the ship-to address. Has no effect on lists
                                that are not location-aware.
                              example: false
                            warehouse_group:
                              type: object
                              nullable: true
                              description: Present only when the `warehouseGroup` relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                            fulfillment_channel:
                              type: object
                              nullable: true
                              description: Present only when the `fulfillmentChannel` relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                            destination_oms:
                              type: object
                              nullable: true
                              description: Present only when the destination integration account relation is eager-loaded.
                              properties:
                                id:
                                  type: integer
                                label:
                                  type: string
                                  nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (e.g. duplicate name, missing lines, unknown foreign keys)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteFulfillmentPriorityList
      tags:
        - Fulfillment Priority Lists
      summary: Delete a fulfillment priority list
      description: Soft-delete a fulfillment priority list. Returns `204 No Content` on success.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentPriorityListId
          required: true
          schema:
            type: integer
          description: Fulfillment priority list ID
      responses:
        '204':
          description: Priority list deleted
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Could not delete the priority list
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /products/alternate-sku:
    post:
      operationId: addAlternateSku
      tags:
        - Products
      summary: Add alternate SKU
      description: |
        Add an alternate SKU to a product. The alternate SKU can be used as an additional identifier
        for the product (e.g., for lookups during sales order creation).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sku
                - alternate_sku
              properties:
                sku:
                  type: string
                  description: Primary / master SKU of the product to attach the alternate SKU to
                alternate_sku:
                  type: string
                  description: The alternate SKU identifier to add
            example:
              sku: WIDGET-001
              alternate_sku: WIDGET-ALT-001
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteAlternateSku
      tags:
        - Products
      summary: Delete alternate SKU
      description: |
        Remove an alternate SKU from whichever product it is attached to. Matching is case-insensitive,
        mirroring the uniqueness check used by `POST /products/alternate-sku`.

        Useful for bulk cleanup (e.g. via script) instead of removing alternate SKUs by hand.
        Returns the deleted row, or `404` if no alternate SKU matches.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - alternate_sku
              properties:
                alternate_sku:
                  type: string
                  description: The alternate SKU value to delete (matched case-insensitively)
            example:
              alternate_sku: WIDGET-ALT-001
      responses:
        '200':
          description: Alternate SKU deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: ID of the deleted alternate SKU row
                  product_id:
                    type: integer
                    description: ID of the product the alternate SKU was attached to
                  product_sku:
                    type: string
                    description: Primary / master SKU of the product
                  alternate_sku:
                    type: string
                    description: The alternate SKU that was deleted
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: No alternate SKU matched the supplied value
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/products/{productId}/lots':
    get:
      operationId: listProductLots
      tags:
        - Lots
      summary: List a product's lots
      description: |
        Returns all lots for a product, newest first. Soft-deleted lots are
        excluded unless `include_deleted=1`; each lot carries `deletedAt`
        (`null` for a live lot). The same lot number can exist as a deleted lot
        and a live lot (e.g. after a lot was deleted and re-created) — pass both
        IDs to `GET /products/{productId}/qty-logs` to see the lot's full
        history. A product with no lots — including an unknown product ID —
        returns an empty list.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Luminous product (rfq) ID
        - in: query
          name: include_deleted
          required: false
          schema:
            type: boolean
            default: false
          description: Also return soft-deleted lots (`1`/`true`)
      responses:
        '200':
          description: The product's lots
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A product lot (batch) for a lot-tracked product. Holds metadata only —
                        lot quantities live in inventory stock and are changed through inventory
                        adjustments, not through the lot endpoints.
                      properties:
                        id:
                          type: integer
                          description: Unique lot identifier
                        createdAt:
                          type: string
                          format: date-time
                          description: When the lot was created
                        updatedAt:
                          type: string
                          format: date-time
                          description: When the lot was last updated
                        status:
                          type: integer
                          description: Lot status flag (1 = active)
                        rfqId:
                          type: integer
                          description: Luminous product (rfq) ID this lot belongs to
                        lotNumber:
                          type: string
                          nullable: true
                          description: |
                            Lot number, unique per product. Auto-generated from the production and
                            expiry dates when omitted on create.
                        manufacturerCode:
                          type: string
                          nullable: true
                          description: Optional manufacturer code for the lot
                        originalQuantity:
                          type: number
                          format: float
                          description: Quantity originally recorded against the lot
                        productionDate:
                          type: string
                          format: date-time
                          nullable: true
                          description: Production date of the lot
                        expiryDate:
                          type: string
                          format: date-time
                          nullable: true
                          description: Expiry date of the lot; always on or after the production date
                        deletedAt:
                          type: string
                          format: date-time
                          nullable: true
                          description: |
                            `null` for a live lot; when the lot was soft-deleted (only returned
                            with `include_deleted=1` on `GET /products/{productId}/lots`)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/products/{productId}/qty-logs':
    get:
      operationId: listProductQtyLogs
      tags:
        - Lots
      summary: List a product's Qty Log movements
      description: |
        Returns a product's (SKU's) Qty Log movements — the SKU's Qty Logs tab —
        filtered, sorted and paged on the server. Use it to trace a lot's
        inventory history: pass the IDs from
        `GET /products/{productId}/lots?include_deleted=1` to `lot_id[in]`
        (the same lot number can exist as a deleted lot and a live lot, so pass
        both IDs to see the lot's full history).

        Without `stock_type`, unfulfillable movements are left out unless the
        tenant tracks unfulfillable stock, as on the Qty Logs tab.

        Returns `404` for an unknown product.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Luminous product (rfq) ID
        - in: query
          name: 'lot_id[in]'
          required: false
          schema:
            type: string
          example: '460,1039'
          description: |
            Lot IDs, comma-separated (`lot_id[in]=460,1039`) or repeated
            (`lot_id[in][]=460&lot_id[in][]=1039`). `lot_id=460` and
            `lot_id[]=460` also work. IDs of deleted lots work. Any other shape
            is a 422 (never a fallback to the whole SKU's history).
        - in: query
          name: stock_type
          required: false
          schema:
            type: string
            enum:
              - onhand
              - on_hand
              - pending
              - incoming
              - committed
              - unfulfillable
          description: Which quantity moved (`on_hand` is an alias for `onhand`)
        - in: query
          name: transaction_type
          required: false
          schema:
            type: string
            maxLength: 100
          description: |
            A Qty Logs tab key or the stored transaction text itself (e.g.
            `ASSEMBLY ORDER ITEM ROLLBACK`). Keys: `adjustment_entry`,
            `defective_report`, `pick_manual`, `pick_auto`, `pick_auto_shipped`,
            `purchase_order`, `receiving_report`, `sku_location_transfer`,
            `pending_sku_recount`, `pending_cleared_not_owned`,
            `pending_kit_recount`, `import_quantities`, `picklist`, `sales_order`,
            `transfer_order`, `assembly_order`, `assembly_order_item`,
            `work_order`
        - in: query
          name: order_number
          required: false
          schema:
            type: string
            maxLength: 100
          description: Contains match on the movement's order number
        - in: query
          name: channel_id
          required: false
          schema:
            type: integer
            minimum: 1
          description: The order's channel
        - in: query
          name: warehouse_id
          required: false
          schema:
            type: integer
            minimum: 1
          description: Warehouse of the movement
        - in: query
          name: 'date[gte]'
          required: false
          schema:
            type: string
            format: date
          description: 'Movements on or after this date (`YYYY-MM-DD`, inclusive, UTC)'
        - in: query
          name: 'date[lte]'
          required: false
          schema:
            type: string
            format: date
          description: 'Movements on or before this date (`YYYY-MM-DD`, inclusive, UTC)'
        - in: query
          name: sort
          required: false
          schema:
            type: string
            enum:
              - '-date'
              - date
              - 'date:desc'
              - 'date:asc'
            default: '-date'
          description: |
            Newest (`-date`) or oldest (`date`) first; ties keep insertion order.
            `date:desc` and `date:asc` are aliases of `-date` and `date`.
        - in: query
          name: page
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Page number
        - in: query
          name: per_page
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Results per page (max 500)
      responses:
        '200':
          description: A page of the product's Qty Log movements
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        One Qty Log movement for a product (a row of the SKU's Qty Logs tab).
                        The three balances are snapshots stored with each movement, one per
                        scope, and are returned as stored — summing `qty_change` can differ
                        from them, because some writes move a balance without a row of their
                        own. No balance across all warehouses is stored.
                      properties:
                        id:
                          type: integer
                          description: Qty Log row ID
                        date:
                          type: string
                          format: date-time
                          description: When the movement was recorded
                        transaction_type:
                          type: string
                          description: 'Stored transaction text, e.g. `ADJUSTMENT ENTRY`, `RECEIVING REPORT`, `ASSEMBLY ORDER ITEM`'
                        stock_type:
                          type: string
                          description: Which quantity moved
                          enum:
                            - onhand
                            - pending
                            - incoming
                            - committed
                            - unfulfillable
                        action:
                          type: string
                          description: 'Movement action, e.g. `ADD`, `SUBTRACT`'
                        qty_change:
                          type: number
                          format: float
                          description: |
                            Signed quantity change — negative for `SUBTRACT`, as on the Qty Logs
                            tab. Uses the row's ordered quantity, or its quantity when no ordered
                            quantity was recorded (the tab shows 0 for those rows).
                        running_balance:
                          type: number
                          format: float
                          description: Stored balance of the SKU in that warehouse after the movement
                        location_running_balance:
                          type: number
                          format: float
                          description: Stored balance of the bin after the movement
                        lot_running_balance:
                          type: number
                          format: float
                          description: Stored balance of the lot (on that stock row) after the movement
                        order_number:
                          type: string
                          nullable: true
                          description: Order number of the movement
                        channel:
                          type: object
                          nullable: true
                          description: The order's channel
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                        warehouse:
                          type: object
                          nullable: true
                          description: Warehouse of the movement
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        location:
                          type: object
                          nullable: true
                          description: The bin
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        lot_id:
                          type: integer
                          nullable: true
                          description: Lot ID
                        lot_number:
                          type: string
                          nullable: true
                          description: Lot number; present for deleted lots too
                        lot_deleted:
                          type: boolean
                          description: '`true` when the lot has been deleted'
                        user:
                          type: object
                          nullable: true
                          description: User who recorded the movement
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        note:
                          type: string
                          nullable: true
                          description: 'Adjustment remarks, or the movement''s own remarks'
                  links:
                    type: object
                    description: Pagination links
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (e.g. an unreadable `lot_id` shape, an unknown `stock_type`, or `per_page` over 500)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/products/{productId}/boms':
    post:
      operationId: attachBomsToProduct
      tags:
        - Products
      summary: Attach BOMs to a product
      description: |
        Associate one or more BOMs with a product by providing an array of BOM IDs.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Product ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - bom_ids
              properties:
                bom_ids:
                  type: array
                  items:
                    type: integer
                  minItems: 1
                  description: Array of BOM IDs to attach to the product
            example:
              bom_ids:
                - 1
                - 2
                - 3
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: detachBomsFromProduct
      tags:
        - Products
      summary: Detach BOMs from a product
      description: |
        Remove one or more BOM associations from a product by providing an array of BOM IDs.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Product ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - bom_ids
              properties:
                bom_ids:
                  type: array
                  items:
                    type: integer
                  minItems: 1
                  description: Array of BOM IDs to detach from the product
            example:
              bom_ids:
                - 1
                - 2
                - 3
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/products/{productId}/substitutions':
    post:
      operationId: addProductSubstitution
      tags:
        - Products
      summary: Add product substitution
      description: |
        Add a substitute product to a product. Substitutes are alternative products that can
        fulfill the same demand — useful when the primary product is out of stock or unavailable.

        Each substitution links the primary product to a single substitute product and an
        optional priority. Priority controls the order substitutes are considered (lower numbers
        are tried first). Call this endpoint once per substitute product you want to attach.

        The response returns the created substitution record, including the embedded substitute
        product. The `id` field on the response is the substitution row's ID — use it with the
        DELETE endpoint to remove the substitution later.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: ID of the product receiving the substitute
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - substitute_product_id
              properties:
                substitute_product_id:
                  type: integer
                  description: ID of the product to add as a substitute for the primary product
                priority:
                  type: integer
                  nullable: true
                  description: |
                    Optional ordering hint. Lower numbers indicate higher priority (tried first).
                    If omitted (or null), the substitute is appended after the product's existing
                    substitutes (priority = current highest priority + 1, starting at 1).
            example:
              substitute_product_id: 1234
              priority: 1
      responses:
        '201':
          description: Substitution created
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: |
                      Substitution row ID. Use this with the DELETE endpoint to remove the substitution.
                  priority:
                    type: integer
                    nullable: true
                    description: |
                      Ordering hint — lower numbers are tried first when looking for a substitute.
                  product:
                    description: |
                      Embedded substitute product. Always present on responses from the substitutions
                      endpoints (the substitute product is eager-loaded server-side).
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the product
                      name:
                        type: string
                        description: Product name
                      description:
                        type: string
                        nullable: true
                        description: Product description
                      retail_price:
                        type: number
                        format: float
                        description: Retail price
                      wholesale_price:
                        type: number
                        format: float
                        description: Wholesale price
                      unit_cost:
                        type: number
                        format: float
                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                      purchase_unit_cost:
                        type: number
                        format: float
                        nullable: true
                        description: |
                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                      purchase_currency:
                        type: string
                        nullable: true
                        description: |
                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                      landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: Landed cost per unit
                      estimated_landed_cost:
                        type: number
                        format: float
                        nullable: true
                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                      design_link:
                        type: string
                        nullable: true
                        description: Product design URL or link. `null` when unset or empty.
                      manufacturing_fee:
                        type: number
                        format: float
                        nullable: true
                        description: Manufacturing fee per unit
                      product_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      product_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in ounces (computed from product_weight)
                      product_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total product weight in pounds (computed from product_weight)
                      dimensional_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      dimensional_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                      dimensional_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                      product_length:
                        type: number
                        format: float
                        description: Length of the product (in inches)
                      product_width:
                        type: number
                        format: float
                        description: Width of the product (in inches)
                      product_height:
                        type: number
                        format: float
                        description: Height of the product (in inches)
                      box_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      box_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in ounces (computed from box_weight)
                      box_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total box weight in pounds (computed from box_weight)
                      box_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the box (in inches)
                      box_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the box (in inches)
                      box_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the box (in inches)
                      carton_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      carton_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in ounces (computed from carton_weight)
                      carton_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total carton weight in pounds (computed from carton_weight)
                      carton_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the carton (in inches)
                      carton_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the carton (in inches)
                      carton_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the carton (in inches)
                      units_per_carton:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                      shipping_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      shipping_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in ounces (computed from shipping_weight)
                      shipping_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total shipping weight in pounds (computed from shipping_weight)
                      shipping_length:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping length (in inches)
                      shipping_width:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping width (in inches)
                      shipping_height:
                        type: number
                        format: float
                        nullable: true
                        description: Shipping height (in inches)
                      pallet_weight:
                        type: array
                        nullable: true
                        items:
                          type: object
                          required:
                            - unit
                            - value
                          properties:
                            unit:
                              type: string
                              enum:
                                - lb
                                - oz
                              description: Weight unit
                            value:
                              type: number
                              format: float
                              minimum: 0
                              description: Weight value
                      pallet_weight_oz:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in ounces (computed from pallet_weight)
                      pallet_weight_lb:
                        type: number
                        format: float
                        nullable: true
                        description: Total pallet weight in pounds (computed from pallet_weight)
                      pallet_length:
                        type: number
                        format: float
                        nullable: true
                        description: Length of the pallet (in inches)
                      pallet_width:
                        type: number
                        format: float
                        nullable: true
                        description: Width of the pallet (in inches)
                      pallet_height:
                        type: number
                        format: float
                        nullable: true
                        description: Height of the pallet (in inches)
                      cartons_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                      units_per_pallet:
                        type: number
                        format: float
                        nullable: true
                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                      default_receiving_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                      default_assembly_location_id:
                        type: integer
                        nullable: true
                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                      lead_time_days:
                        type: integer
                        nullable: true
                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                      sellable:
                        type: boolean
                        description: Whether the product can be sold
                      discontinued:
                        type: boolean
                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                      is_drop_ship_item:
                        type: boolean
                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                      taxable:
                        type: boolean
                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                      lot_tracking:
                        type: boolean
                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                      lot_deduction_strategy:
                        type: string
                        nullable: true
                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                      round_up_as_component:
                        type: boolean
                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                      default_supply_method:
                        type: string
                        nullable: true
                        enum:
                          - purchase
                          - vendor_supplied
                          - assemble
                          - on_hand
                          - assembly_order
                          - buy_and_ship
                          - brand_supplied
                        description: Default supply mode used when planning replenishment for this product
                      image_url:
                        type: string
                        nullable: true
                        description: URL to the product's main image
                      images:
                        type: array
                        description: |
                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                          them again rather than storing them.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                            url:
                              type: string
                              description: Presigned URL of the full-size image.
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: Presigned URL of the thumbnail.
                            position:
                              type: integer
                              description: 1-based position in the gallery.
                      category:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product category information
                      subcategory:
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                        description: Product subcategory information
                      custom_fields:
                        type: object
                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties:
                          type: string
                      attachments:
                        type: array
                        description: Product attachments
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the attachment
                            name:
                              type: string
                              description: Filename of the attachment
                            type:
                              type: string
                              description: MIME type of the attachment
                            size:
                              type: integer
                              description: File size in bytes
                            full_url:
                              type: string
                              description: Full resolution URL of the attachment
                            thumb_url:
                              type: string
                              description: Thumbnail URL of the attachment (if applicable)
                          required:
                            - id
                            - name
                            - type
                            - size
                            - full_url
                      variants:
                        type: array
                        description: Product variants
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            product_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            product_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            product_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            dimensional_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            dimensional_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            box_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            box_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            box_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            carton_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            carton_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            carton_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            shipping_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            shipping_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight:
                              type: array
                              nullable: true
                              items:
                                type: object
                                required:
                                  - unit
                                  - value
                                properties:
                                  unit:
                                    type: string
                                    enum:
                                      - lb
                                      - oz
                                    description: Weight unit
                                  value:
                                    type: number
                                    format: float
                                    minimum: 0
                                    description: Weight value
                            pallet_weight_oz:
                              type: number
                              format: float
                              nullable: true
                            pallet_weight_lb:
                              type: number
                              format: float
                              nullable: true
                            attachments:
                              type: array
                              description: Variant-specific attachments
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the attachment
                                  name:
                                    type: string
                                    description: Filename of the attachment
                                  type:
                                    type: string
                                    description: MIME type of the attachment
                                  size:
                                    type: integer
                                    description: File size in bytes
                                  full_url:
                                    type: string
                                    description: Full resolution URL of the attachment
                                  thumb_url:
                                    type: string
                                    description: Thumbnail URL of the attachment (if applicable)
                                required:
                                  - id
                                  - name
                                  - type
                                  - size
                                  - full_url
                            retail_price:
                              type: number
                              format: float
                            wholesale_price:
                              type: number
                              format: float
                            custom_fields:
                              type: array
                              items:
                                type: object
                            variant_attributes:
                              type: array
                              nullable: true
                              description: |
                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                on that axis.
                              items:
                                type: object
                                properties:
                                  variant_name:
                                    type: string
                                    description: Name of the variant axis (e.g. "Size")
                                  variant_terms:
                                    type: array
                                    description: Term value(s) selected for this child on that axis
                                    items:
                                      type: string
                            sku:
                              type: string
                            upc:
                              type: string
                            hs_code:
                              type: string
                              nullable: true
                              description: HS/HTS tariff code for the product (max 50 characters)
                            round_up_as_component:
                              type: boolean
                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      variant_attributes:
                        type: array
                        nullable: true
                        description: |
                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                          child variant, this holds the specific term(s) the child is assigned to.

                          Set via the request field `product_variants` (same shape) on create/update.
                        items:
                          type: object
                          properties:
                            variant_name:
                              type: string
                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                            variant_terms:
                              type: array
                              description: Terms on this axis
                              items:
                                type: string
                      sku:
                        type: string
                        description: Internal SKU
                      alternate_skus:
                        type: array
                        description: Alternate SKUs
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                      upc:
                        type: string
                        description: UPC/Barcode
                      hs_code:
                        type: string
                        nullable: true
                        description: HS/HTS tariff code for the product (max 50 characters)
                      tags:
                        type: array
                        description: Tags associated with the product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the tag
                            name:
                              type: string
                              description: Name of the tag
                            description:
                              type: string
                              nullable: true
                              description: Description of the tag
                            icon:
                              type: string
                              nullable: true
                              description: Icon identifier or URL for the tag
                            color:
                              type: string
                              nullable: true
                              description: Color code for the tag
                          required:
                            - id
                            - name
                      substitutions:
                        type: array
                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Substitution record ID
                            priority:
                              type: integer
                              description: Substitution priority (lower number = higher priority)
                            product:
                              type: object
                              description: The substitute product
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the product
                                name:
                                  type: string
                                  description: Product name
                                description:
                                  type: string
                                  nullable: true
                                  description: Product description
                                retail_price:
                                  type: number
                                  format: float
                                  description: Retail price
                                wholesale_price:
                                  type: number
                                  format: float
                                  description: Wholesale price
                                unit_cost:
                                  type: number
                                  format: float
                                  description: Cost per unit
                                product_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                product_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                product_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                dimensional_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                dimensional_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                product_length:
                                  type: number
                                  format: float
                                  description: Length of the product (in inches)
                                product_width:
                                  type: number
                                  format: float
                                  description: Width of the product (in inches)
                                product_height:
                                  type: number
                                  format: float
                                  description: Height of the product (in inches)
                                box_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                box_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                box_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                box_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the box (in inches)
                                box_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the box (in inches)
                                box_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the box (in inches)
                                carton_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                carton_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                carton_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the carton (in inches)
                                carton_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the carton (in inches)
                                carton_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the carton (in inches)
                                shipping_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                shipping_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                shipping_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping length (in inches)
                                shipping_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping width (in inches)
                                shipping_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Shipping height (in inches)
                                pallet_weight:
                                  type: array
                                  nullable: true
                                  items:
                                    type: object
                                    required:
                                      - unit
                                      - value
                                    properties:
                                      unit:
                                        type: string
                                        enum:
                                          - lb
                                          - oz
                                        description: Weight unit
                                      value:
                                        type: number
                                        format: float
                                        minimum: 0
                                        description: Weight value
                                pallet_weight_oz:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_weight_lb:
                                  type: number
                                  format: float
                                  nullable: true
                                pallet_length:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Length of the pallet (in inches)
                                pallet_width:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Width of the pallet (in inches)
                                pallet_height:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Height of the pallet (in inches)
                                sellable:
                                  type: boolean
                                  description: Whether the product can be sold
                                discontinued:
                                  type: boolean
                                  description: Whether the product is discontinued
                                is_drop_ship_item:
                                  type: boolean
                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                taxable:
                                  type: boolean
                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                image_url:
                                  type: string
                                  nullable: true
                                  description: URL to the product's main image
                                sku:
                                  type: string
                                  description: Internal SKU
                                upc:
                                  type: string
                                  description: UPC/Barcode
                                hs_code:
                                  type: string
                                  nullable: true
                                  description: HS/HTS tariff code for the product (max 50 characters)
                                round_up_as_component:
                                  type: boolean
                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                created_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was created
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: Timestamp when the product was last updated
                      supplier:
                        type: object
                        nullable: true
                        description: Supplier information
                      type:
                        type: string
                        enum:
                          - PRODUCT
                          - KIT
                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                      kit_items:
                        type: array
                        nullable: true
                        description: Kit items (components) for kit products. Only present when type = KIT.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the kit item
                            product_id:
                              type: integer
                              description: ID of the product component
                            quantity:
                              type: number
                              format: float
                              description: Quantity of this component in the kit
                            uom_id:
                              type: integer
                              description: Unit of measure ID for the quantity
                            base_uom_quantity:
                              type: number
                              format: float
                              description: Quantity converted to base unit of measure
                            price:
                              type: number
                              format: float
                              description: Price for this kit item
                            original_price:
                              type: number
                              format: float
                              description: Original price for this kit item
                            total:
                              type: number
                              format: float
                              description: Calculated total (quantity * price)
                            product:
                              type: object
                              nullable: true
                              description: Product information for this kit item (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                retail_price:
                                  type: number
                                  format: float
                                wholesale_price:
                                  type: number
                                  format: float
                            unit_of_measure:
                              type: object
                              nullable: true
                              description: Unit of measure information (when loaded)
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                      priority_list:
                        type: object
                        nullable: true
                        description: Fulfillment priority list assigned to this product
                        properties:
                          id:
                            type: integer
                            description: Priority list ID
                          name:
                            type: string
                            description: Priority list name
                          description:
                            type: string
                            nullable: true
                            description: Priority list description
                      distribution_template:
                        type: object
                        nullable: true
                        description: |
                          The distribution template (size curve) directly assigned to this product.
                          Returns `null` when no template is assigned (the tenant default applies
                          when resolving for production-run drafting). Use the dedicated
                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                          name:
                            type: string
                            description: Distribution template name
                          source:
                            type: string
                            enum:
                              - assigned
                            description: Always `assigned` — only directly assigned templates are returned here.
                      distribution_template_category:
                        type: object
                        nullable: true
                        description: |
                          The size-curve category assigned to this master SKU, used for
                          category × warehouse resolution of a distribution template when no
                          template is directly pinned. Returns `null` when no category is assigned.
                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                          endpoint to assign one.
                        properties:
                          id:
                            type: integer
                            description: Size-curve category ID
                          name:
                            type: string
                            description: Size-curve category name
                      boms:
                        type: array
                        description: BOMs (Bills of Materials) associated with this product
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the BOM
                            name:
                              type: string
                              description: BOM name
                            items:
                              type: array
                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the BOM item
                                  bom_id:
                                    type: integer
                                    description: ID of the BOM this item belongs to
                                  product_id:
                                    type: integer
                                    description: ID of the product/component
                                  product:
                                    type: object
                                    nullable: true
                                    description: Product information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity required for this item
                                  base_quantity:
                                    type: number
                                    format: float
                                    description: Base quantity (converted to base unit of measure)
                                  note:
                                    type: string
                                    nullable: true
                                    description: Optional note for this item
                                  uom_id:
                                    type: integer
                                    nullable: true
                                    description: Unit of measure ID
                                  unit_of_measure:
                                    type: object
                                    nullable: true
                                    description: Unit of measure information (when loaded)
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                  order:
                                    type: integer
                                    nullable: true
                                    description: Display order for this item
                                  consumption_basis:
                                    type: string
                                    enum:
                                      - planned
                                      - actual
                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the item was last updated
                                required:
                                  - id
                                  - bom_id
                                  - product_id
                                  - quantity
                            extra_costs:
                              type: array
                              description: Additional costs associated with the BOM
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the extra cost
                                  name:
                                    type: string
                                    description: Name/description of the extra cost
                                  quantity:
                                    type: number
                                    format: float
                                    description: Quantity for this cost item
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Unit price for this cost item
                                  line_total:
                                    type: number
                                    format: float
                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Timestamp when the extra cost was last updated
                                required:
                                  - id
                                  - name
                                  - quantity
                                  - unit_price
                                  - line_total
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the BOM was last updated
                          required:
                            - id
                            - name
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the product was last updated
                      created_by:
                        type: integer
                        description: |
                          ID of the user who created the product. `0` for products created before
                          provenance was recorded or by a system path with no attributable user.
                          Products created through the External API are stamped with the API token's user.
                      updated_by:
                        type: integer
                        description: ID of the user who last updated the product. `0` when never attributed.
                      created_via:
                        type: string
                        nullable: true
                        enum:
                          - user
                          - api
                          - import
                          - auto_create_sku
                          - job
                          - system
                        description: |
                          How the product was created, stamped once at creation and never changed:
                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                          console command), or `system` (other internal write). `null` for products created
                          before provenance was recorded (unknown source).

                          Always present on single-product responses. On product **list** endpoints
                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                          it is only returned when requested with `?include=created_via`.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Primary product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (e.g., substitute product not found or inactive, duplicate substitution, or the substitute would create a cycle)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/products/{productId}/substitutions/{substitutionId}':
    delete:
      operationId: removeProductSubstitution
      tags:
        - Products
      summary: Remove product substitution
      description: |
        Remove a substitute product from a product by substitution row ID. The endpoint
        verifies the substitution belongs to the given `productId` before deleting it —
        a mismatched pair returns 404.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: ID of the primary product
        - in: path
          name: substitutionId
          required: true
          schema:
            type: integer
          description: ID of the substitution row to remove (returned from the create endpoint as `id`)
      responses:
        '200':
          description: Substitution removed
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Substitution not found for this product
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Service-level failure removing the substitution
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/products/{productId}/distribution-template/candidates':
    get:
      operationId: getProductDistributionTemplateCandidates
      tags:
        - Products
      summary: List distribution template candidates for a product
      description: |
        Returns the distribution templates (size curves) that are compatible with
        a master SKU's variant axes. Only master SKUs with at least one variant
        axis defined will have candidates — child/variant SKUs and flat products
        return an empty list.

        Use this endpoint to discover which templates can be assigned via
        `PUT /products/{productId}/distribution-template`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Product ID (must be a master SKU)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: Compatible distribution templates for this product.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Distribution template ID
                        name:
                          type: string
                          description: Distribution template name
                        description:
                          type: string
                          nullable: true
                          description: Distribution template description
                        is_default:
                          type: boolean
                          description: Whether this is the tenant's default template
                        category_id:
                          type: integer
                          nullable: true
                          description: |
                            Size-curve category this template belongs to, or `null`
                            when the template is not scoped to a category.
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: |
                            Warehouse this template is scoped to for category ×
                            warehouse resolution, or `null` when not warehouse-scoped.
                        axis_count:
                          type: integer
                          enum:
                            - 1
                            - 2
                          description: 'Number of axes on the template (1 = single axis, 2 = dual axis)'
                        row_values:
                          description: Row-axis values with their percent share (used by dual-axis templates).
                          type: array
                          items:
                            type: object
                            properties:
                              value:
                                type: string
                                description: Axis value (e.g. a size or color)
                              percent:
                                type: number
                                description: 'Share of this axis value, in percent (0–100, two decimals)'
                              sort_order:
                                type: integer
                        column_values:
                          description: Column-axis values with their percent share.
                          type: array
                          items:
                            type: object
                            properties:
                              value:
                                type: string
                                description: Axis value (e.g. a size or color)
                              percent:
                                type: number
                                description: 'Share of this axis value, in percent (0–100, two decimals)'
                              sort_order:
                                type: integer
                        cells:
                          type: array
                          description: |
                            Per-cell weights. On a single-axis template there is one cell per
                            column value, with `weight` = `percent / 100`. On a dual-axis template
                            there is one cell per row × column pair, and the weight is the product
                            of the row and column shares.
                          items:
                            type: object
                            properties:
                              size:
                                type: string
                                description: Column-axis value for this cell
                              axis:
                                type: string
                                enum:
                                  - column
                              row_value:
                                type: string
                                description: Row-axis value (dual-axis templates only)
                              column_value:
                                type: string
                                description: Column-axis value (dual-axis templates only)
                              percent:
                                type: number
                                description: Cell share in percent (two decimals)
                              weight:
                                type: number
                                description: Cell share as a fraction (four decimals)
              example:
                data:
                  - id: 12
                    name: Women's Tops - Standard
                    description: Standard size curve for women's tops
                    is_default: true
                    category_id: 3
                    warehouse_id: null
                    axis_count: 1
                    column_values:
                      - value: S
                        percent: 25
                        sort_order: 0
                      - value: M
                        percent: 50
                        sort_order: 1
                      - value: L
                        percent: 25
                        sort_order: 2
                    cells:
                      - size: S
                        axis: column
                        percent: 25
                        weight: 0.25
                      - size: M
                        axis: column
                        percent: 50
                        weight: 0.5
                      - size: L
                        axis: column
                        percent: 25
                        weight: 0.25
                  - id: 17
                    name: Women's Tops - Petite
                    description: Size curve skewed for petite sizing
                    is_default: false
                    category_id: 3
                    warehouse_id: 8
        '400':
          description: Product is not eligible for template assignment (e.g. not a master SKU)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/products/{productId}/distribution-template':
    put:
      operationId: setProductDistributionTemplate
      tags:
        - Products
      summary: Assign a distribution template to a product
      description: |
        Assigns a distribution template (size curve) to a master SKU. The template
        must be compatible with the product's variant axes — use
        `GET /products/{productId}/distribution-template/candidates` to find valid
        options. Only master SKUs with variant axes defined can be assigned a template.

        The assigned template is returned in the `distribution_template` field on
        the product response and overrides the tenant default when resolving for
        production-run drafting.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Product ID (must be a master SKU)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - distribution_template_id
              properties:
                distribution_template_id:
                  type: integer
                  description: ID of the distribution template to assign
            example:
              distribution_template_id: 12
      responses:
        '200':
          description: Template assigned successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Distribution template ID
                      name:
                        type: string
                        description: Distribution template name
                      source:
                        type: string
                        enum:
                          - assigned
                        description: Always `assigned`
                  message:
                    type: string
                    description: Confirmation message
              example:
                data:
                  id: 12
                  name: Women's Tops - Standard
                  source: assigned
                message: Distribution template assigned.
        '400':
          description: Assignment failed (e.g. template axes incompatible with product)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: clearProductDistributionTemplate
      tags:
        - Products
      summary: Clear a product's distribution template assignment
      description: |
        Removes the directly assigned distribution template from a product. After
        clearing, the product returns `null` for `distribution_template` on the
        product response, and the tenant default template applies when resolving
        for production-run drafting.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Product ID
      responses:
        '200':
          description: Template assignment cleared successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Confirmation message
              example:
                message: Distribution template cleared.
        '400':
          description: Failed to clear assignment
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/products/{productId}/distribution-template-category':
    put:
      operationId: setProductDistributionTemplateCategory
      tags:
        - Products
      summary: Assign a size-curve category to a product
      description: |
        Assigns a size-curve category to a master SKU. When a category is assigned
        (and no distribution template is directly pinned), the category is used for
        category × warehouse resolution of a distribution template at production-run
        drafting time. A directly pinned template always wins over category ×
        warehouse resolution.

        Only master SKUs can be assigned a size-curve category, and the category
        must be active. The assigned category is returned in the
        `distribution_template_category` field on the product response.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Product ID (must be a master SKU)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - category_id
              properties:
                category_id:
                  type: integer
                  minimum: 1
                  description: ID of the size-curve category to assign
            example:
              category_id: 3
      responses:
        '200':
          description: Category assigned successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Size-curve category ID
                      name:
                        type: string
                        description: Size-curve category name
                  message:
                    type: string
                    description: Confirmation message
              example:
                data:
                  id: 3
                  name: Women's Tops
                message: Size-curve category assigned.
        '400':
          description: 'Assignment failed (e.g. not a master SKU, or the category is inactive)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product or category not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: clearProductDistributionTemplateCategory
      tags:
        - Products
      summary: Clear a product's size-curve category
      description: |
        Removes the size-curve category assignment from a master SKU. After
        clearing, the product returns `null` for `distribution_template_category`
        on the product response and no longer participates in category × warehouse
        resolution.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: productId
          required: true
          schema:
            type: integer
          description: Product ID
      responses:
        '200':
          description: Category assignment cleared successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Confirmation message
              example:
                message: Size-curve category removed from SKU.
        '400':
          description: Failed to clear assignment
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /distribution-templates:
    get:
      operationId: listDistributionTemplates
      tags:
        - Products
      summary: List distribution templates
      description: |
        Returns every active distribution template. A distribution template is a size curve: it
        splits a total quantity for a master SKU across that SKU's variants, on one axis (e.g. Size)
        or two (e.g. Color × Size).

        The list is not paginated and inactive templates are left out.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A distribution template (size curve) that splits a master SKU total across its variants.
                      properties:
                        id:
                          type: integer
                          description: Distribution template ID
                          example: 12
                        name:
                          type: string
                          description: 'Template name, unique among non-deleted templates'
                          example: Apparel sizes
                        description:
                          type: string
                          nullable: true
                          description: Template description
                        axis_count:
                          type: integer
                          enum:
                            - 1
                            - 2
                          description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                        mode:
                          type: string
                          enum:
                            - single_axis
                            - dual_axis
                          description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                        row_axis_name:
                          type: string
                          nullable: true
                          description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                        column_axis_name:
                          type: string
                          description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                          example: Size
                        row_values:
                          type: array
                          description: Row-axis values with their percent share. Empty on a single-axis template.
                          items:
                            type: object
                            properties:
                              value:
                                type: string
                                description: Axis value (e.g. a size or color)
                                example: M
                              percent:
                                type: number
                                description: 'Share of this axis value, in percent (0–100, two decimals)'
                                example: 60
                              sort_order:
                                type: integer
                                description: Position of the value on its axis
                                example: 1
                        column_values:
                          type: array
                          description: Column-axis values with their percent share.
                          items:
                            type: object
                            properties:
                              value:
                                type: string
                                description: Axis value (e.g. a size or color)
                                example: M
                              percent:
                                type: number
                                description: 'Share of this axis value, in percent (0–100, two decimals)'
                                example: 60
                              sort_order:
                                type: integer
                                description: Position of the value on its axis
                                example: 1
                        cells:
                          type: array
                          description: |
                            Per-cell weights. On a single-axis template there is one cell per column value, with
                            `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                            pair, and the weight is the product of the row and column shares.
                          items:
                            type: object
                            properties:
                              size:
                                type: string
                                description: Column-axis value for this cell
                              axis:
                                type: string
                                enum:
                                  - column
                              row_value:
                                type: string
                                description: Row-axis value (dual-axis templates only)
                              column_value:
                                type: string
                                description: Column-axis value (dual-axis templates only)
                              percent:
                                type: number
                                description: Cell share in percent (two decimals)
                              weight:
                                type: number
                                description: Cell share as a fraction (four decimals)
                        is_default:
                          type: boolean
                          description: Whether this is the tenant's default template
                        is_active:
                          type: boolean
                          description: Whether the template is active
                        category_id:
                          type: integer
                          nullable: true
                          description: 'Size-curve category the template belongs to, or `null`'
                        category_name:
                          type: string
                          nullable: true
                          description: 'Name of that category, or `null`'
                        warehouse_id:
                          type: integer
                          nullable: true
                          description: |
                            Destination warehouse the template is scoped to for category × warehouse resolution,
                            or `null` when it is not warehouse-scoped.
                      example:
                        id: 12
                        name: Apparel sizes
                        description: null
                        axis_count: 1
                        mode: single_axis
                        row_axis_name: null
                        column_axis_name: Size
                        row_values: []
                        column_values:
                          - value: S
                            percent: 40
                            sort_order: 0
                          - value: M
                            percent: 60
                            sort_order: 1
                        cells:
                          - size: S
                            axis: column
                            percent: 40
                            weight: 0.4
                          - size: M
                            axis: column
                            percent: 60
                            weight: 0.6
                        is_default: false
                        is_active: true
                        category_id: null
                        category_name: null
                        warehouse_id: null
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createDistributionTemplate
      tags:
        - Products
      summary: Create a distribution template
      description: |
        Creates a distribution template (size curve). Each axis lists its values with a percent
        share, and the shares on an axis must total 100. A single-axis template uses the column axis
        only; a dual-axis template also needs `row_axis_name` and `row_values`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - axis_count
                - column_axis_name
                - column_values
              properties:
                name:
                  type: string
                  maxLength: 191
                  description: |
                    Template name. Must be unique among non-deleted templates; on update, sending the
                    template's current name is allowed.
                  example: Apparel sizes
                description:
                  type: string
                  nullable: true
                  maxLength: 2000
                axis_count:
                  type: integer
                  enum:
                    - 1
                    - 2
                  description: '`1` for a single-axis template, `2` for a dual-axis (row × column) template.'
                column_axis_name:
                  type: string
                  maxLength: 191
                  description: 'Variant type on the column axis, e.g. `Size`.'
                  example: Size
                column_values:
                  type: array
                  minItems: 1
                  maxItems: 200
                  description: Column-axis values. Values must be distinct and their percents must total 100.
                  items:
                    type: object
                    required:
                      - value
                      - percent
                    properties:
                      value:
                        type: string
                        maxLength: 191
                        description: Axis value (e.g. a size or color)
                        example: M
                      percent:
                        type: number
                        minimum: 0
                        maximum: 100
                        description: |
                          Share of this value in percent. The values on one axis must total 100, to within 0.01
                          (so twelve values of 8.33 are rejected; use eight at 8.33 and four at 8.34).
                        example: 60
                      sort_order:
                        type: integer
                        minimum: 0
                        nullable: true
                        description: Position on the axis. Defaults to the value's index in the array.
                row_axis_name:
                  type: string
                  nullable: true
                  maxLength: 191
                  description: |
                    Variant type on the row axis. Required when `axis_count` is `2`, and must be a different
                    variant type from `column_axis_name`. Rejected on a single-axis template.
                row_values:
                  type: array
                  maxItems: 200
                  description: |
                    Row-axis values, same shape and rules as `column_values`. Required when `axis_count` is
                    `2`; rejected on a single-axis template.
                  items:
                    type: object
                    required:
                      - value
                      - percent
                    properties:
                      value:
                        type: string
                        maxLength: 191
                        description: Axis value (e.g. a size or color)
                        example: M
                      percent:
                        type: number
                        minimum: 0
                        maximum: 100
                        description: |
                          Share of this value in percent. The values on one axis must total 100, to within 0.01
                          (so twelve values of 8.33 are rejected; use eight at 8.33 and four at 8.34).
                        example: 60
                      sort_order:
                        type: integer
                        minimum: 0
                        nullable: true
                        description: Position on the axis. Defaults to the value's index in the array.
                is_default:
                  type: boolean
                  default: false
                  description: Make this the tenant default. Promoting a template clears the previous default.
                is_active:
                  type: boolean
                  default: true
                sort_order:
                  type: integer
                  minimum: 0
                  default: 0
                category_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of an existing size-curve category (see `GET /distribution-templates/categories`).
                warehouse_id:
                  type: integer
                  nullable: true
                  description: |
                    Destination warehouse this template applies to. Only allowed together with `category_id`.
                    At most one active template may exist per category and warehouse, including the
                    category's unscoped (no warehouse) slot.
            examples:
              single_axis:
                summary: Single axis
                value:
                  name: Apparel sizes
                  axis_count: 1
                  column_axis_name: Size
                  column_values:
                    - value: S
                      percent: 40
                      sort_order: 0
                    - value: M
                      percent: 60
                      sort_order: 1
              dual_axis:
                summary: Dual axis
                value:
                  name: Tees by color and size
                  axis_count: 2
                  row_axis_name: Color
                  row_values:
                    - value: Black
                      percent: 50
                    - value: White
                      percent: 50
                  column_axis_name: Size
                  column_values:
                    - value: S
                      percent: 25
                    - value: M
                      percent: 50
                    - value: L
                      percent: 25
      responses:
        '201':
          description: Template created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A distribution template (size curve) that splits a master SKU total across its variants.
                    properties:
                      id:
                        type: integer
                        description: Distribution template ID
                        example: 12
                      name:
                        type: string
                        description: 'Template name, unique among non-deleted templates'
                        example: Apparel sizes
                      description:
                        type: string
                        nullable: true
                        description: Template description
                      axis_count:
                        type: integer
                        enum:
                          - 1
                          - 2
                        description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                      mode:
                        type: string
                        enum:
                          - single_axis
                          - dual_axis
                        description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                      row_axis_name:
                        type: string
                        nullable: true
                        description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                      column_axis_name:
                        type: string
                        description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                        example: Size
                      row_values:
                        type: array
                        description: Row-axis values with their percent share. Empty on a single-axis template.
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                              description: Axis value (e.g. a size or color)
                              example: M
                            percent:
                              type: number
                              description: 'Share of this axis value, in percent (0–100, two decimals)'
                              example: 60
                            sort_order:
                              type: integer
                              description: Position of the value on its axis
                              example: 1
                      column_values:
                        type: array
                        description: Column-axis values with their percent share.
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                              description: Axis value (e.g. a size or color)
                              example: M
                            percent:
                              type: number
                              description: 'Share of this axis value, in percent (0–100, two decimals)'
                              example: 60
                            sort_order:
                              type: integer
                              description: Position of the value on its axis
                              example: 1
                      cells:
                        type: array
                        description: |
                          Per-cell weights. On a single-axis template there is one cell per column value, with
                          `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                          pair, and the weight is the product of the row and column shares.
                        items:
                          type: object
                          properties:
                            size:
                              type: string
                              description: Column-axis value for this cell
                            axis:
                              type: string
                              enum:
                                - column
                            row_value:
                              type: string
                              description: Row-axis value (dual-axis templates only)
                            column_value:
                              type: string
                              description: Column-axis value (dual-axis templates only)
                            percent:
                              type: number
                              description: Cell share in percent (two decimals)
                            weight:
                              type: number
                              description: Cell share as a fraction (four decimals)
                      is_default:
                        type: boolean
                        description: Whether this is the tenant's default template
                      is_active:
                        type: boolean
                        description: Whether the template is active
                      category_id:
                        type: integer
                        nullable: true
                        description: 'Size-curve category the template belongs to, or `null`'
                      category_name:
                        type: string
                        nullable: true
                        description: 'Name of that category, or `null`'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: |
                          Destination warehouse the template is scoped to for category × warehouse resolution,
                          or `null` when it is not warehouse-scoped.
                    example:
                      id: 12
                      name: Apparel sizes
                      description: null
                      axis_count: 1
                      mode: single_axis
                      row_axis_name: null
                      column_axis_name: Size
                      row_values: []
                      column_values:
                        - value: S
                          percent: 40
                          sort_order: 0
                        - value: M
                          percent: 60
                          sort_order: 1
                      cells:
                        - size: S
                          axis: column
                          percent: 40
                          weight: 0.4
                        - size: M
                          axis: column
                          percent: 60
                          weight: 0.6
                      is_default: false
                      is_active: true
                      category_id: null
                      category_name: null
                      warehouse_id: null
        '400':
          description: The template could not be saved (`Failed to create grid template.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error. The body carries an `errors` object keyed by field, e.g. a duplicate
            `name` (`A distribution template with this name already exists.`), an axis whose
            percents do not total 100 (`Column percentages must total 100% (currently 99.96%).`),
            a duplicate or blank axis value, row data on a single-axis template, a missing row axis on
            a dual-axis template, identical row and column axes, a `warehouse_id` without a
            `category_id`, or a category and warehouse that already has an active template.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /distribution-templates/default:
    get:
      operationId: getDefaultDistributionTemplate
      tags:
        - Products
      summary: Get the default distribution template
      description: |
        Returns the tenant's default distribution template, the one used for a master SKU that has
        no pinned template and no matching size-curve category. When no default is set, the
        response is still `200` with `data: null` and a `message`.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    allOf:
                      - type: object
                        description: A distribution template (size curve) that splits a master SKU total across its variants.
                        properties:
                          id:
                            type: integer
                            description: Distribution template ID
                            example: 12
                          name:
                            type: string
                            description: 'Template name, unique among non-deleted templates'
                            example: Apparel sizes
                          description:
                            type: string
                            nullable: true
                            description: Template description
                          axis_count:
                            type: integer
                            enum:
                              - 1
                              - 2
                            description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                          mode:
                            type: string
                            enum:
                              - single_axis
                              - dual_axis
                            description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                          row_axis_name:
                            type: string
                            nullable: true
                            description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                          column_axis_name:
                            type: string
                            description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                            example: Size
                          row_values:
                            type: array
                            description: Row-axis values with their percent share. Empty on a single-axis template.
                            items:
                              type: object
                              properties:
                                value:
                                  type: string
                                  description: Axis value (e.g. a size or color)
                                  example: M
                                percent:
                                  type: number
                                  description: 'Share of this axis value, in percent (0–100, two decimals)'
                                  example: 60
                                sort_order:
                                  type: integer
                                  description: Position of the value on its axis
                                  example: 1
                          column_values:
                            type: array
                            description: Column-axis values with their percent share.
                            items:
                              type: object
                              properties:
                                value:
                                  type: string
                                  description: Axis value (e.g. a size or color)
                                  example: M
                                percent:
                                  type: number
                                  description: 'Share of this axis value, in percent (0–100, two decimals)'
                                  example: 60
                                sort_order:
                                  type: integer
                                  description: Position of the value on its axis
                                  example: 1
                          cells:
                            type: array
                            description: |
                              Per-cell weights. On a single-axis template there is one cell per column value, with
                              `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                              pair, and the weight is the product of the row and column shares.
                            items:
                              type: object
                              properties:
                                size:
                                  type: string
                                  description: Column-axis value for this cell
                                axis:
                                  type: string
                                  enum:
                                    - column
                                row_value:
                                  type: string
                                  description: Row-axis value (dual-axis templates only)
                                column_value:
                                  type: string
                                  description: Column-axis value (dual-axis templates only)
                                percent:
                                  type: number
                                  description: Cell share in percent (two decimals)
                                weight:
                                  type: number
                                  description: Cell share as a fraction (four decimals)
                          is_default:
                            type: boolean
                            description: Whether this is the tenant's default template
                          is_active:
                            type: boolean
                            description: Whether the template is active
                          category_id:
                            type: integer
                            nullable: true
                            description: 'Size-curve category the template belongs to, or `null`'
                          category_name:
                            type: string
                            nullable: true
                            description: 'Name of that category, or `null`'
                          warehouse_id:
                            type: integer
                            nullable: true
                            description: |
                              Destination warehouse the template is scoped to for category × warehouse resolution,
                              or `null` when it is not warehouse-scoped.
                        example:
                          id: 12
                          name: Apparel sizes
                          description: null
                          axis_count: 1
                          mode: single_axis
                          row_axis_name: null
                          column_axis_name: Size
                          row_values: []
                          column_values:
                            - value: S
                              percent: 40
                              sort_order: 0
                            - value: M
                              percent: 60
                              sort_order: 1
                          cells:
                            - size: S
                              axis: column
                              percent: 40
                              weight: 0.4
                            - size: M
                              axis: column
                              percent: 60
                              weight: 0.6
                          is_default: false
                          is_active: true
                          category_id: null
                          category_name: null
                          warehouse_id: null
                    nullable: true
                    description: 'The default template, or `null` when none is set'
                  message:
                    type: string
                    description: Present only when no default is set
                    example: No default distribution template is set.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /distribution-templates/categories:
    get:
      operationId: listDistributionTemplateCategories
      tags:
        - Products
      summary: List size-curve categories
      description: |
        Returns the active size-curve categories. A category groups distribution templates so that a
        product assigned to the category (see
        `PUT /products/{productId}/distribution-template-category`) picks up the category's
        template for the destination warehouse, or its unscoped template. Categories are read-only
        on this API; use an `id` from here as `category_id` when creating or updating a template.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 3
                        name:
                          type: string
                          example: Women's Tops
                        is_active:
                          type: boolean
                        sort_order:
                          type: integer
                        assigned_template_count:
                          type: integer
                          description: Number of templates in the category
                        assigned_sku_count:
                          type: integer
                          description: Number of products assigned to the category
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /distribution-templates/resolve:
    get:
      operationId: resolveDistributionTemplate
      tags:
        - Products
      summary: Resolve the distribution template for a product
      description: |
        Works out which distribution template applies to a master SKU and returns its grid, one cell
        per variant combination, without distributing any quantity. Nothing is saved.

        The template is picked in this order: the `distribution_template_id` on the request, the
        template pinned on the product, the product's size-curve category (for `warehouse_id`, then
        unscoped), then the tenant default. When none applies, the grid falls back to an equal share
        for each variant (`source: even_split`), and `reason` still says why no template was used.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: master_sku_id
          required: true
          schema:
            type: integer
            minimum: 1
          description: Product ID of the master SKU
        - in: query
          name: distribution_template_id
          schema:
            type: integer
            minimum: 1
          description: Use this template instead of the one the product would resolve to
        - in: query
          name: vendor_id
          schema:
            type: integer
          description: 'Supplier ID, used to price each cell from that supplier''s prices'
        - in: query
          name: warehouse_id
          schema:
            type: integer
            minimum: 1
          description: |
            Destination warehouse. Selects the warehouse-specific template of the product's
            size-curve category when the product has no pinned template.
      responses:
        '200':
          description: 'The resolution and its grid, with every cell''s `quantity` at `0`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      master:
                        type: object
                        description: The master SKU the grid was resolved for.
                        properties:
                          sku_id:
                            type: integer
                            description: Product ID of the master SKU
                          internal_sku:
                            type: string
                            nullable: true
                          product_name:
                            type: string
                            nullable: true
                          axes:
                            type: array
                            description: 'Names of the master''s variant types, e.g. `["Size", "Color"]`'
                            items:
                              type: string
                      source:
                        type: string
                        enum:
                          - override
                          - master
                          - category
                          - default
                          - even_split
                          - none
                        description: |
                          Where the template came from: `override` (the `distribution_template_id` sent on the
                          request), `master` (the template pinned on the product), `category` (the product's
                          size-curve category, warehouse-specific when `warehouse_id` matched), `default` (the
                          tenant default), `even_split` (no template applied, so each variant gets an equal share),
                          or `none` (no template applied and the product has no variants to split across; `grid`
                          is `null`).
                      reason:
                        type: string
                        nullable: true
                        enum:
                          - AXIS_NOT_ON_MASTER
                          - VALUES_NOT_ON_MASTER
                          - MASTER_VALUE_NOT_IN_TEMPLATE
                          - MASTER_HAS_NO_VARIANTS
                          - MASTER_AXIS_AMBIGUOUS
                          - NOT_A_MASTER_SKU
                          - TEMPLATE_INACTIVE
                          - null
                        description: |
                          Why a template was not applied, or `null`. A template must match the master's variant
                          options exactly: `AXIS_NOT_ON_MASTER` (a template axis is not a variant type of the
                          product), `VALUES_NOT_ON_MASTER` (the template lists a value the product does not have),
                          `MASTER_VALUE_NOT_IN_TEMPLATE` (the product has a value the template does not cover),
                          `MASTER_HAS_NO_VARIANTS`, `MASTER_AXIS_AMBIGUOUS` (two of the product's variant types
                          normalize to the same name), `NOT_A_MASTER_SKU` (the product is a variant child) and
                          `TEMPLATE_INACTIVE`.
                      reason_message:
                        type: string
                        nullable: true
                        description: 'Human-readable explanation of `reason`, when a specific template was rejected.'
                      template:
                        allOf:
                          - type: object
                            description: A distribution template (size curve) that splits a master SKU total across its variants.
                            properties:
                              id:
                                type: integer
                                description: Distribution template ID
                                example: 12
                              name:
                                type: string
                                description: 'Template name, unique among non-deleted templates'
                                example: Apparel sizes
                              description:
                                type: string
                                nullable: true
                                description: Template description
                              axis_count:
                                type: integer
                                enum:
                                  - 1
                                  - 2
                                description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                              mode:
                                type: string
                                enum:
                                  - single_axis
                                  - dual_axis
                                description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                              row_axis_name:
                                type: string
                                nullable: true
                                description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                              column_axis_name:
                                type: string
                                description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                                example: Size
                              row_values:
                                type: array
                                description: Row-axis values with their percent share. Empty on a single-axis template.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              column_values:
                                type: array
                                description: Column-axis values with their percent share.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              cells:
                                type: array
                                description: |
                                  Per-cell weights. On a single-axis template there is one cell per column value, with
                                  `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                                  pair, and the weight is the product of the row and column shares.
                                items:
                                  type: object
                                  properties:
                                    size:
                                      type: string
                                      description: Column-axis value for this cell
                                    axis:
                                      type: string
                                      enum:
                                        - column
                                    row_value:
                                      type: string
                                      description: Row-axis value (dual-axis templates only)
                                    column_value:
                                      type: string
                                      description: Column-axis value (dual-axis templates only)
                                    percent:
                                      type: number
                                      description: Cell share in percent (two decimals)
                                    weight:
                                      type: number
                                      description: Cell share as a fraction (four decimals)
                              is_default:
                                type: boolean
                                description: Whether this is the tenant's default template
                              is_active:
                                type: boolean
                                description: Whether the template is active
                              category_id:
                                type: integer
                                nullable: true
                                description: 'Size-curve category the template belongs to, or `null`'
                              category_name:
                                type: string
                                nullable: true
                                description: 'Name of that category, or `null`'
                              warehouse_id:
                                type: integer
                                nullable: true
                                description: |
                                  Destination warehouse the template is scoped to for category × warehouse resolution,
                                  or `null` when it is not warehouse-scoped.
                            example:
                              id: 12
                              name: Apparel sizes
                              description: null
                              axis_count: 1
                              mode: single_axis
                              row_axis_name: null
                              column_axis_name: Size
                              row_values: []
                              column_values:
                                - value: S
                                  percent: 40
                                  sort_order: 0
                                - value: M
                                  percent: 60
                                  sort_order: 1
                              cells:
                                - size: S
                                  axis: column
                                  percent: 40
                                  weight: 0.4
                                - size: M
                                  axis: column
                                  percent: 60
                                  weight: 0.6
                              is_default: false
                              is_active: true
                              category_id: null
                              category_name: null
                              warehouse_id: null
                        nullable: true
                        description: 'The template that was applied, or `null` (always `null` on an even split).'
                      rejected_template:
                        allOf:
                          - type: object
                            description: A distribution template (size curve) that splits a master SKU total across its variants.
                            properties:
                              id:
                                type: integer
                                description: Distribution template ID
                                example: 12
                              name:
                                type: string
                                description: 'Template name, unique among non-deleted templates'
                                example: Apparel sizes
                              description:
                                type: string
                                nullable: true
                                description: Template description
                              axis_count:
                                type: integer
                                enum:
                                  - 1
                                  - 2
                                description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                              mode:
                                type: string
                                enum:
                                  - single_axis
                                  - dual_axis
                                description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                              row_axis_name:
                                type: string
                                nullable: true
                                description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                              column_axis_name:
                                type: string
                                description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                                example: Size
                              row_values:
                                type: array
                                description: Row-axis values with their percent share. Empty on a single-axis template.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              column_values:
                                type: array
                                description: Column-axis values with their percent share.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              cells:
                                type: array
                                description: |
                                  Per-cell weights. On a single-axis template there is one cell per column value, with
                                  `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                                  pair, and the weight is the product of the row and column shares.
                                items:
                                  type: object
                                  properties:
                                    size:
                                      type: string
                                      description: Column-axis value for this cell
                                    axis:
                                      type: string
                                      enum:
                                        - column
                                    row_value:
                                      type: string
                                      description: Row-axis value (dual-axis templates only)
                                    column_value:
                                      type: string
                                      description: Column-axis value (dual-axis templates only)
                                    percent:
                                      type: number
                                      description: Cell share in percent (two decimals)
                                    weight:
                                      type: number
                                      description: Cell share as a fraction (four decimals)
                              is_default:
                                type: boolean
                                description: Whether this is the tenant's default template
                              is_active:
                                type: boolean
                                description: Whether the template is active
                              category_id:
                                type: integer
                                nullable: true
                                description: 'Size-curve category the template belongs to, or `null`'
                              category_name:
                                type: string
                                nullable: true
                                description: 'Name of that category, or `null`'
                              warehouse_id:
                                type: integer
                                nullable: true
                                description: |
                                  Destination warehouse the template is scoped to for category × warehouse resolution,
                                  or `null` when it is not warehouse-scoped.
                            example:
                              id: 12
                              name: Apparel sizes
                              description: null
                              axis_count: 1
                              mode: single_axis
                              row_axis_name: null
                              column_axis_name: Size
                              row_values: []
                              column_values:
                                - value: S
                                  percent: 40
                                  sort_order: 0
                                - value: M
                                  percent: 60
                                  sort_order: 1
                              cells:
                                - size: S
                                  axis: column
                                  percent: 40
                                  weight: 0.4
                                - size: M
                                  axis: column
                                  percent: 60
                                  weight: 0.6
                              is_default: false
                              is_active: true
                              category_id: null
                              category_name: null
                              warehouse_id: null
                        nullable: true
                        description: 'The template that was considered and rejected for `reason`, or `null`.'
                      grid:
                        type: object
                        nullable: true
                        description: 'The resolved grid, one cell per variant combination. `null` when `source` is `none`.'
                        properties:
                          template_id:
                            type: integer
                            nullable: true
                            description: ID of the applied template; `null` on an even split
                          template_name:
                            type: string
                            nullable: true
                          axis_count:
                            type: integer
                            enum:
                              - 1
                              - 2
                          row_axis_name:
                            type: string
                            nullable: true
                          column_axis_name:
                            type: string
                          row_values:
                            type: array
                            description: Row-axis values in grid order (empty on a single-axis grid)
                            items:
                              type: object
                              properties:
                                value:
                                  type: string
                                percent:
                                  type: number
                          column_values:
                            type: array
                            description: Column-axis values in grid order
                            items:
                              type: object
                              properties:
                                value:
                                  type: string
                                percent:
                                  type: number
                          total_requested:
                            type: integer
                            description: The `total_quantity` sent to distribute; `0` on resolve
                          total_allocated:
                            type: integer
                            description: |
                              Quantity actually placed on cells. Equals `total_requested` whenever at least one
                              cell can receive quantity.
                          matched_cell_count:
                            type: integer
                            description: Cells backed by exactly one variant SKU
                          skipped_cell_count:
                            type: integer
                            description: 'Cells dropped because no variant, or more than one, matched'
                          warnings:
                            type: array
                            description: |
                              `NO_CHILD_SKUS` (no cell resolved to a variant SKU), `AMBIGUOUS_CELLS` (at least one
                              cell matched several variants and was dropped), `ZERO_WEIGHT_DISTRIBUTION` (every
                              remaining cell has a 0% share, so nothing can be allocated).
                            items:
                              type: string
                              enum:
                                - NO_CHILD_SKUS
                                - AMBIGUOUS_CELLS
                                - ZERO_WEIGHT_DISTRIBUTION
                          cells:
                            type: array
                            items:
                              type: object
                              properties:
                                row_value:
                                  type: string
                                  nullable: true
                                  description: Row-axis value; `null` on a single-axis grid
                                column_value:
                                  type: string
                                row_index:
                                  type: integer
                                  nullable: true
                                  description: Row position; `null` on a single-axis grid
                                column_index:
                                  type: integer
                                key:
                                  type: string
                                  description: 'Stable positional key, `{row_index}:{column_index}` zero-padded to four digits'
                                  example: '0000:0001'
                                share_percent:
                                  type: number
                                  description: 'The cell''s share of the total, in percent (two decimals)'
                                match_status:
                                  type: string
                                  enum:
                                    - matched
                                    - no_sku
                                    - ambiguous
                                  description: |
                                    `matched` (exactly one variant SKU backs the cell), `no_sku` (none does) or
                                    `ambiguous` (several do). Unmatched cells are dropped and their share is
                                    redistributed across the matched ones.
                                match_note:
                                  type: string
                                  nullable: true
                                  description: Why the cell did not match; `null` when matched
                                quantity:
                                  type: integer
                                  description: Quantity allocated to the cell (`0` on resolve)
                                included:
                                  type: boolean
                                  description: Whether the cell received quantity
                                child_sku_id:
                                  type: integer
                                  nullable: true
                                  description: Product ID of the variant SKU behind the cell
                                child_internal_sku:
                                  type: string
                                  nullable: true
                                child_product_name:
                                  type: string
                                  nullable: true
                                unit_price:
                                  type: number
                                  nullable: true
                                  description: Resolved purchase price for the variant
                                unit_price_source:
                                  type: string
                                  nullable: true
                                  enum:
                                    - child
                                    - supplier
                                    - master
                                    - none
                                    - null
                                  description: |
                                    Where `unit_price` came from: the variant itself, the supplier price (for
                                    `vendor_id`), the master SKU, or `none`.
                                inventory_tracked:
                                  type: boolean
                                  description: '`false` when the variant SKU is not inventory-tracked'
                                is_kit:
                                  type: boolean
                                  description: Whether the variant SKU is a kit
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: |
            The master SKU (`SKU not found.`) or the `distribution_template_id`
            (`Grid template not found.`) does not exist
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, e.g. `master_sku_id` missing (`A master SKU ID is required.`)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /distribution-templates/resolve/for-master:
    get:
      operationId: resolveDistributionTemplateForMaster
      tags:
        - Products
      summary: Resolve the distribution template for a master SKU (alias)
      description: |
        Alias of `GET /distribution-templates/resolve`. Same parameters, same response.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: master_sku_id
          required: true
          schema:
            type: integer
            minimum: 1
          description: Product ID of the master SKU
        - in: query
          name: distribution_template_id
          schema:
            type: integer
            minimum: 1
          description: Use this template instead of the one the product would resolve to
        - in: query
          name: vendor_id
          schema:
            type: integer
          description: 'Supplier ID, used to price each cell from that supplier''s prices'
        - in: query
          name: warehouse_id
          schema:
            type: integer
            minimum: 1
          description: |
            Destination warehouse. Selects the warehouse-specific template of the product's
            size-curve category when the product has no pinned template.
      responses:
        '200':
          description: 'The resolution and its grid, with every cell''s `quantity` at `0`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      master:
                        type: object
                        description: The master SKU the grid was resolved for.
                        properties:
                          sku_id:
                            type: integer
                            description: Product ID of the master SKU
                          internal_sku:
                            type: string
                            nullable: true
                          product_name:
                            type: string
                            nullable: true
                          axes:
                            type: array
                            description: 'Names of the master''s variant types, e.g. `["Size", "Color"]`'
                            items:
                              type: string
                      source:
                        type: string
                        enum:
                          - override
                          - master
                          - category
                          - default
                          - even_split
                          - none
                        description: |
                          Where the template came from: `override` (the `distribution_template_id` sent on the
                          request), `master` (the template pinned on the product), `category` (the product's
                          size-curve category, warehouse-specific when `warehouse_id` matched), `default` (the
                          tenant default), `even_split` (no template applied, so each variant gets an equal share),
                          or `none` (no template applied and the product has no variants to split across; `grid`
                          is `null`).
                      reason:
                        type: string
                        nullable: true
                        enum:
                          - AXIS_NOT_ON_MASTER
                          - VALUES_NOT_ON_MASTER
                          - MASTER_VALUE_NOT_IN_TEMPLATE
                          - MASTER_HAS_NO_VARIANTS
                          - MASTER_AXIS_AMBIGUOUS
                          - NOT_A_MASTER_SKU
                          - TEMPLATE_INACTIVE
                          - null
                        description: |
                          Why a template was not applied, or `null`. A template must match the master's variant
                          options exactly: `AXIS_NOT_ON_MASTER` (a template axis is not a variant type of the
                          product), `VALUES_NOT_ON_MASTER` (the template lists a value the product does not have),
                          `MASTER_VALUE_NOT_IN_TEMPLATE` (the product has a value the template does not cover),
                          `MASTER_HAS_NO_VARIANTS`, `MASTER_AXIS_AMBIGUOUS` (two of the product's variant types
                          normalize to the same name), `NOT_A_MASTER_SKU` (the product is a variant child) and
                          `TEMPLATE_INACTIVE`.
                      reason_message:
                        type: string
                        nullable: true
                        description: 'Human-readable explanation of `reason`, when a specific template was rejected.'
                      template:
                        allOf:
                          - type: object
                            description: A distribution template (size curve) that splits a master SKU total across its variants.
                            properties:
                              id:
                                type: integer
                                description: Distribution template ID
                                example: 12
                              name:
                                type: string
                                description: 'Template name, unique among non-deleted templates'
                                example: Apparel sizes
                              description:
                                type: string
                                nullable: true
                                description: Template description
                              axis_count:
                                type: integer
                                enum:
                                  - 1
                                  - 2
                                description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                              mode:
                                type: string
                                enum:
                                  - single_axis
                                  - dual_axis
                                description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                              row_axis_name:
                                type: string
                                nullable: true
                                description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                              column_axis_name:
                                type: string
                                description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                                example: Size
                              row_values:
                                type: array
                                description: Row-axis values with their percent share. Empty on a single-axis template.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              column_values:
                                type: array
                                description: Column-axis values with their percent share.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              cells:
                                type: array
                                description: |
                                  Per-cell weights. On a single-axis template there is one cell per column value, with
                                  `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                                  pair, and the weight is the product of the row and column shares.
                                items:
                                  type: object
                                  properties:
                                    size:
                                      type: string
                                      description: Column-axis value for this cell
                                    axis:
                                      type: string
                                      enum:
                                        - column
                                    row_value:
                                      type: string
                                      description: Row-axis value (dual-axis templates only)
                                    column_value:
                                      type: string
                                      description: Column-axis value (dual-axis templates only)
                                    percent:
                                      type: number
                                      description: Cell share in percent (two decimals)
                                    weight:
                                      type: number
                                      description: Cell share as a fraction (four decimals)
                              is_default:
                                type: boolean
                                description: Whether this is the tenant's default template
                              is_active:
                                type: boolean
                                description: Whether the template is active
                              category_id:
                                type: integer
                                nullable: true
                                description: 'Size-curve category the template belongs to, or `null`'
                              category_name:
                                type: string
                                nullable: true
                                description: 'Name of that category, or `null`'
                              warehouse_id:
                                type: integer
                                nullable: true
                                description: |
                                  Destination warehouse the template is scoped to for category × warehouse resolution,
                                  or `null` when it is not warehouse-scoped.
                            example:
                              id: 12
                              name: Apparel sizes
                              description: null
                              axis_count: 1
                              mode: single_axis
                              row_axis_name: null
                              column_axis_name: Size
                              row_values: []
                              column_values:
                                - value: S
                                  percent: 40
                                  sort_order: 0
                                - value: M
                                  percent: 60
                                  sort_order: 1
                              cells:
                                - size: S
                                  axis: column
                                  percent: 40
                                  weight: 0.4
                                - size: M
                                  axis: column
                                  percent: 60
                                  weight: 0.6
                              is_default: false
                              is_active: true
                              category_id: null
                              category_name: null
                              warehouse_id: null
                        nullable: true
                        description: 'The template that was applied, or `null` (always `null` on an even split).'
                      rejected_template:
                        allOf:
                          - type: object
                            description: A distribution template (size curve) that splits a master SKU total across its variants.
                            properties:
                              id:
                                type: integer
                                description: Distribution template ID
                                example: 12
                              name:
                                type: string
                                description: 'Template name, unique among non-deleted templates'
                                example: Apparel sizes
                              description:
                                type: string
                                nullable: true
                                description: Template description
                              axis_count:
                                type: integer
                                enum:
                                  - 1
                                  - 2
                                description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                              mode:
                                type: string
                                enum:
                                  - single_axis
                                  - dual_axis
                                description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                              row_axis_name:
                                type: string
                                nullable: true
                                description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                              column_axis_name:
                                type: string
                                description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                                example: Size
                              row_values:
                                type: array
                                description: Row-axis values with their percent share. Empty on a single-axis template.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              column_values:
                                type: array
                                description: Column-axis values with their percent share.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              cells:
                                type: array
                                description: |
                                  Per-cell weights. On a single-axis template there is one cell per column value, with
                                  `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                                  pair, and the weight is the product of the row and column shares.
                                items:
                                  type: object
                                  properties:
                                    size:
                                      type: string
                                      description: Column-axis value for this cell
                                    axis:
                                      type: string
                                      enum:
                                        - column
                                    row_value:
                                      type: string
                                      description: Row-axis value (dual-axis templates only)
                                    column_value:
                                      type: string
                                      description: Column-axis value (dual-axis templates only)
                                    percent:
                                      type: number
                                      description: Cell share in percent (two decimals)
                                    weight:
                                      type: number
                                      description: Cell share as a fraction (four decimals)
                              is_default:
                                type: boolean
                                description: Whether this is the tenant's default template
                              is_active:
                                type: boolean
                                description: Whether the template is active
                              category_id:
                                type: integer
                                nullable: true
                                description: 'Size-curve category the template belongs to, or `null`'
                              category_name:
                                type: string
                                nullable: true
                                description: 'Name of that category, or `null`'
                              warehouse_id:
                                type: integer
                                nullable: true
                                description: |
                                  Destination warehouse the template is scoped to for category × warehouse resolution,
                                  or `null` when it is not warehouse-scoped.
                            example:
                              id: 12
                              name: Apparel sizes
                              description: null
                              axis_count: 1
                              mode: single_axis
                              row_axis_name: null
                              column_axis_name: Size
                              row_values: []
                              column_values:
                                - value: S
                                  percent: 40
                                  sort_order: 0
                                - value: M
                                  percent: 60
                                  sort_order: 1
                              cells:
                                - size: S
                                  axis: column
                                  percent: 40
                                  weight: 0.4
                                - size: M
                                  axis: column
                                  percent: 60
                                  weight: 0.6
                              is_default: false
                              is_active: true
                              category_id: null
                              category_name: null
                              warehouse_id: null
                        nullable: true
                        description: 'The template that was considered and rejected for `reason`, or `null`.'
                      grid:
                        type: object
                        nullable: true
                        description: 'The resolved grid, one cell per variant combination. `null` when `source` is `none`.'
                        properties:
                          template_id:
                            type: integer
                            nullable: true
                            description: ID of the applied template; `null` on an even split
                          template_name:
                            type: string
                            nullable: true
                          axis_count:
                            type: integer
                            enum:
                              - 1
                              - 2
                          row_axis_name:
                            type: string
                            nullable: true
                          column_axis_name:
                            type: string
                          row_values:
                            type: array
                            description: Row-axis values in grid order (empty on a single-axis grid)
                            items:
                              type: object
                              properties:
                                value:
                                  type: string
                                percent:
                                  type: number
                          column_values:
                            type: array
                            description: Column-axis values in grid order
                            items:
                              type: object
                              properties:
                                value:
                                  type: string
                                percent:
                                  type: number
                          total_requested:
                            type: integer
                            description: The `total_quantity` sent to distribute; `0` on resolve
                          total_allocated:
                            type: integer
                            description: |
                              Quantity actually placed on cells. Equals `total_requested` whenever at least one
                              cell can receive quantity.
                          matched_cell_count:
                            type: integer
                            description: Cells backed by exactly one variant SKU
                          skipped_cell_count:
                            type: integer
                            description: 'Cells dropped because no variant, or more than one, matched'
                          warnings:
                            type: array
                            description: |
                              `NO_CHILD_SKUS` (no cell resolved to a variant SKU), `AMBIGUOUS_CELLS` (at least one
                              cell matched several variants and was dropped), `ZERO_WEIGHT_DISTRIBUTION` (every
                              remaining cell has a 0% share, so nothing can be allocated).
                            items:
                              type: string
                              enum:
                                - NO_CHILD_SKUS
                                - AMBIGUOUS_CELLS
                                - ZERO_WEIGHT_DISTRIBUTION
                          cells:
                            type: array
                            items:
                              type: object
                              properties:
                                row_value:
                                  type: string
                                  nullable: true
                                  description: Row-axis value; `null` on a single-axis grid
                                column_value:
                                  type: string
                                row_index:
                                  type: integer
                                  nullable: true
                                  description: Row position; `null` on a single-axis grid
                                column_index:
                                  type: integer
                                key:
                                  type: string
                                  description: 'Stable positional key, `{row_index}:{column_index}` zero-padded to four digits'
                                  example: '0000:0001'
                                share_percent:
                                  type: number
                                  description: 'The cell''s share of the total, in percent (two decimals)'
                                match_status:
                                  type: string
                                  enum:
                                    - matched
                                    - no_sku
                                    - ambiguous
                                  description: |
                                    `matched` (exactly one variant SKU backs the cell), `no_sku` (none does) or
                                    `ambiguous` (several do). Unmatched cells are dropped and their share is
                                    redistributed across the matched ones.
                                match_note:
                                  type: string
                                  nullable: true
                                  description: Why the cell did not match; `null` when matched
                                quantity:
                                  type: integer
                                  description: Quantity allocated to the cell (`0` on resolve)
                                included:
                                  type: boolean
                                  description: Whether the cell received quantity
                                child_sku_id:
                                  type: integer
                                  nullable: true
                                  description: Product ID of the variant SKU behind the cell
                                child_internal_sku:
                                  type: string
                                  nullable: true
                                child_product_name:
                                  type: string
                                  nullable: true
                                unit_price:
                                  type: number
                                  nullable: true
                                  description: Resolved purchase price for the variant
                                unit_price_source:
                                  type: string
                                  nullable: true
                                  enum:
                                    - child
                                    - supplier
                                    - master
                                    - none
                                    - null
                                  description: |
                                    Where `unit_price` came from: the variant itself, the supplier price (for
                                    `vendor_id`), the master SKU, or `none`.
                                inventory_tracked:
                                  type: boolean
                                  description: '`false` when the variant SKU is not inventory-tracked'
                                is_kit:
                                  type: boolean
                                  description: Whether the variant SKU is a kit
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: |
            The master SKU (`SKU not found.`) or the `distribution_template_id`
            (`Grid template not found.`) does not exist
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, e.g. `master_sku_id` missing (`A master SKU ID is required.`)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /distribution-templates/distribute:
    post:
      operationId: distributeQuantity
      tags:
        - Products
      summary: Distribute a quantity across a product's variants
      description: |
        Splits a total quantity for a master SKU across its variants using the resolved distribution
        template (see `GET /distribution-templates/resolve` for how the template is picked). The
        per-cell quantities are whole numbers that add up exactly to `total_quantity`. Cells with
        no matching variant SKU are dropped and their share goes to the matched ones.

        This is a calculation only. Nothing is created or saved; use the returned quantities to
        build your own request, e.g. `POST /work-orders/bulk`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - master_sku_id
                - total_quantity
              properties:
                master_sku_id:
                  type: integer
                  minimum: 1
                  description: Product ID of the master SKU
                total_quantity:
                  type: integer
                  minimum: 0
                  maximum: 10000000
                  description: Total to split. Whole numbers only.
                distribution_template_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: Use this template instead of the one the product would resolve to
                vendor_id:
                  type: integer
                  nullable: true
                  description: 'Supplier ID, used to price each cell from that supplier''s prices'
                warehouse_id:
                  type: integer
                  nullable: true
                  minimum: 1
                  description: |
                    Destination warehouse. Selects the warehouse-specific template of the product's
                    size-curve category when the product has no pinned template.
            example:
              master_sku_id: 5521
              total_quantity: 100
      responses:
        '200':
          description: 'The resolution and its grid, with each included cell''s `quantity` filled in'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      master:
                        type: object
                        description: The master SKU the grid was resolved for.
                        properties:
                          sku_id:
                            type: integer
                            description: Product ID of the master SKU
                          internal_sku:
                            type: string
                            nullable: true
                          product_name:
                            type: string
                            nullable: true
                          axes:
                            type: array
                            description: 'Names of the master''s variant types, e.g. `["Size", "Color"]`'
                            items:
                              type: string
                      source:
                        type: string
                        enum:
                          - override
                          - master
                          - category
                          - default
                          - even_split
                          - none
                        description: |
                          Where the template came from: `override` (the `distribution_template_id` sent on the
                          request), `master` (the template pinned on the product), `category` (the product's
                          size-curve category, warehouse-specific when `warehouse_id` matched), `default` (the
                          tenant default), `even_split` (no template applied, so each variant gets an equal share),
                          or `none` (no template applied and the product has no variants to split across; `grid`
                          is `null`).
                      reason:
                        type: string
                        nullable: true
                        enum:
                          - AXIS_NOT_ON_MASTER
                          - VALUES_NOT_ON_MASTER
                          - MASTER_VALUE_NOT_IN_TEMPLATE
                          - MASTER_HAS_NO_VARIANTS
                          - MASTER_AXIS_AMBIGUOUS
                          - NOT_A_MASTER_SKU
                          - TEMPLATE_INACTIVE
                          - null
                        description: |
                          Why a template was not applied, or `null`. A template must match the master's variant
                          options exactly: `AXIS_NOT_ON_MASTER` (a template axis is not a variant type of the
                          product), `VALUES_NOT_ON_MASTER` (the template lists a value the product does not have),
                          `MASTER_VALUE_NOT_IN_TEMPLATE` (the product has a value the template does not cover),
                          `MASTER_HAS_NO_VARIANTS`, `MASTER_AXIS_AMBIGUOUS` (two of the product's variant types
                          normalize to the same name), `NOT_A_MASTER_SKU` (the product is a variant child) and
                          `TEMPLATE_INACTIVE`.
                      reason_message:
                        type: string
                        nullable: true
                        description: 'Human-readable explanation of `reason`, when a specific template was rejected.'
                      template:
                        allOf:
                          - type: object
                            description: A distribution template (size curve) that splits a master SKU total across its variants.
                            properties:
                              id:
                                type: integer
                                description: Distribution template ID
                                example: 12
                              name:
                                type: string
                                description: 'Template name, unique among non-deleted templates'
                                example: Apparel sizes
                              description:
                                type: string
                                nullable: true
                                description: Template description
                              axis_count:
                                type: integer
                                enum:
                                  - 1
                                  - 2
                                description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                              mode:
                                type: string
                                enum:
                                  - single_axis
                                  - dual_axis
                                description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                              row_axis_name:
                                type: string
                                nullable: true
                                description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                              column_axis_name:
                                type: string
                                description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                                example: Size
                              row_values:
                                type: array
                                description: Row-axis values with their percent share. Empty on a single-axis template.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              column_values:
                                type: array
                                description: Column-axis values with their percent share.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              cells:
                                type: array
                                description: |
                                  Per-cell weights. On a single-axis template there is one cell per column value, with
                                  `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                                  pair, and the weight is the product of the row and column shares.
                                items:
                                  type: object
                                  properties:
                                    size:
                                      type: string
                                      description: Column-axis value for this cell
                                    axis:
                                      type: string
                                      enum:
                                        - column
                                    row_value:
                                      type: string
                                      description: Row-axis value (dual-axis templates only)
                                    column_value:
                                      type: string
                                      description: Column-axis value (dual-axis templates only)
                                    percent:
                                      type: number
                                      description: Cell share in percent (two decimals)
                                    weight:
                                      type: number
                                      description: Cell share as a fraction (four decimals)
                              is_default:
                                type: boolean
                                description: Whether this is the tenant's default template
                              is_active:
                                type: boolean
                                description: Whether the template is active
                              category_id:
                                type: integer
                                nullable: true
                                description: 'Size-curve category the template belongs to, or `null`'
                              category_name:
                                type: string
                                nullable: true
                                description: 'Name of that category, or `null`'
                              warehouse_id:
                                type: integer
                                nullable: true
                                description: |
                                  Destination warehouse the template is scoped to for category × warehouse resolution,
                                  or `null` when it is not warehouse-scoped.
                            example:
                              id: 12
                              name: Apparel sizes
                              description: null
                              axis_count: 1
                              mode: single_axis
                              row_axis_name: null
                              column_axis_name: Size
                              row_values: []
                              column_values:
                                - value: S
                                  percent: 40
                                  sort_order: 0
                                - value: M
                                  percent: 60
                                  sort_order: 1
                              cells:
                                - size: S
                                  axis: column
                                  percent: 40
                                  weight: 0.4
                                - size: M
                                  axis: column
                                  percent: 60
                                  weight: 0.6
                              is_default: false
                              is_active: true
                              category_id: null
                              category_name: null
                              warehouse_id: null
                        nullable: true
                        description: 'The template that was applied, or `null` (always `null` on an even split).'
                      rejected_template:
                        allOf:
                          - type: object
                            description: A distribution template (size curve) that splits a master SKU total across its variants.
                            properties:
                              id:
                                type: integer
                                description: Distribution template ID
                                example: 12
                              name:
                                type: string
                                description: 'Template name, unique among non-deleted templates'
                                example: Apparel sizes
                              description:
                                type: string
                                nullable: true
                                description: Template description
                              axis_count:
                                type: integer
                                enum:
                                  - 1
                                  - 2
                                description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                              mode:
                                type: string
                                enum:
                                  - single_axis
                                  - dual_axis
                                description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                              row_axis_name:
                                type: string
                                nullable: true
                                description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                              column_axis_name:
                                type: string
                                description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                                example: Size
                              row_values:
                                type: array
                                description: Row-axis values with their percent share. Empty on a single-axis template.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              column_values:
                                type: array
                                description: Column-axis values with their percent share.
                                items:
                                  type: object
                                  properties:
                                    value:
                                      type: string
                                      description: Axis value (e.g. a size or color)
                                      example: M
                                    percent:
                                      type: number
                                      description: 'Share of this axis value, in percent (0–100, two decimals)'
                                      example: 60
                                    sort_order:
                                      type: integer
                                      description: Position of the value on its axis
                                      example: 1
                              cells:
                                type: array
                                description: |
                                  Per-cell weights. On a single-axis template there is one cell per column value, with
                                  `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                                  pair, and the weight is the product of the row and column shares.
                                items:
                                  type: object
                                  properties:
                                    size:
                                      type: string
                                      description: Column-axis value for this cell
                                    axis:
                                      type: string
                                      enum:
                                        - column
                                    row_value:
                                      type: string
                                      description: Row-axis value (dual-axis templates only)
                                    column_value:
                                      type: string
                                      description: Column-axis value (dual-axis templates only)
                                    percent:
                                      type: number
                                      description: Cell share in percent (two decimals)
                                    weight:
                                      type: number
                                      description: Cell share as a fraction (four decimals)
                              is_default:
                                type: boolean
                                description: Whether this is the tenant's default template
                              is_active:
                                type: boolean
                                description: Whether the template is active
                              category_id:
                                type: integer
                                nullable: true
                                description: 'Size-curve category the template belongs to, or `null`'
                              category_name:
                                type: string
                                nullable: true
                                description: 'Name of that category, or `null`'
                              warehouse_id:
                                type: integer
                                nullable: true
                                description: |
                                  Destination warehouse the template is scoped to for category × warehouse resolution,
                                  or `null` when it is not warehouse-scoped.
                            example:
                              id: 12
                              name: Apparel sizes
                              description: null
                              axis_count: 1
                              mode: single_axis
                              row_axis_name: null
                              column_axis_name: Size
                              row_values: []
                              column_values:
                                - value: S
                                  percent: 40
                                  sort_order: 0
                                - value: M
                                  percent: 60
                                  sort_order: 1
                              cells:
                                - size: S
                                  axis: column
                                  percent: 40
                                  weight: 0.4
                                - size: M
                                  axis: column
                                  percent: 60
                                  weight: 0.6
                              is_default: false
                              is_active: true
                              category_id: null
                              category_name: null
                              warehouse_id: null
                        nullable: true
                        description: 'The template that was considered and rejected for `reason`, or `null`.'
                      grid:
                        type: object
                        nullable: true
                        description: 'The resolved grid, one cell per variant combination. `null` when `source` is `none`.'
                        properties:
                          template_id:
                            type: integer
                            nullable: true
                            description: ID of the applied template; `null` on an even split
                          template_name:
                            type: string
                            nullable: true
                          axis_count:
                            type: integer
                            enum:
                              - 1
                              - 2
                          row_axis_name:
                            type: string
                            nullable: true
                          column_axis_name:
                            type: string
                          row_values:
                            type: array
                            description: Row-axis values in grid order (empty on a single-axis grid)
                            items:
                              type: object
                              properties:
                                value:
                                  type: string
                                percent:
                                  type: number
                          column_values:
                            type: array
                            description: Column-axis values in grid order
                            items:
                              type: object
                              properties:
                                value:
                                  type: string
                                percent:
                                  type: number
                          total_requested:
                            type: integer
                            description: The `total_quantity` sent to distribute; `0` on resolve
                          total_allocated:
                            type: integer
                            description: |
                              Quantity actually placed on cells. Equals `total_requested` whenever at least one
                              cell can receive quantity.
                          matched_cell_count:
                            type: integer
                            description: Cells backed by exactly one variant SKU
                          skipped_cell_count:
                            type: integer
                            description: 'Cells dropped because no variant, or more than one, matched'
                          warnings:
                            type: array
                            description: |
                              `NO_CHILD_SKUS` (no cell resolved to a variant SKU), `AMBIGUOUS_CELLS` (at least one
                              cell matched several variants and was dropped), `ZERO_WEIGHT_DISTRIBUTION` (every
                              remaining cell has a 0% share, so nothing can be allocated).
                            items:
                              type: string
                              enum:
                                - NO_CHILD_SKUS
                                - AMBIGUOUS_CELLS
                                - ZERO_WEIGHT_DISTRIBUTION
                          cells:
                            type: array
                            items:
                              type: object
                              properties:
                                row_value:
                                  type: string
                                  nullable: true
                                  description: Row-axis value; `null` on a single-axis grid
                                column_value:
                                  type: string
                                row_index:
                                  type: integer
                                  nullable: true
                                  description: Row position; `null` on a single-axis grid
                                column_index:
                                  type: integer
                                key:
                                  type: string
                                  description: 'Stable positional key, `{row_index}:{column_index}` zero-padded to four digits'
                                  example: '0000:0001'
                                share_percent:
                                  type: number
                                  description: 'The cell''s share of the total, in percent (two decimals)'
                                match_status:
                                  type: string
                                  enum:
                                    - matched
                                    - no_sku
                                    - ambiguous
                                  description: |
                                    `matched` (exactly one variant SKU backs the cell), `no_sku` (none does) or
                                    `ambiguous` (several do). Unmatched cells are dropped and their share is
                                    redistributed across the matched ones.
                                match_note:
                                  type: string
                                  nullable: true
                                  description: Why the cell did not match; `null` when matched
                                quantity:
                                  type: integer
                                  description: Quantity allocated to the cell (`0` on resolve)
                                included:
                                  type: boolean
                                  description: Whether the cell received quantity
                                child_sku_id:
                                  type: integer
                                  nullable: true
                                  description: Product ID of the variant SKU behind the cell
                                child_internal_sku:
                                  type: string
                                  nullable: true
                                child_product_name:
                                  type: string
                                  nullable: true
                                unit_price:
                                  type: number
                                  nullable: true
                                  description: Resolved purchase price for the variant
                                unit_price_source:
                                  type: string
                                  nullable: true
                                  enum:
                                    - child
                                    - supplier
                                    - master
                                    - none
                                    - null
                                  description: |
                                    Where `unit_price` came from: the variant itself, the supplier price (for
                                    `vendor_id`), the master SKU, or `none`.
                                inventory_tracked:
                                  type: boolean
                                  description: '`false` when the variant SKU is not inventory-tracked'
                                is_kit:
                                  type: boolean
                                  description: Whether the variant SKU is a kit
              example:
                data:
                  master:
                    sku_id: 5521
                    internal_sku: TEE-CLASSIC
                    product_name: Classic Tee
                    axes:
                      - Size
                  source: master
                  reason: null
                  reason_message: null
                  template:
                    id: 12
                    name: Apparel sizes
                    description: null
                    axis_count: 1
                    mode: single_axis
                    row_axis_name: null
                    column_axis_name: Size
                    row_values: []
                    column_values:
                      - value: S
                        percent: 40
                        sort_order: 0
                      - value: M
                        percent: 60
                        sort_order: 1
                    cells:
                      - size: S
                        axis: column
                        percent: 40
                        weight: 0.4
                      - size: M
                        axis: column
                        percent: 60
                        weight: 0.6
                    is_default: false
                    is_active: true
                    category_id: null
                    category_name: null
                    warehouse_id: null
                  rejected_template: null
                  grid:
                    template_id: 12
                    template_name: Apparel sizes
                    axis_count: 1
                    row_axis_name: null
                    column_axis_name: Size
                    row_values: []
                    column_values:
                      - value: S
                        percent: 40
                      - value: M
                        percent: 60
                    total_requested: 100
                    total_allocated: 100
                    matched_cell_count: 2
                    skipped_cell_count: 0
                    warnings: []
                    cells:
                      - row_value: null
                        column_value: S
                        row_index: null
                        column_index: 0
                        key: '0000:0000'
                        share_percent: 40
                        match_status: matched
                        match_note: null
                        quantity: 40
                        included: true
                        child_sku_id: 5522
                        child_internal_sku: TEE-CLASSIC-S
                        child_product_name: Classic Tee - S
                        unit_price: 4.25
                        unit_price_source: child
                        inventory_tracked: true
                        is_kit: false
                      - row_value: null
                        column_value: M
                        row_index: null
                        column_index: 1
                        key: '0000:0001'
                        share_percent: 60
                        match_status: matched
                        match_note: null
                        quantity: 60
                        included: true
                        child_sku_id: 5523
                        child_internal_sku: TEE-CLASSIC-M
                        child_product_name: Classic Tee - M
                        unit_price: 4.25
                        unit_price_source: child
                        inventory_tracked: true
                        is_kit: false
        '400':
          description: |
            Nothing can receive quantity: no template applies and the product has no variants to
            split across (the message explains why, or `No grid template applies to this SKU.`), or
            no cell resolves to a variant SKU (`No variant SKUs match this grid, so there is nothing
            to insert.`).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: |
            The master SKU (`SKU not found.`) or the `distribution_template_id`
            (`Grid template not found.`) does not exist
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error, e.g. `master_sku_id` or `total_quantity` missing, or a fractional
            `total_quantity` (`The quantity must be a whole number.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/distribution-templates/{templateId}':
    get:
      operationId: getDistributionTemplate
      tags:
        - Products
      summary: Get a distribution template
      description: 'Returns one distribution template by ID, whether or not it is active.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: templateId
          required: true
          schema:
            type: integer
          description: Distribution template ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A distribution template (size curve) that splits a master SKU total across its variants.
                    properties:
                      id:
                        type: integer
                        description: Distribution template ID
                        example: 12
                      name:
                        type: string
                        description: 'Template name, unique among non-deleted templates'
                        example: Apparel sizes
                      description:
                        type: string
                        nullable: true
                        description: Template description
                      axis_count:
                        type: integer
                        enum:
                          - 1
                          - 2
                        description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                      mode:
                        type: string
                        enum:
                          - single_axis
                          - dual_axis
                        description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                      row_axis_name:
                        type: string
                        nullable: true
                        description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                      column_axis_name:
                        type: string
                        description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                        example: Size
                      row_values:
                        type: array
                        description: Row-axis values with their percent share. Empty on a single-axis template.
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                              description: Axis value (e.g. a size or color)
                              example: M
                            percent:
                              type: number
                              description: 'Share of this axis value, in percent (0–100, two decimals)'
                              example: 60
                            sort_order:
                              type: integer
                              description: Position of the value on its axis
                              example: 1
                      column_values:
                        type: array
                        description: Column-axis values with their percent share.
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                              description: Axis value (e.g. a size or color)
                              example: M
                            percent:
                              type: number
                              description: 'Share of this axis value, in percent (0–100, two decimals)'
                              example: 60
                            sort_order:
                              type: integer
                              description: Position of the value on its axis
                              example: 1
                      cells:
                        type: array
                        description: |
                          Per-cell weights. On a single-axis template there is one cell per column value, with
                          `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                          pair, and the weight is the product of the row and column shares.
                        items:
                          type: object
                          properties:
                            size:
                              type: string
                              description: Column-axis value for this cell
                            axis:
                              type: string
                              enum:
                                - column
                            row_value:
                              type: string
                              description: Row-axis value (dual-axis templates only)
                            column_value:
                              type: string
                              description: Column-axis value (dual-axis templates only)
                            percent:
                              type: number
                              description: Cell share in percent (two decimals)
                            weight:
                              type: number
                              description: Cell share as a fraction (four decimals)
                      is_default:
                        type: boolean
                        description: Whether this is the tenant's default template
                      is_active:
                        type: boolean
                        description: Whether the template is active
                      category_id:
                        type: integer
                        nullable: true
                        description: 'Size-curve category the template belongs to, or `null`'
                      category_name:
                        type: string
                        nullable: true
                        description: 'Name of that category, or `null`'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: |
                          Destination warehouse the template is scoped to for category × warehouse resolution,
                          or `null` when it is not warehouse-scoped.
                    example:
                      id: 12
                      name: Apparel sizes
                      description: null
                      axis_count: 1
                      mode: single_axis
                      row_axis_name: null
                      column_axis_name: Size
                      row_values: []
                      column_values:
                        - value: S
                          percent: 40
                          sort_order: 0
                        - value: M
                          percent: 60
                          sort_order: 1
                      cells:
                        - size: S
                          axis: column
                          percent: 40
                          weight: 0.4
                        - size: M
                          axis: column
                          percent: 60
                          weight: 0.6
                      is_default: false
                      is_active: true
                      category_id: null
                      category_name: null
                      warehouse_id: null
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Template not found (`Distribution template not found.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: updateDistributionTemplate
      tags:
        - Products
      summary: Update a distribution template
      description: |
        Replaces a distribution template's definition. The body is the same as on create and is a
        full replacement, so send every field you want the template to keep. Fields left out fall
        back to their defaults (`is_default` to `false`, `is_active` to `true`, `sort_order`
        to `0`, `description`, `category_id` and `warehouse_id` to `null`).

        Note the method: this is a `POST` to the template's URL, not a `PUT`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: templateId
          required: true
          schema:
            type: integer
          description: Distribution template ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - axis_count
                - column_axis_name
                - column_values
              properties:
                name:
                  type: string
                  maxLength: 191
                  description: |
                    Template name. Must be unique among non-deleted templates; on update, sending the
                    template's current name is allowed.
                  example: Apparel sizes
                description:
                  type: string
                  nullable: true
                  maxLength: 2000
                axis_count:
                  type: integer
                  enum:
                    - 1
                    - 2
                  description: '`1` for a single-axis template, `2` for a dual-axis (row × column) template.'
                column_axis_name:
                  type: string
                  maxLength: 191
                  description: 'Variant type on the column axis, e.g. `Size`.'
                  example: Size
                column_values:
                  type: array
                  minItems: 1
                  maxItems: 200
                  description: Column-axis values. Values must be distinct and their percents must total 100.
                  items:
                    type: object
                    required:
                      - value
                      - percent
                    properties:
                      value:
                        type: string
                        maxLength: 191
                        description: Axis value (e.g. a size or color)
                        example: M
                      percent:
                        type: number
                        minimum: 0
                        maximum: 100
                        description: |
                          Share of this value in percent. The values on one axis must total 100, to within 0.01
                          (so twelve values of 8.33 are rejected; use eight at 8.33 and four at 8.34).
                        example: 60
                      sort_order:
                        type: integer
                        minimum: 0
                        nullable: true
                        description: Position on the axis. Defaults to the value's index in the array.
                row_axis_name:
                  type: string
                  nullable: true
                  maxLength: 191
                  description: |
                    Variant type on the row axis. Required when `axis_count` is `2`, and must be a different
                    variant type from `column_axis_name`. Rejected on a single-axis template.
                row_values:
                  type: array
                  maxItems: 200
                  description: |
                    Row-axis values, same shape and rules as `column_values`. Required when `axis_count` is
                    `2`; rejected on a single-axis template.
                  items:
                    type: object
                    required:
                      - value
                      - percent
                    properties:
                      value:
                        type: string
                        maxLength: 191
                        description: Axis value (e.g. a size or color)
                        example: M
                      percent:
                        type: number
                        minimum: 0
                        maximum: 100
                        description: |
                          Share of this value in percent. The values on one axis must total 100, to within 0.01
                          (so twelve values of 8.33 are rejected; use eight at 8.33 and four at 8.34).
                        example: 60
                      sort_order:
                        type: integer
                        minimum: 0
                        nullable: true
                        description: Position on the axis. Defaults to the value's index in the array.
                is_default:
                  type: boolean
                  default: false
                  description: Make this the tenant default. Promoting a template clears the previous default.
                is_active:
                  type: boolean
                  default: true
                sort_order:
                  type: integer
                  minimum: 0
                  default: 0
                category_id:
                  type: integer
                  nullable: true
                  description: |
                    ID of an existing size-curve category (see `GET /distribution-templates/categories`).
                warehouse_id:
                  type: integer
                  nullable: true
                  description: |
                    Destination warehouse this template applies to. Only allowed together with `category_id`.
                    At most one active template may exist per category and warehouse, including the
                    category's unscoped (no warehouse) slot.
            example:
              name: Apparel sizes
              axis_count: 1
              column_axis_name: Size
              column_values:
                - value: S
                  percent: 30
                - value: M
                  percent: 40
                - value: L
                  percent: 30
      responses:
        '200':
          description: Template updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A distribution template (size curve) that splits a master SKU total across its variants.
                    properties:
                      id:
                        type: integer
                        description: Distribution template ID
                        example: 12
                      name:
                        type: string
                        description: 'Template name, unique among non-deleted templates'
                        example: Apparel sizes
                      description:
                        type: string
                        nullable: true
                        description: Template description
                      axis_count:
                        type: integer
                        enum:
                          - 1
                          - 2
                        description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                      mode:
                        type: string
                        enum:
                          - single_axis
                          - dual_axis
                        description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                      row_axis_name:
                        type: string
                        nullable: true
                        description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                      column_axis_name:
                        type: string
                        description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                        example: Size
                      row_values:
                        type: array
                        description: Row-axis values with their percent share. Empty on a single-axis template.
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                              description: Axis value (e.g. a size or color)
                              example: M
                            percent:
                              type: number
                              description: 'Share of this axis value, in percent (0–100, two decimals)'
                              example: 60
                            sort_order:
                              type: integer
                              description: Position of the value on its axis
                              example: 1
                      column_values:
                        type: array
                        description: Column-axis values with their percent share.
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                              description: Axis value (e.g. a size or color)
                              example: M
                            percent:
                              type: number
                              description: 'Share of this axis value, in percent (0–100, two decimals)'
                              example: 60
                            sort_order:
                              type: integer
                              description: Position of the value on its axis
                              example: 1
                      cells:
                        type: array
                        description: |
                          Per-cell weights. On a single-axis template there is one cell per column value, with
                          `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                          pair, and the weight is the product of the row and column shares.
                        items:
                          type: object
                          properties:
                            size:
                              type: string
                              description: Column-axis value for this cell
                            axis:
                              type: string
                              enum:
                                - column
                            row_value:
                              type: string
                              description: Row-axis value (dual-axis templates only)
                            column_value:
                              type: string
                              description: Column-axis value (dual-axis templates only)
                            percent:
                              type: number
                              description: Cell share in percent (two decimals)
                            weight:
                              type: number
                              description: Cell share as a fraction (four decimals)
                      is_default:
                        type: boolean
                        description: Whether this is the tenant's default template
                      is_active:
                        type: boolean
                        description: Whether the template is active
                      category_id:
                        type: integer
                        nullable: true
                        description: 'Size-curve category the template belongs to, or `null`'
                      category_name:
                        type: string
                        nullable: true
                        description: 'Name of that category, or `null`'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: |
                          Destination warehouse the template is scoped to for category × warehouse resolution,
                          or `null` when it is not warehouse-scoped.
                    example:
                      id: 12
                      name: Apparel sizes
                      description: null
                      axis_count: 1
                      mode: single_axis
                      row_axis_name: null
                      column_axis_name: Size
                      row_values: []
                      column_values:
                        - value: S
                          percent: 40
                          sort_order: 0
                        - value: M
                          percent: 60
                          sort_order: 1
                      cells:
                        - size: S
                          axis: column
                          percent: 40
                          weight: 0.4
                        - size: M
                          axis: column
                          percent: 60
                          weight: 0.6
                      is_default: false
                      is_active: true
                      category_id: null
                      category_name: null
                      warehouse_id: null
        '400':
          description: The template could not be saved (`Failed to update grid template.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Template not found (`Grid template not found.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error. The body carries an `errors` object keyed by field, e.g. a duplicate
            `name` (`A distribution template with this name already exists.`), an axis whose
            percents do not total 100 (`Column percentages must total 100% (currently 99.96%).`),
            a duplicate or blank axis value, row data on a single-axis template, a missing row axis on
            a dual-axis template, identical row and column axes, a `warehouse_id` without a
            `category_id`, or a category and warehouse that already has an active template.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    delete:
      operationId: deleteDistributionTemplate
      tags:
        - Products
      summary: Delete a distribution template
      description: |
        Soft-deletes a distribution template and removes it from every product it was pinned on.
        Those products fall back to their size-curve category or the tenant default the next time
        a quantity is split.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: templateId
          required: true
          schema:
            type: integer
          description: Distribution template ID
      responses:
        '200':
          description: |
            Template deleted. The message says how many products it was removed from, or is
            `Grid template deleted.` when it was not pinned anywhere.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Grid template deleted and removed from 3 SKU(s).
        '400':
          description: The template could not be deleted (`Failed to delete grid template.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Template not found (`Grid template not found.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/distribution-templates/{templateId}/default':
    post:
      operationId: setDefaultDistributionTemplate
      tags:
        - Products
      summary: Set the default distribution template
      description: |
        Makes this template the tenant default and clears the previous default. Send an empty body.
        An inactive template cannot be the default.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: templateId
          required: true
          schema:
            type: integer
          description: Distribution template ID
      responses:
        '200':
          description: 'The template, now with `is_default: true`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A distribution template (size curve) that splits a master SKU total across its variants.
                    properties:
                      id:
                        type: integer
                        description: Distribution template ID
                        example: 12
                      name:
                        type: string
                        description: 'Template name, unique among non-deleted templates'
                        example: Apparel sizes
                      description:
                        type: string
                        nullable: true
                        description: Template description
                      axis_count:
                        type: integer
                        enum:
                          - 1
                          - 2
                        description: 'Number of axes (`1` = single axis, `2` = dual axis)'
                      mode:
                        type: string
                        enum:
                          - single_axis
                          - dual_axis
                        description: '`single_axis` when `axis_count` is `1`, `dual_axis` when it is `2`'
                      row_axis_name:
                        type: string
                        nullable: true
                        description: 'Variant type on the row axis (dual-axis templates only), e.g. `Color`'
                      column_axis_name:
                        type: string
                        description: 'Variant type on the column axis, e.g. `Size`. A single-axis template keeps its one axis here.'
                        example: Size
                      row_values:
                        type: array
                        description: Row-axis values with their percent share. Empty on a single-axis template.
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                              description: Axis value (e.g. a size or color)
                              example: M
                            percent:
                              type: number
                              description: 'Share of this axis value, in percent (0–100, two decimals)'
                              example: 60
                            sort_order:
                              type: integer
                              description: Position of the value on its axis
                              example: 1
                      column_values:
                        type: array
                        description: Column-axis values with their percent share.
                        items:
                          type: object
                          properties:
                            value:
                              type: string
                              description: Axis value (e.g. a size or color)
                              example: M
                            percent:
                              type: number
                              description: 'Share of this axis value, in percent (0–100, two decimals)'
                              example: 60
                            sort_order:
                              type: integer
                              description: Position of the value on its axis
                              example: 1
                      cells:
                        type: array
                        description: |
                          Per-cell weights. On a single-axis template there is one cell per column value, with
                          `weight` = `percent / 100`. On a dual-axis template there is one cell per row × column
                          pair, and the weight is the product of the row and column shares.
                        items:
                          type: object
                          properties:
                            size:
                              type: string
                              description: Column-axis value for this cell
                            axis:
                              type: string
                              enum:
                                - column
                            row_value:
                              type: string
                              description: Row-axis value (dual-axis templates only)
                            column_value:
                              type: string
                              description: Column-axis value (dual-axis templates only)
                            percent:
                              type: number
                              description: Cell share in percent (two decimals)
                            weight:
                              type: number
                              description: Cell share as a fraction (four decimals)
                      is_default:
                        type: boolean
                        description: Whether this is the tenant's default template
                      is_active:
                        type: boolean
                        description: Whether the template is active
                      category_id:
                        type: integer
                        nullable: true
                        description: 'Size-curve category the template belongs to, or `null`'
                      category_name:
                        type: string
                        nullable: true
                        description: 'Name of that category, or `null`'
                      warehouse_id:
                        type: integer
                        nullable: true
                        description: |
                          Destination warehouse the template is scoped to for category × warehouse resolution,
                          or `null` when it is not warehouse-scoped.
                    example:
                      id: 12
                      name: Apparel sizes
                      description: null
                      axis_count: 1
                      mode: single_axis
                      row_axis_name: null
                      column_axis_name: Size
                      row_values: []
                      column_values:
                        - value: S
                          percent: 40
                          sort_order: 0
                        - value: M
                          percent: 60
                          sort_order: 1
                      cells:
                        - size: S
                          axis: column
                          percent: 40
                          weight: 0.4
                        - size: M
                          axis: column
                          percent: 60
                          weight: 0.6
                      is_default: false
                      is_active: true
                      category_id: null
                      category_name: null
                      warehouse_id: null
        '400':
          description: The template is inactive (`An inactive grid template cannot be the tenant default.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Template not found (`Grid template not found.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/distribution-templates/{templateId}/assign':
    post:
      operationId: bulkAssignDistributionTemplate
      tags:
        - Products
      summary: Assign a distribution template to multiple products
      description: |
        Pins this template on each of the listed products, the bulk form of
        `PUT /products/{productId}/distribution-template`. Each product is handled on its own: one
        that cannot take the template (not found, not a master SKU, variant options that do not
        match the template) is reported as an error in `results` and the rest are still assigned.
        The response is `200` even when some or all assignments fail, so check `failed`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: templateId
          required: true
          schema:
            type: integer
          description: Distribution template ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sku_ids
              properties:
                sku_ids:
                  type: array
                  minItems: 1
                  description: Product IDs of the master SKUs to assign the template to
                  items:
                    type: integer
            example:
              sku_ids:
                - 5521
                - 5530
                - 5544
      responses:
        '200':
          description: Per-product results
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      template_id:
                        type: integer
                      template_name:
                        type: string
                      total:
                        type: integer
                        description: Number of product IDs sent
                      succeeded:
                        type: integer
                      failed:
                        type: integer
                      results:
                        type: array
                        items:
                          type: object
                          properties:
                            sku_id:
                              type: integer
                            status:
                              type: string
                              enum:
                                - assigned
                                - error
                            message:
                              type: string
                              description: Why the assignment failed. Present only when `status` is `error`.
              example:
                data:
                  template_id: 12
                  template_name: Apparel sizes
                  total: 3
                  succeeded: 2
                  failed: 1
                  results:
                    - sku_id: 5521
                      status: assigned
                    - sku_id: 5530
                      status: assigned
                    - sku_id: 5544
                      status: error
                      message: SKU not found.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Template not found (`Distribution template not found.`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (`sku_ids` missing, empty, or not integers)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /labels/render:
    post:
      operationId: renderLabel
      tags:
        - Labels
      summary: Render ZPL label
      description: |
        Render a ZPL label to an image or PDF using the Labelary service.

        Returns raw image or PDF bytes on success (not JSON). The `Content-Type` header will be
        set to the appropriate image or PDF MIME type.

        On error, returns a JSON response with `message` and/or `errors` fields.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - zpl
              properties:
                zpl:
                  type: string
                  description: ZPL source code to render
                dpmm:
                  type: string
                  enum:
                    - 6dpmm
                    - 8dpmm
                    - 12dpmm
                    - 24dpmm
                  default: 8dpmm
                  description: Dots per millimeter resolution
                width:
                  type: number
                  minimum: 0.1
                  maximum: 15
                  default: 4
                  description: Label width in inches
                height:
                  type: number
                  minimum: 0.1
                  maximum: 15
                  default: 6
                  description: Label height in inches
                format:
                  type: string
                  enum:
                    - png
                    - pdf
                  default: png
                  description: Output format
                index:
                  type: integer
                  minimum: 0
                  description: Label index in ZPL (for multi-label ZPL)
            example:
              zpl: '^XA^FO50,50^ADN,36,20^FDHello World^FS^XZ'
              dpmm: 8dpmm
              width: 4
              height: 6
              format: png
      responses:
        '200':
          description: Rendered label image or PDF
          content:
            image/png:
              schema:
                type: string
                format: binary
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
        '500':
          description: Labelary API failure
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /imports/types:
    get:
      operationId: getImportTypes
      tags:
        - Imports
      summary: List import types
      description: |
        Return the catalog of bulk-import types that are available via the External API.

        Use the returned `type` keys with `GET /imports/specs?type=...` to discover the
        fields each type accepts, and with `POST /imports` to submit data.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Import type catalog
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          example: master_skus
                        label:
                          type: string
                          example: Master SKUs
                        description:
                          type: string
                          example: Create and update products by master SKU.
                        specs_url:
                          type: string
                          format: uri
                          description: Convenience URL to fetch field specs for this type
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /imports/specs:
    get:
      operationId: getImportSpecs
      tags:
        - Imports
      summary: Field schema for an import type
      description: |
        Return the field schema for a single import type — the column names, data types,
        whether each column is required, and any allowed enum values. Use this to validate
        a CSV/JSON payload before submitting it to `POST /imports`.

        **Custom fields (`sales_orders`):** the `sales_orders` schema also lists every Sales Order
        custom field defined on the account, after the reserved columns. Each one has
        `isCustomField: true`, its `customFieldId`, `required: false`, and its custom-field label as
        `field` — use that label as the column name (or as the `column_mapping` target) to write the
        value onto the imported order. Dropdown custom fields carry their options in `allowedValues`;
        a value that fails the custom field's validation is reported as a per-row import error rather
        than failing the whole import. A custom field whose label matches a reserved column
        (case-insensitive) is left out, and the reserved column wins.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: type
          required: true
          schema:
            type: string
          description: Import type key (one of the keys returned by `GET /imports/types`)
          example: master_skus
      responses:
        '200':
          description: Import field definitions
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      type:
                        type: string
                        example: master_skus
                      label:
                        type: string
                      description:
                        type: string
                      fields:
                        type: array
                        items:
                          type: object
                          properties:
                            field:
                              type: string
                              description: Canonical system field name
                              example: MASTER_SKU
                            type:
                              type: string
                              description: 'e.g. `string`, `integer`, `decimal`, `boolean`'
                            required:
                              type: boolean
                            description:
                              type: string
                            allowedValues:
                              type: array
                              nullable: true
                              description: Present for enum-style fields (including dropdown custom fields)
                              items: {}
                            isCustomField:
                              type: boolean
                              description: Present and `true` on account custom-field columns (currently `sales_orders` only)
                            customFieldId:
                              type: integer
                              description: ID of the custom field this column writes to. Present only when `isCustomField` is true.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (unknown or unsupported import type)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /imports/mapping-suggestions:
    post:
      operationId: suggestImportColumnMapping
      tags:
        - Imports
      summary: AI-suggested column mapping
      description: |
        Upload a small CSV sample (the first ~20 rows is plenty) and receive an AI-suggested
        mapping from canonical system field names to the column headers found in your CSV.

        Use the result directly as the `column_mapping` argument to `POST /imports`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - type
                - file
              properties:
                type:
                  type: string
                  description: Import type key
                  example: master_skus
                file:
                  type: string
                  format: binary
                  description: |
                    CSV sample. `.csv` or `.txt` only (Excel files are not accepted —
                    export to CSV first). Max 20 MB. UTF-8 encoding recommended;
                    first row must be a header row.
      responses:
        '200':
          description: Suggested mapping (system field name → source column header)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties:
                      type: string
                    example:
                      MASTER_SKU: Product ID
                      PRODUCT_NAME: Name
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /imports:
    get:
      operationId: getImports
      tags:
        - Imports
      summary: List imports
      description: |
        Paginated list of bulk-import jobs created against this tenant. Optionally
        filter by import `type`.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: type
          schema:
            type: string
          description: Filter by import type key
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        Bulk import job record. Returned from the imports endpoints and reflects the
                        async `ImportJob` that processes the rows.
                      properties:
                        id:
                          type: integer
                          description: Import ID
                          example: 8421
                        type:
                          type: string
                          description: Import type key (see `GET /imports/types`)
                          example: master_skus
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        email:
                          type: string
                          nullable: true
                          description: Email address that will receive the completion notification (PII-hashed when PII filtering is enabled)
                          example: ops@example.com
                        options:
                          type: object
                          nullable: true
                          description: Free-form import options recorded with the job (PII-redacted when applicable)
                        imported_by:
                          type: string
                          nullable: true
                          description: Name or email of the user who created the import (PII-redacted when applicable)
                          example: Jane Doe
                        stats:
                          type: object
                          properties:
                            total_rows:
                              type: integer
                              example: 1240
                            success_count:
                              type: integer
                              description: |
                                Rows imported without error (`total_rows` minus `error_count`). For
                                `inventory_quantities` imports this reports `0` while the underlying job
                                is still in flight (queued or running) and only reflects the real count
                                once the job has finished — poll until the `job.finished_at` timestamp
                                is set before relying on it.
                              example: 1235
                            error_count:
                              type: integer
                              example: 5
                        job:
                          type: object
                          nullable: true
                          description: |
                            The underlying async job. Only present when the `job` relation is loaded
                            (which is the case for create, resume, retry, copy, and `GET /imports/{id}` responses).
                          properties:
                            id:
                              type: integer
                            job_id:
                              type: string
                              nullable: true
                              description: Underlying queue job identifier
                            type:
                              type: string
                              nullable: true
                            status:
                              type: string
                              nullable: true
                              description: 'e.g. `queued`, `executing`, `finished`, `failed`'
                            queue:
                              type: string
                              nullable: true
                            attempts:
                              type: integer
                              nullable: true
                            progress_now:
                              type: integer
                              nullable: true
                              description: Rows processed so far
                            progress_max:
                              type: integer
                              nullable: true
                              description: Total rows to process
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            started_at:
                              type: string
                              format: date-time
                              nullable: true
                            finished_at:
                              type: string
                              format: date-time
                              nullable: true
                      required:
                        - id
                        - type
                        - stats
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createImport
      tags:
        - Imports
      summary: Submit a bulk import
      description: |
        Create and queue a bulk-import job. Two payload formats are supported:

        - **CSV (recommended)** — `multipart/form-data` with a `.csv` file (up to
          20 MB), the import `type`, and an optional `column_mapping` JSON string
          (system field → CSV header). File uploads are recommended for speed: the
          server streams rows directly from disk rather than parsing a JSON array
          in memory, so throughput is significantly higher for non-trivial datasets.
        - **JSON** — `application/json` with `type` and `rows` (up to 10,000 items).
          `column_mapping` here maps system field names → keys present in each row
          object. Use CSV upload for anything larger.

        ### File support

        | Extension | Accepted | Notes |
        | --- | --- | --- |
        | `.csv` | ✅ | Preferred. Comma-delimited, UTF-8, header row required. |
        | `.txt` | ✅ | Treated as CSV (same parser, same expectations). |
        | `.xlsx` / `.xls` | ❌ | Excel files are not accepted — export to CSV first. |

        Other CSV details:

        - **Max upload size:** 20 MB. Larger files are rejected with `422`.
        - **Header row:** the first row must contain column names. Headers are trimmed of whitespace.
        - **Delimiter / quoting:** standard CSV — comma delimiter, double-quote enclosure.
          Use double quotes to wrap fields that contain commas, newlines, or quotes
          (escape an embedded quote by doubling it: `""`).
        - **Empty rows** are skipped automatically.
        - **Encoding:** UTF-8 is strongly recommended. Other encodings may parse but
          can corrupt non-ASCII characters.

        On success the endpoint returns `201` with the import record (including its
        `job` progress fields). Poll `GET /imports/{id}` to track progress.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - type
                - file
              properties:
                type:
                  type: string
                  description: Import type key (see `GET /imports/types`)
                  example: master_skus
                file:
                  type: string
                  format: binary
                  description: 'CSV file (`.csv` or `.txt`, max 20 MB)'
                column_mapping:
                  type: string
                  description: JSON object as a string — system field name → CSV header name
                  example: '{"MASTER_SKU":"Product ID","PRODUCT_NAME":"Name"}'
                email:
                  type: string
                  format: email
                  description: Email address to notify when the import finishes
                job_name:
                  type: string
                  maxLength: 255
                  description: Human-readable name for the job
                options:
                  type: string
                  description: JSON object as a string — additional per-type options
          application/json:
            schema:
              type: object
              required:
                - type
                - rows
              properties:
                type:
                  type: string
                  description: Import type key
                  example: master_skus
                rows:
                  type: array
                  maxItems: 10000
                  description: |
                    Up to 10,000 row objects. Each row is an object whose keys correspond
                    to canonical system field names (or to the keys you supply in
                    `column_mapping`). Use the CSV upload for larger datasets.
                  items:
                    type: object
                    additionalProperties: true
                column_mapping:
                  type: object
                  description: |
                    Optional mapping from system field name → the key used in each row
                    object. Useful when your row objects use source-system field names
                    rather than canonical ones.
                  additionalProperties:
                    type: string
                email:
                  type: string
                  format: email
                  description: Email address to notify when the import finishes
                job_name:
                  type: string
                  maxLength: 255
                options:
                  type: object
                  description: Free-form per-type options
                  additionalProperties: true
      responses:
        '201':
          description: Import created and job queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Bulk import job record. Returned from the imports endpoints and reflects the
                      async `ImportJob` that processes the rows.
                    properties:
                      id:
                        type: integer
                        description: Import ID
                        example: 8421
                      type:
                        type: string
                        description: Import type key (see `GET /imports/types`)
                        example: master_skus
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      email:
                        type: string
                        nullable: true
                        description: Email address that will receive the completion notification (PII-hashed when PII filtering is enabled)
                        example: ops@example.com
                      options:
                        type: object
                        nullable: true
                        description: Free-form import options recorded with the job (PII-redacted when applicable)
                      imported_by:
                        type: string
                        nullable: true
                        description: Name or email of the user who created the import (PII-redacted when applicable)
                        example: Jane Doe
                      stats:
                        type: object
                        properties:
                          total_rows:
                            type: integer
                            example: 1240
                          success_count:
                            type: integer
                            description: |
                              Rows imported without error (`total_rows` minus `error_count`). For
                              `inventory_quantities` imports this reports `0` while the underlying job
                              is still in flight (queued or running) and only reflects the real count
                              once the job has finished — poll until the `job.finished_at` timestamp
                              is set before relying on it.
                            example: 1235
                          error_count:
                            type: integer
                            example: 5
                      job:
                        type: object
                        nullable: true
                        description: |
                          The underlying async job. Only present when the `job` relation is loaded
                          (which is the case for create, resume, retry, copy, and `GET /imports/{id}` responses).
                        properties:
                          id:
                            type: integer
                          job_id:
                            type: string
                            nullable: true
                            description: Underlying queue job identifier
                          type:
                            type: string
                            nullable: true
                          status:
                            type: string
                            nullable: true
                            description: 'e.g. `queued`, `executing`, `finished`, `failed`'
                          queue:
                            type: string
                            nullable: true
                          attempts:
                            type: integer
                            nullable: true
                          progress_now:
                            type: integer
                            nullable: true
                            description: Rows processed so far
                          progress_max:
                            type: integer
                            nullable: true
                            description: Total rows to process
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                          updated_at:
                            type: string
                            format: date-time
                            nullable: true
                          started_at:
                            type: string
                            format: date-time
                            nullable: true
                          finished_at:
                            type: string
                            format: date-time
                            nullable: true
                    required:
                      - id
                      - type
                      - stats
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/imports/{id}/download':
    get:
      operationId: downloadImportFile
      tags:
        - Imports
      summary: Download the original import file
      description: |
        Download the original submitted rows as an Excel (`.xlsx`) file. Useful for
        auditing what was sent to the import job.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Import ID
      responses:
        '200':
          description: Excel file download
          content:
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Import not found or has no data
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/imports/{id}/preview':
    get:
      operationId: previewImportFile
      tags:
        - Imports
      summary: Preview the import file rows
      description: |
        Return the first 100 rows of the original submitted input as JSON so the
        raw file contents can be rendered inline (no download). The `columns` array
        is derived from the union of keys across the previewed rows, preserving
        first-seen order so the header matches the source file. Each entry in `rows`
        is the original input row as a key/value object.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Import ID
      responses:
        '200':
          description: Import preview payload
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Import ID
                      type:
                        type: string
                        description: 'Import type (e.g. `products`, `sales_orders`)'
                      total_rows:
                        type: integer
                        description: Total number of rows in the original input
                      preview_count:
                        type: integer
                        description: Number of rows returned in this preview (at most `limit`)
                      limit:
                        type: integer
                        description: Maximum number of rows returned (always `100`)
                      columns:
                        type: array
                        description: |
                          Column names in first-seen order, taken from the union of
                          keys across the previewed rows.
                        items:
                          type: string
                      rows:
                        type: array
                        description: 'The previewed input rows, each as a key/value object.'
                        items:
                          type: object
                          additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Import not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/imports/{id}/errors':
    get:
      operationId: getImportErrors
      tags:
        - Imports
      summary: Download import errors
      description: |
        Download only the rows that failed during processing as an Excel (`.xlsx`)
        file. Returns `404` if the import has no recorded errors.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Import ID
      responses:
        '200':
          description: Excel file download
          content:
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Import not found or has no errors
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/imports/{id}/resume':
    post:
      operationId: resumeImport
      tags:
        - Imports
      summary: Resume an incomplete import
      description: |
        Re-dispatch an import job that did not finish, picking up from where it left off.

        If the original import recorded job progress, no body is required — the resume
        will start from the recorded position. If progress was not recorded, pass
        `start_position` to indicate which row to resume from.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Import ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                start_position:
                  type: integer
                  minimum: 0
                  description: Row index to resume from when no job progress is available
      responses:
        '200':
          description: Resume job queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Bulk import job record. Returned from the imports endpoints and reflects the
                      async `ImportJob` that processes the rows.
                    properties:
                      id:
                        type: integer
                        description: Import ID
                        example: 8421
                      type:
                        type: string
                        description: Import type key (see `GET /imports/types`)
                        example: master_skus
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      email:
                        type: string
                        nullable: true
                        description: Email address that will receive the completion notification (PII-hashed when PII filtering is enabled)
                        example: ops@example.com
                      options:
                        type: object
                        nullable: true
                        description: Free-form import options recorded with the job (PII-redacted when applicable)
                      imported_by:
                        type: string
                        nullable: true
                        description: Name or email of the user who created the import (PII-redacted when applicable)
                        example: Jane Doe
                      stats:
                        type: object
                        properties:
                          total_rows:
                            type: integer
                            example: 1240
                          success_count:
                            type: integer
                            description: |
                              Rows imported without error (`total_rows` minus `error_count`). For
                              `inventory_quantities` imports this reports `0` while the underlying job
                              is still in flight (queued or running) and only reflects the real count
                              once the job has finished — poll until the `job.finished_at` timestamp
                              is set before relying on it.
                            example: 1235
                          error_count:
                            type: integer
                            example: 5
                      job:
                        type: object
                        nullable: true
                        description: |
                          The underlying async job. Only present when the `job` relation is loaded
                          (which is the case for create, resume, retry, copy, and `GET /imports/{id}` responses).
                        properties:
                          id:
                            type: integer
                          job_id:
                            type: string
                            nullable: true
                            description: Underlying queue job identifier
                          type:
                            type: string
                            nullable: true
                          status:
                            type: string
                            nullable: true
                            description: 'e.g. `queued`, `executing`, `finished`, `failed`'
                          queue:
                            type: string
                            nullable: true
                          attempts:
                            type: integer
                            nullable: true
                          progress_now:
                            type: integer
                            nullable: true
                            description: Rows processed so far
                          progress_max:
                            type: integer
                            nullable: true
                            description: Total rows to process
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                          updated_at:
                            type: string
                            format: date-time
                            nullable: true
                          started_at:
                            type: string
                            format: date-time
                            nullable: true
                          finished_at:
                            type: string
                            format: date-time
                            nullable: true
                    required:
                      - id
                      - type
                      - stats
        '400':
          description: Cannot resume — no progress recorded and `start_position` was not supplied
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Import not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/imports/{id}/retry-errors':
    post:
      operationId: retryImportErrors
      tags:
        - Imports
      summary: Retry errored rows
      description: |
        Create a new import that processes only the rows that failed in the source
        import. Useful for re-running after fixing the underlying data issue.

        Returns `400` if the source import has no recorded errors to retry.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Source import ID
      responses:
        '200':
          description: Retry job queued — returns the new import record
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Bulk import job record. Returned from the imports endpoints and reflects the
                      async `ImportJob` that processes the rows.
                    properties:
                      id:
                        type: integer
                        description: Import ID
                        example: 8421
                      type:
                        type: string
                        description: Import type key (see `GET /imports/types`)
                        example: master_skus
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      email:
                        type: string
                        nullable: true
                        description: Email address that will receive the completion notification (PII-hashed when PII filtering is enabled)
                        example: ops@example.com
                      options:
                        type: object
                        nullable: true
                        description: Free-form import options recorded with the job (PII-redacted when applicable)
                      imported_by:
                        type: string
                        nullable: true
                        description: Name or email of the user who created the import (PII-redacted when applicable)
                        example: Jane Doe
                      stats:
                        type: object
                        properties:
                          total_rows:
                            type: integer
                            example: 1240
                          success_count:
                            type: integer
                            description: |
                              Rows imported without error (`total_rows` minus `error_count`). For
                              `inventory_quantities` imports this reports `0` while the underlying job
                              is still in flight (queued or running) and only reflects the real count
                              once the job has finished — poll until the `job.finished_at` timestamp
                              is set before relying on it.
                            example: 1235
                          error_count:
                            type: integer
                            example: 5
                      job:
                        type: object
                        nullable: true
                        description: |
                          The underlying async job. Only present when the `job` relation is loaded
                          (which is the case for create, resume, retry, copy, and `GET /imports/{id}` responses).
                        properties:
                          id:
                            type: integer
                          job_id:
                            type: string
                            nullable: true
                            description: Underlying queue job identifier
                          type:
                            type: string
                            nullable: true
                          status:
                            type: string
                            nullable: true
                            description: 'e.g. `queued`, `executing`, `finished`, `failed`'
                          queue:
                            type: string
                            nullable: true
                          attempts:
                            type: integer
                            nullable: true
                          progress_now:
                            type: integer
                            nullable: true
                            description: Rows processed so far
                          progress_max:
                            type: integer
                            nullable: true
                            description: Total rows to process
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                          updated_at:
                            type: string
                            format: date-time
                            nullable: true
                          started_at:
                            type: string
                            format: date-time
                            nullable: true
                          finished_at:
                            type: string
                            format: date-time
                            nullable: true
                    required:
                      - id
                      - type
                      - stats
        '400':
          description: Source import has no errors to retry
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Import not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/imports/{id}/copy':
    post:
      operationId: copyImport
      tags:
        - Imports
      summary: Copy an import
      description: |
        Create a brand-new import that re-runs the same input rows and options as
        the source import. Useful for re-running an entire dataset after a config
        change without re-uploading.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Source import ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                  description: Override the notification email on the new import
                job_name:
                  type: string
                  maxLength: 255
                  description: Name for the new job (defaults to "Import Job")
      responses:
        '200':
          description: New import created and job queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Bulk import job record. Returned from the imports endpoints and reflects the
                      async `ImportJob` that processes the rows.
                    properties:
                      id:
                        type: integer
                        description: Import ID
                        example: 8421
                      type:
                        type: string
                        description: Import type key (see `GET /imports/types`)
                        example: master_skus
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      email:
                        type: string
                        nullable: true
                        description: Email address that will receive the completion notification (PII-hashed when PII filtering is enabled)
                        example: ops@example.com
                      options:
                        type: object
                        nullable: true
                        description: Free-form import options recorded with the job (PII-redacted when applicable)
                      imported_by:
                        type: string
                        nullable: true
                        description: Name or email of the user who created the import (PII-redacted when applicable)
                        example: Jane Doe
                      stats:
                        type: object
                        properties:
                          total_rows:
                            type: integer
                            example: 1240
                          success_count:
                            type: integer
                            description: |
                              Rows imported without error (`total_rows` minus `error_count`). For
                              `inventory_quantities` imports this reports `0` while the underlying job
                              is still in flight (queued or running) and only reflects the real count
                              once the job has finished — poll until the `job.finished_at` timestamp
                              is set before relying on it.
                            example: 1235
                          error_count:
                            type: integer
                            example: 5
                      job:
                        type: object
                        nullable: true
                        description: |
                          The underlying async job. Only present when the `job` relation is loaded
                          (which is the case for create, resume, retry, copy, and `GET /imports/{id}` responses).
                        properties:
                          id:
                            type: integer
                          job_id:
                            type: string
                            nullable: true
                            description: Underlying queue job identifier
                          type:
                            type: string
                            nullable: true
                          status:
                            type: string
                            nullable: true
                            description: 'e.g. `queued`, `executing`, `finished`, `failed`'
                          queue:
                            type: string
                            nullable: true
                          attempts:
                            type: integer
                            nullable: true
                          progress_now:
                            type: integer
                            nullable: true
                            description: Rows processed so far
                          progress_max:
                            type: integer
                            nullable: true
                            description: Total rows to process
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                          updated_at:
                            type: string
                            format: date-time
                            nullable: true
                          started_at:
                            type: string
                            format: date-time
                            nullable: true
                          finished_at:
                            type: string
                            format: date-time
                            nullable: true
                    required:
                      - id
                      - type
                      - stats
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Source import not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/imports/{id}':
    get:
      operationId: getImportById
      tags:
        - Imports
      summary: Get import by ID
      description: |
        Retrieve a single import record, including its `job` status and row stats.
        Poll this endpoint to track an import's progress to completion.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Import ID
      responses:
        '200':
          description: Import record with job and stats
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      Bulk import job record. Returned from the imports endpoints and reflects the
                      async `ImportJob` that processes the rows.
                    properties:
                      id:
                        type: integer
                        description: Import ID
                        example: 8421
                      type:
                        type: string
                        description: Import type key (see `GET /imports/types`)
                        example: master_skus
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      email:
                        type: string
                        nullable: true
                        description: Email address that will receive the completion notification (PII-hashed when PII filtering is enabled)
                        example: ops@example.com
                      options:
                        type: object
                        nullable: true
                        description: Free-form import options recorded with the job (PII-redacted when applicable)
                      imported_by:
                        type: string
                        nullable: true
                        description: Name or email of the user who created the import (PII-redacted when applicable)
                        example: Jane Doe
                      stats:
                        type: object
                        properties:
                          total_rows:
                            type: integer
                            example: 1240
                          success_count:
                            type: integer
                            description: |
                              Rows imported without error (`total_rows` minus `error_count`). For
                              `inventory_quantities` imports this reports `0` while the underlying job
                              is still in flight (queued or running) and only reflects the real count
                              once the job has finished — poll until the `job.finished_at` timestamp
                              is set before relying on it.
                            example: 1235
                          error_count:
                            type: integer
                            example: 5
                      job:
                        type: object
                        nullable: true
                        description: |
                          The underlying async job. Only present when the `job` relation is loaded
                          (which is the case for create, resume, retry, copy, and `GET /imports/{id}` responses).
                        properties:
                          id:
                            type: integer
                          job_id:
                            type: string
                            nullable: true
                            description: Underlying queue job identifier
                          type:
                            type: string
                            nullable: true
                          status:
                            type: string
                            nullable: true
                            description: 'e.g. `queued`, `executing`, `finished`, `failed`'
                          queue:
                            type: string
                            nullable: true
                          attempts:
                            type: integer
                            nullable: true
                          progress_now:
                            type: integer
                            nullable: true
                            description: Rows processed so far
                          progress_max:
                            type: integer
                            nullable: true
                            description: Total rows to process
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                          updated_at:
                            type: string
                            format: date-time
                            nullable: true
                          started_at:
                            type: string
                            format: date-time
                            nullable: true
                          finished_at:
                            type: string
                            format: date-time
                            nullable: true
                    required:
                      - id
                      - type
                      - stats
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Import not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills:
    get:
      operationId: getBills
      tags:
        - Bills
      summary: List bills
      description: |
        Get a paginated list of bills with optional filtering.

        For detailed information about the filtering system and available operators,
        refer to the [Filter System Documentation](/filters).
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: vendor_id
          schema:
            type: integer
          description: Only bills for this vendor (supplier) ID.
        - in: query
          name: status
          schema:
            type: string
            enum:
              - draft
              - open
              - partially_paid
              - paid
              - cancelled
          description: Only bills in this status.
        - in: query
          name: overdue
          schema:
            type: boolean
          description: 'When true, only `open` or `partially_paid` bills whose due date is before today.'
        - in: query
          name: due_soon
          schema:
            type: boolean
          description: 'When true, only `draft`, `open` or `partially_paid` bills due within the next 14 days (today included).'
        - in: query
          name: due_from
          schema:
            type: string
            format: date
          description: Only bills due on or after this date.
        - in: query
          name: due_to
          schema:
            type: string
            format: date
          description: Only bills due on or before this date.
        - in: query
          name: purchase_order_id
          schema:
            type: integer
          description: 'Only bills linked to this purchase order, either directly, through a bill line that references one of its lines, or through a purchase order linked to the bill after the fact (for example via `purchase_order_ids` or a later PO link).'
        - in: query
          name: search
          schema:
            type: string
            maxLength: 255
          description: 'Partial match on bill number, vendor invoice number, the bill''s alternate IDs, or the alternate IDs of any linked purchase order (direct, through a bill line, or linked to the bill after the fact).'
        - in: query
          name: reconcile_status
          schema:
            type: string
            enum:
              - reconciled
              - partial
              - unreconciled
              - n/a
          description: |
            Only bills with this line-reconciliation state. `reconciled`: every non-adjustment line is fully allocated.
            `partial`: some allocation exists. `unreconciled`: no allocations. `n/a`: the bill has no non-adjustment lines.
        - in: query
          name: variance_status
          schema:
            type: string
            enum:
              - detected
              - resolved
          description: Only bills with this variance status. `detected` also matches bills where a line's allocated amount differs from the line amount by more than 0.01.
        - in: query
          name: sync_status
          schema:
            type: string
            enum:
              - not_pushed
              - waiting
              - syncing
              - synced
              - failed
          description: |
            Only bills in this accounting sync state (QuickBooks or Xero).
            `not_pushed`: never queued for sync. `waiting`: queued to post or re-sync. `syncing`: push in progress.
            `synced`: posted to the accounting system. `failed`: the last push failed.
        - in: query
          name: completion
          schema:
            type: string
            enum:
              - completed
              - needs_attention
          description: |
            Only bills in this completion view. `completed`: `paid` bills whose lines are all reconciled
            (`reconcile_status` of `reconciled` or `n/a`). `needs_attention`: every other bill that is not `cancelled`.
            Combines with the other filters.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createBill
      tags:
        - Bills
      summary: Create a bill
      description: |
        Create a new bill record.

        Each line item's `amount` must be zero or greater, except for adjustment
        lines (`line_type` of `adjustment`), which may carry a negative amount to
        record a credit or downward correction. A negative `amount` on any other
        line type returns `422`.

        **Linking purchase orders.** A bill can be linked to one or more purchase
        orders. Pass `purchase_order_ids` (an array of PO IDs) to link multiple
        purchase orders to the bill. The legacy single `purchase_order_id` field is
        still accepted for backward compatibility and is treated as a one-element
        `purchase_order_ids` array. Linked POs are returned under the bill's
        `purchase_orders` field.

        **Linking assembly orders and work orders.** A bill can also be created
        against manufacturing output. Pass `assembly_order_ids` and/or
        `work_order_ids` to link assembly orders and work orders; the linked
        records are returned under the bill's `assembly_orders` and `work_orders`
        fields. To reconcile individual bill line items against manufacturing
        lines, set `items.*.assembly_order_id`, `items.*.assembly_order_line_id`
        (component lines), or `items.*.assembly_order_extra_cost_id` (extra
        costs / manufacturing service fees) on the item. Use
        `GET /assembly-orders/{assemblyOrderId}/billable-lines` or
        `GET /work-orders/{workOrderId}/billable-lines` to discover the billable
        lines to reference.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                purchase_order_ids:
                  type: array
                  nullable: true
                  description: |
                    IDs of the purchase orders to link to this bill. Use this to link
                    multiple POs. Each ID must reference an existing purchase order.
                  items:
                    type: integer
                purchase_order_id:
                  type: integer
                  nullable: true
                  description: |
                    Deprecated — single purchase order to link. Prefer
                    `purchase_order_ids`. When supplied without `purchase_order_ids`,
                    it is treated as a one-element `purchase_order_ids` array.
                assembly_order_ids:
                  type: array
                  nullable: true
                  description: |
                    IDs of the assembly orders to link to this bill. Each ID must
                    reference an existing assembly order.
                  items:
                    type: integer
                work_order_ids:
                  type: array
                  nullable: true
                  description: |
                    IDs of the work orders to link to this bill. Each ID must
                    reference an existing work order.
                  items:
                    type: integer
                items:
                  type: array
                  nullable: true
                  description: |
                    Bill line items. Alongside the standard fields, each item may
                    reference a manufacturing source line for reconciliation:
                    `assembly_order_id`, `assembly_order_line_id` (component lines),
                    and `assembly_order_extra_cost_id` (extra costs). A line may also
                    record which production run (production batch) it originated from
                    via `production_batch_id` and/or `production_batch_number`.
                  items:
                    type: object
                    properties:
                      assembly_order_id:
                        type: integer
                        nullable: true
                      assembly_order_line_id:
                        type: integer
                        nullable: true
                      assembly_order_extra_cost_id:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the production run (production batch) this line
                          originated from. Echoed back on the bill item as
                          `production_batch_id`.
                      production_batch_number:
                        type: string
                        nullable: true
                        maxLength: 100
                        description: |
                          Human-readable production run number this line originated
                          from. Echoed back on the bill item as
                          `production_batch_number`.
      responses:
        '201':
          description: Bill created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error — for example a line item's `amount` is negative on a
            non-adjustment line (only `line_type` of `adjustment` may be negative).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills/summary:
    get:
      operationId: getBillsSummary
      tags:
        - Bills
      summary: Bills summary
      description: |
        Returns summary and aggregate data for bills, such as totals and counts by status.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills/check-duplicate:
    get:
      operationId: checkDuplicateBill
      tags:
        - Bills
      summary: Check for duplicate bill
      description: |
        Check whether a bill already exists based on the provided query parameters. Useful for preventing duplicate bill entry.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: vendor_id
          schema:
            type: integer
          description: Vendor (company) ID to check against
        - in: query
          name: bill_number
          schema:
            type: string
          description: Bill number to check for duplicates
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills/calculate-due-date:
    post:
      operationId: calculateBillDueDate
      tags:
        - Bills
      summary: Calculate bill due date
      description: |
        Calculate the due date for a bill based on the provided payment terms and bill date.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills/from-shipments/prefill:
    get:
      operationId: prefillBillFromShipments
      tags:
        - Bills
      summary: Prefill bill from shipments
      description: |
        Get prefilled bill data based on one or more shipments. Use this to auto-populate a new bill from incoming shipment records.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: shipment_ids
          schema:
            type: string
          description: Comma-separated list of shipment IDs to prefill from
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills/allocation-inbox:
    get:
      operationId: getBillsAllocationInbox
      tags:
        - Bills
      summary: Bills allocation inbox
      description: |
        Returns a list of bills that need allocation attention, such as bills with unallocated amounts or pending cost allocations.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills/import/parse:
    post:
      operationId: parseBillImport
      tags:
        - Bills
      summary: Parse bill import
      description: |
        Parse imported bill data from an uploaded file or raw input. Returns structured bill data ready for review and creation.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /bills/bulk-reconcile:
    post:
      operationId: bulkReconcileBills
      tags:
        - Bills
      summary: Bulk reconcile bills to a purchase order
      description: |
        Link up to 100 existing bills to one purchase order, then run the same receipt auto-allocation
        as `POST /bills/{id}/auto-allocate` on each bill.

        Bills are processed independently — one bill failing does not stop the others. The response is
        `200` whenever the request body is valid, even if some (or all) bills fail; check each entry in
        `results`.

        - A bill already linked to the purchase order is treated as linked (`already_linked: true`) and
          is still allocated, so retrying the same `bill_ids` is safe.
        - A per-bill `error` with `linked: true` means the purchase-order link was saved but allocation
          failed. Retrying that bill re-runs allocation without re-linking.

        **What this call does not do**

        - It links the bill to the purchase order at the header level only. It does not set
          `purchase_order_item_id` on bill line items.
        - Auto-allocation matches a product line to a receipt line only when the bill item's
          `purchase_order_item_id` equals the receipt line's purchase order line. Lines without that id
          are counted in `skipped`. Lines are not matched by SKU.
        - The purchase order's billed quantity is driven by each bill item's `purchase_order_item_id`,
          not by the header link. Set that field with `PUT /bills/{id}` when billed quantity should move.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - purchase_order_id
                - bill_ids
              properties:
                purchase_order_id:
                  type: integer
                  description: ID of the purchase order to link every bill to. Must exist.
                  example: 12345
                bill_ids:
                  type: array
                  description: IDs of the bills to link and auto-allocate (1–100).
                  minItems: 1
                  maxItems: 100
                  items:
                    type: integer
                  example:
                    - 1
                    - 2
      responses:
        '200':
          description: Request processed. Inspect each entry in `results` for per-bill success or failure.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      purchase_order_id:
                        type: integer
                        example: 12345
                      results:
                        type: array
                        description: 'One entry per requested bill, in request order.'
                        items:
                          type: object
                          properties:
                            bill_id:
                              type: integer
                              example: 1
                            linked:
                              type: boolean
                              description: Whether the bill is linked to the purchase order after this call.
                              example: true
                            already_linked:
                              type: boolean
                              description: Present when `linked` is true. `true` if the bill was already linked before this call.
                              example: false
                            allocated:
                              type: integer
                              description: Present on success. Number of allocations created.
                              example: 3
                            skipped:
                              type: integer
                              description: Present on success. Number of bill items that could not be matched to a receipt line.
                              example: 1
                            message:
                              type: string
                              description: Present on success. Auto-allocation summary.
                              example: 'Auto-allocation complete: 3 allocation(s) created, 1 item(s) skipped.'
                            error:
                              type: string
                              description: 'Present on failure (bill not found, link rejected, or allocation failed).'
                              example: Purchase order must belong to the same vendor as the bill.
              example:
                data:
                  purchase_order_id: 12345
                  results:
                    - bill_id: 1
                      linked: true
                      already_linked: false
                      allocated: 3
                      skipped: 1
                      message: 'Auto-allocation complete: 3 allocation(s) created, 1 item(s) skipped.'
                    - bill_id: 2
                      linked: false
                      error: Purchase order must belong to the same vendor as the bill.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error — invalid body, or `purchase_order_id` does not exist'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/by-purchase-order/{id}':
    get:
      operationId: getBillsByPurchaseOrder
      tags:
        - Bills
      summary: Bills by purchase order
      description: |
        Returns all bills associated with a specific purchase order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Purchase order ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Purchase order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/by-vendor/{id}':
    get:
      operationId: getBillsByVendor
      tags:
        - Bills
      summary: Bills by vendor
      description: |
        Returns all bills for a specific vendor (company).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor (company) ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Vendor not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/link-po':
    post:
      operationId: linkBillPurchaseOrder
      tags:
        - Bills
      summary: Link a purchase order to a bill
      description: |
        Link another purchase order to a bill, for a vendor invoice that covers several POs.
        The purchase order must belong to the same vendor as the bill. The bill cannot be
        cancelled, on hold or disputed, and the PO cannot already be linked.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - purchase_order_id
              properties:
                purchase_order_id:
                  type: integer
                  description: ID of the purchase order to link. Must exist.
      responses:
        '200':
          description: 'The updated bill detail, in the same shape as `GET /bills/{id}` (returned as the top-level object, not wrapped in `data`).'
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Bill not found, or purchase order not found.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or the bill is cancelled / on hold / disputed, the PO belongs to a different vendor, or the PO is already linked.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/purchase-orders/{purchaseOrderId}':
    delete:
      operationId: unlinkBillPurchaseOrder
      tags:
        - Bills
      summary: Unlink a purchase order from a bill
      description: |
        Remove a linked purchase order from a bill. The bill cannot be cancelled or on hold.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: ID of the linked purchase order to remove
      responses:
        '200':
          description: 'The updated bill detail, in the same shape as `GET /bills/{id}` (returned as the top-level object, not wrapped in `data`).'
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: 'The bill is cancelled, or on hold / disputed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The purchase order is not linked to the bill.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/link-work-order':
    post:
      operationId: linkBillWorkOrder
      tags:
        - Bills
      summary: Link a work order to a bill
      description: |
        Link a production-run work order to a bill, for a vendor invoice that covers a
        production run. The work order must belong to the same vendor as the bill. The bill
        cannot be cancelled, on hold or disputed, and the work order cannot already be linked.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - work_order_id
              properties:
                work_order_id:
                  type: integer
                  description: ID of the work order to link. Must exist.
      responses:
        '200':
          description: 'The updated bill detail, in the same shape as `GET /bills/{id}` (returned as the top-level object, not wrapped in `data`).'
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Bill not found, or work order not found.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or the bill is cancelled / on hold / disputed, the work order belongs to a different vendor, or the work order is already linked.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/work-orders/{workOrderId}':
    delete:
      operationId: unlinkBillWorkOrder
      tags:
        - Bills
      summary: Unlink a work order from a bill
      description: |
        Remove a linked work order from a bill. The bill cannot be cancelled, on hold or
        disputed.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the linked work order to remove
      responses:
        '200':
          description: 'The updated bill detail, in the same shape as `GET /bills/{id}` (returned as the top-level object, not wrapped in `data`).'
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'The bill is cancelled / on hold / disputed, or the work order is not linked to the bill.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}':
    get:
      operationId: getBillById
      tags:
        - Bills
      summary: Single bill
      description: |
        Get details of a specific bill by ID.

        Each line item carries `unit_of_measure_id` and `unit_of_measure` (`{ "id", "name" }`). When
        the bill line has no unit of measure of its own, `unit_of_measure` falls back to the linked
        purchase-order line's ordered unit; it is `null` when neither is set.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateBill
      tags:
        - Bills
      summary: Update a bill
      description: |
        Update an existing bill by ID. Send only the fields you want to change.

        A bill that is on hold (`hold_status` of `on_hold` or `disputed`) is
        considered under review and cannot be edited until the hold is released
        via `POST /bills/{id}/unhold`; attempting to update such a bill returns
        `422`. Cancelled bills cannot be edited, and line items cannot be changed
        on a paid bill.

        Each line item's `amount` must be zero or greater, except for adjustment
        lines (`line_type` of `adjustment`), which may carry a negative amount to
        record a credit or downward correction. A negative `amount` on any other
        line type returns `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error, or the bill cannot be edited — for example it is on
            hold or disputed (`hold_status` of `on_hold` or `disputed`), it is
            cancelled, line items were changed on a paid bill, or a line item's
            `amount` is negative on a non-adjustment line (only `line_type` of
            `adjustment` may be negative).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/status':
    patch:
      operationId: updateBillStatus
      tags:
        - Bills
      summary: Update bill status
      description: |
        Update the status of an existing bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/post':
    post:
      operationId: postBill
      tags:
        - Bills
      summary: Post a bill
      description: |
        Post a bill to the connected accounting provider (e.g. QuickBooks or Xero),
        marking it as finalized and ready for payment processing.

        Only open, partially paid, or paid bills can be posted. A bill that is on
        hold (`hold_status` of `on_hold` or `disputed`) is considered under review
        and cannot be posted until the hold is released via `POST /bills/{id}/unhold`;
        attempting to post such a bill returns `422`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            The bill cannot be posted — for example it is on hold or disputed
            (`hold_status` of `on_hold` or `disputed`), or its status is not open,
            partially paid, or paid.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/reopen':
    post:
      operationId: reopenBill
      tags:
        - Bills
      summary: Reopen a bill
      description: |
        Reopen a previously posted or closed bill, returning it to an editable state.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/hold':
    post:
      operationId: holdBill
      tags:
        - Bills
      summary: Hold a bill
      description: |
        Place a bill on hold or mark it as disputed, preventing it from being
        processed for payment. A reason is required and is recorded on the bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - hold_status
                - hold_reason
              properties:
                hold_status:
                  type: string
                  enum:
                    - on_hold
                    - disputed
                  description: Whether to place the bill on hold or mark it as disputed.
                hold_reason:
                  type: string
                  maxLength: 255
                  description: Reason the bill is being held or disputed. Required.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/unhold':
    post:
      operationId: unholdBill
      tags:
        - Bills
      summary: Unhold a bill
      description: |
        Remove the hold from a bill, allowing it to be processed for payment again.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/payments':
    post:
      operationId: createBillPayment
      tags:
        - Bills
      summary: Record a bill payment
      description: |
        Record a payment against a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                amount:
                  type: number
                  description: Payment amount
                payment_date:
                  type: string
                  format: date
                  description: Date of payment
                payment_method:
                  type: string
                  description: Payment method
                reference:
                  type: string
                  description: Payment reference or check number
      responses:
        '201':
          description: Payment recorded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/payments/{paymentId}':
    delete:
      operationId: deleteBillPayment
      tags:
        - Bills
      summary: Delete a bill payment
      description: |
        Remove a payment from a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: paymentId
          required: true
          schema:
            type: integer
          description: Payment ID
      responses:
        '200':
          description: Payment deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill or payment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/payments/{paymentId}/void':
    post:
      operationId: voidBillPayment
      tags:
        - Bills
      summary: Void a bill payment
      description: |
        Void a payment on a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: paymentId
          required: true
          schema:
            type: integer
          description: Payment ID
      responses:
        '200':
          description: Payment voided
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill or payment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/payments/{paymentId}/move':
    post:
      operationId: moveBillPayment
      tags:
        - Bills
      summary: Move a bill payment
      description: |
        Move all or part of a recorded payment from one bill to another bill of the same vendor.

        A payment is a booked fact, so it is reversed rather than rewritten: the source payment is
        **voided**, any remainder is recorded back on the source bill as a new payment, and the
        moved amount is recorded on the target bill as a new payment. The new payments keep the
        original's dates, reference, notes and exchange rate. The GL and QuickBooks follow the
        normal void and record-payment paths. Both bills log a "payment moved" event.

        ## Refusals (`422`)
        - The target is the same bill (`The payment is already on this bill.`)
        - Either bill is managed by a connected bill-pay platform — move the payment in the platform
        - The payment was made in a connected bill-pay platform, or is not a manually recorded
          payment (e.g. ACH) — only manual payments can be moved
        - The payment is voided or not applied
        - The payment falls in a closed accounting period
        - The target bill belongs to a different vendor, or is in a different currency from the payment
        - The target bill is a draft, cancelled, or on hold / disputed
        - `amount` is not greater than zero, exceeds the payment amount, or exceeds the target
          bill's outstanding amount; or the target bill has no remaining balance
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: ID of the bill the payment is currently on
        - in: path
          name: paymentId
          required: true
          schema:
            type: integer
          description: ID of the payment to move
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - target_bill_id
              properties:
                target_bill_id:
                  type: integer
                  minimum: 1
                  description: Bill to move the payment to. Must belong to the same vendor and use the payment's currency.
                  example: 812
                amount:
                  type: number
                  format: float
                  minimum: 0.01
                  nullable: true
                  description: |
                    Amount to move. Defaults to the whole payment. Cannot exceed the payment amount
                    or the target bill's outstanding amount.
                  example: 250
      responses:
        '200':
          description: 'Payment moved. Returns both bills in the same shape as `GET /bills/{id}`.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  source_bill:
                    type: object
                    description: The source bill (bill detail shape)
                  target_bill:
                    type: object
                    description: The target bill (bill detail shape)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Bill, target bill, or payment not found'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error or the move was refused (see description)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/attachments':
    post:
      operationId: uploadBillAttachment
      tags:
        - Bills
      summary: Upload a bill attachment
      description: |
        Upload an attachment to a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The file to upload
      responses:
        '201':
          description: Attachment uploaded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/attachments/{attachmentId}/download':
    get:
      operationId: downloadBillAttachment
      tags:
        - Bills
      summary: Download a bill attachment
      description: |
        Download an attachment file from a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: attachmentId
          required: true
          schema:
            type: integer
          description: Attachment ID
      responses:
        '200':
          description: File download
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill or attachment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/attachments/{attachmentId}':
    delete:
      operationId: deleteBillAttachment
      tags:
        - Bills
      summary: Delete a bill attachment
      description: |
        Delete an attachment from a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: attachmentId
          required: true
          schema:
            type: integer
          description: Attachment ID
      responses:
        '200':
          description: Attachment deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill or attachment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/variance':
    get:
      operationId: getBillVariance
      tags:
        - Bills
      summary: Get bill variance
      description: |
        Returns variance data for a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Variance data
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/resolve-variance':
    post:
      operationId: resolveBillVariance
      tags:
        - Bills
      summary: Resolve bill variance
      description: |
        Resolve variance on a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Variance resolved
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/allocations':
    get:
      operationId: getBillAllocations
      tags:
        - Bills
      summary: List bill allocations
      description: |
        List allocations for a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: List of allocations
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createBillAllocation
      tags:
        - Bills
      summary: Create a bill allocation
      description: |
        Create an allocation for a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '201':
          description: Allocation created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/allocations/{allocationId}':
    delete:
      operationId: deleteBillAllocation
      tags:
        - Bills
      summary: Delete a bill allocation
      description: |
        Remove an allocation from a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: allocationId
          required: true
          schema:
            type: integer
          description: Allocation ID
      responses:
        '200':
          description: Allocation deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill or allocation not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/billable-lines':
    get:
      operationId: getBillBillableLines
      tags:
        - Bills
      summary: Get bill billable lines
      description: |
        List billable lines for a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: List of billable lines
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/candidate-lines':
    get:
      operationId: getBillCandidateLines
      tags:
        - Bills
      summary: Get bill candidate lines
      description: |
        List candidate lines for a bill.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: List of candidate lines
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/auto-allocate':
    post:
      operationId: autoAllocateBill
      tags:
        - Bills
      summary: Auto-allocate bill
      description: |
        Automatically allocate bill line items.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Bill auto-allocated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/bill-items/{billItemId}/eligible-lines':
    get:
      operationId: getBillItemEligibleLines
      tags:
        - Bills
      summary: Get eligible lines for a bill item
      description: |
        List eligible lines for a specific bill item.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: billItemId
          required: true
          schema:
            type: integer
          description: Bill Item ID
      responses:
        '200':
          description: List of eligible lines
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill or bill item not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/bill-items/{billItemId}/ai-suggestions':
    post:
      operationId: getBillItemAiSuggestions
      tags:
        - Bills
      summary: Get AI suggestions for a bill item
      description: |
        Get AI-powered allocation suggestions for a specific bill item.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: billItemId
          required: true
          schema:
            type: integer
          description: Bill Item ID
      responses:
        '200':
          description: AI suggestions
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill or bill item not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/bills/{id}/bill-items/{billItemId}/prorate-allocate':
    post:
      operationId: prorateBillItemAllocation
      tags:
        - Bills
      summary: Prorate allocation for a bill item
      description: |
        Prorate and allocate a specific bill item across eligible lines.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Bill ID
        - in: path
          name: billItemId
          required: true
          schema:
            type: integer
          description: Bill Item ID
      responses:
        '200':
          description: Allocation prorated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Bill or bill item not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/receiving-reports/{receivingReportId}/billable-lines':
    get:
      operationId: getReceivingReportBillableLines
      tags:
        - Receiving Reports
      summary: Get billable lines for a receiving report
      description: |
        Returns the billable lines for a receiving report — the lines you would turn into a
        vendor bill. A single receiving report can consolidate lines from several purchase
        orders, and those purchase orders can belong to different vendors, so `data` is a flat
        list of every billable line on the receipt. Use `vendor_groups` to split it when more
        than one vendor is involved.

        **Extra costs (freight / duty / service).** By default this endpoint also returns the
        receipt-scoped extra-cost lines (marked `receipt_scoped: true`, with a `null`
        `purchase_order_id`), so integrations bill freight and duty alongside the product lines.
        Pass `include_extra_costs=false` to omit them.

        **Multi-vendor / multi-PO receipts.** `vendor_id` and `purchase_order_id` are `null`
        when the receipt spans more than one vendor or purchase order. Use `vendor_groups` and
        `purchase_order_ids`, which carry the full breakdown.

        **Line selection.** A line is returned based on its remaining billable *amount*, not its
        remaining quantity, so a partially billed line can appear with `remaining_billable_qty`
        of `0` while still having a `remaining_billable_amount`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: receivingReportId
          required: true
          schema:
            type: integer
          description: Receiving report ID
        - in: query
          name: include_extra_costs
          required: false
          schema:
            type: boolean
            default: true
          description: |
            Whether to include the receipt-scoped extra-cost lines (freight / duty / service) in `data`. Defaults to `true` on this endpoint. Set to `false` to return only the product lines.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: |
                      Flat list of billable lines. Product lines carry `line_type: "product"`; extra-cost lines carry a classified `line_type` (freight / duty / service / other) and `receipt_scoped: true`.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        line_type:
                          type: string
                          description: |
                            `product` for received product lines; for extra-cost lines the resolved cost type — one of `freight`, `duty`, `service`, `other`.
                        cost_type:
                          type: string
                          nullable: true
                          description: |
                            Present on extra-cost lines only; mirrors the resolved `line_type`.
                        purchase_order_id:
                          type: integer
                          nullable: true
                          description: |
                            The purchase order this line belongs to. Always `null` for extra-cost lines, which hang off the receipt rather than a PO.
                        purchase_order_rfq_id:
                          type: integer
                          nullable: true
                        vendor_id:
                          type: integer
                          nullable: true
                        receiving_report_id:
                          type: integer
                        receipt_scoped:
                          type: boolean
                          description: |
                            `true` on extra-cost lines (freight / duty / service), which are scoped to the whole receipt rather than a single PO line.
                        sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        description:
                          type: string
                          nullable: true
                          description: Present on extra-cost lines (the extra cost's name).
                        received_qty:
                          type: number
                        unit_price:
                          type: number
                        billable_unit_price:
                          type: number
                          description: Present on extra-cost lines.
                        line_total:
                          type: number
                        already_billed_amount:
                          type: number
                        billable_amount:
                          type: number
                        billed_qty:
                          type: number
                        billed_amount:
                          type: number
                        remaining_billable_qty:
                          type: number
                        remaining_billable_amount:
                          type: number
                  vendor_id:
                    type: integer
                    nullable: true
                    description: |
                      The single vendor for the receipt, or `null` when the receipt spans more than one vendor. Use `vendor_groups` in that case.
                  vendor_groups:
                    type: array
                    description: Per-vendor breakdown of the billable lines on the receipt.
                    items:
                      type: object
                      properties:
                        vendor_id:
                          type: integer
                          nullable: true
                        vendor_name:
                          type: string
                          nullable: true
                        currency_code:
                          type: string
                          nullable: true
                        purchase_order_ids:
                          type: array
                          items:
                            type: integer
                        line_count:
                          type: integer
                        billable_total:
                          type: number
                  is_multi_vendor:
                    type: boolean
                    description: |
                      `true` when the receipt has billable lines from more than one vendor.
                  purchase_order_id:
                    type: integer
                    nullable: true
                    description: |
                      The single purchase order for the receipt, or `null` when the receipt consolidates more than one PO. Use `purchase_order_ids` in that case.
                  purchase_order_ids:
                    type: array
                    items:
                      type: integer
                    description: All purchase orders contributing lines to this receipt.
                  extra_costs_included:
                    type: boolean
                    description: |
                      Whether extra-cost lines were included in `data` (reflects the `include_extra_costs` query parameter).
                  extra_cost_summary:
                    type: object
                    description: Summary of the receipt-scoped extra-cost lines.
                    properties:
                      count:
                        type: integer
                      billable_total:
                        type: number
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/billable-lines':
    get:
      operationId: getPurchaseOrderBillableLines
      tags:
        - Purchase Orders
      summary: Get billable lines for a purchase order
      description: |
        Returns billable lines for a specific purchase order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/shipments/{shipmentId}/billable-lines':
    get:
      operationId: getShipmentBillableLines
      tags:
        - Bills
      summary: Get billable lines for a shipment
      description: |
        Returns billable lines for a specific shipment.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: shipmentId
          required: true
          schema:
            type: integer
          description: Shipment ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /assembly-orders:
    get:
      operationId: getAssemblyOrders
      tags:
        - Assembly Orders
      summary: Assembly orders
      description: |
        Get a paginated list of assembly orders, newest first. Disassembly orders are not included.

        Filters use the standard [filter syntax](/filters), for example `status=issued`,
        `created_at[gte]=2026-08-01`, or `end_time[gte]=...&end_time[lte]=...`.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 15
            minimum: 1
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 100
          description: Page size used when `per_page` is omitted.
        - in: query
          name: status
          schema:
            type: string
            enum:
              - draft
              - issued
              - in_progress
              - paused
              - completed
              - rolled_back
          description: 'Filter by status. Supports `status[in]=issued,in_progress`.'
        - in: query
          name: bom_id
          schema:
            type: integer
          description: Filter by BOM ID
        - in: query
          name: rfq_id
          schema:
            type: integer
          description: Filter by the ID of the product being assembled
        - in: query
          name: warehouse_id
          schema:
            type: integer
          description: Filter by warehouse ID
        - in: query
          name: 'created_at[gte]'
          schema:
            type: string
            format: date
          description: Created on or after this date
        - in: query
          name: 'created_at[lte]'
          schema:
            type: string
            format: date
          description: Created on or before this date
        - in: query
          name: 'end_time[gte]'
          schema:
            type: string
            format: date-time
          description: End time on or after this value
        - in: query
          name: 'end_time[lte]'
          schema:
            type: string
            format: date-time
          description: End time on or before this value
      responses:
        '200':
          description: Paginated list of assembly orders
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: An assembly order. Disassembly orders are not returned by these endpoints.
                      properties:
                        id:
                          type: integer
                        status:
                          type: string
                          enum:
                            - draft
                            - issued
                            - in_progress
                            - paused
                            - completed
                            - rolled_back
                        planned_quantity:
                          type: number
                          description: Quantity planned to assemble.
                        actual_quantity:
                          type: number
                          description: Quantity actually assembled.
                        start_time:
                          type: string
                          format: date-time
                          nullable: true
                          description: Scheduled or actual start. Assembly orders have no separate due date; `start_time` and `end_time` are the schedule fields.
                        end_time:
                          type: string
                          format: date-time
                          nullable: true
                        bom_id:
                          type: integer
                          nullable: true
                          description: BOM used for the assembly.
                        rfq_id:
                          type: integer
                          description: ID of the product being assembled.
                        warehouse_id:
                          type: integer
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                          description: Name of the product being assembled.
                        sku:
                          type: string
                          nullable: true
                          description: SKU of the product being assembled.
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: A filter value is not recognized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createAssemblyOrder
      tags:
        - Assembly Orders
      summary: Create a draft assembly order
      description: |
        Create a **Draft** assembly order from a finished SKU and one of its BOMs, the same way
        Inventory > Assembly Orders > Create Assembly Order does. No work order is needed.

        The component lines are built server-side from the BOM for the requested quantity, picking
        stocked bins in the warehouse's group (Auto Split). A draft moves no stock; complete it in the app.

        The request is refused with **422** in the same cases the screen refuses it:
        - a lot-tracked finished SKU with no `lot_id` (when the tenant requires finished-goods lots)
        - a `lot_id` that belongs to another SKU
        - a BOM that is not attached to the SKU
        - a `location_id` outside the warehouse
        - a `warehouse_group_id` that does not contain the warehouse
        - a `uom_id` that is not one of the SKU's units
        - a component with no bin (or no lot, when lot-tracked) in the warehouse

        Low component stock is not refused; the screen only warns about it.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - rfq_id
                - bom_id
                - warehouse_id
                - quantity
              properties:
                rfq_id:
                  type: integer
                  description: ID of the finished product (SKU) to assemble
                bom_id:
                  type: integer
                  description: ID of a BOM attached to the finished product
                warehouse_id:
                  type: integer
                  description: ID of the warehouse (a top-level location)
                quantity:
                  type: number
                  exclusiveMinimum: true
                  minimum: 0
                  description: Quantity to assemble. Must be greater than 0.
                location_id:
                  type: integer
                  nullable: true
                  description: 'Destination bin in the warehouse. Defaults to the product''s default bin, then the warehouse''s default receiving bin.'
                warehouse_group_id:
                  type: integer
                  nullable: true
                  description: 'Warehouse group to source components from; must contain the warehouse. Defaults to the tenant''s default warehouse group when it contains the warehouse, otherwise the warehouse''s first group.'
                uom_id:
                  type: integer
                  nullable: true
                  description: 'One of the product''s units of measure. Defaults to the product''s purchase unit, then its base unit.'
                lot_id:
                  type: integer
                  nullable: true
                  description: Finished-goods lot. Required for a lot-tracked product when the tenant requires finished-goods lots.
            example:
              rfq_id: 1201
              bom_id: 88
              warehouse_id: 3
              quantity: 50
      responses:
        '201':
          description: The created draft assembly order
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An assembly order. Disassembly orders are not returned by these endpoints.
                    properties:
                      id:
                        type: integer
                      status:
                        type: string
                        enum:
                          - draft
                          - issued
                          - in_progress
                          - paused
                          - completed
                          - rolled_back
                      planned_quantity:
                        type: number
                        description: Quantity planned to assemble.
                      actual_quantity:
                        type: number
                        description: Quantity actually assembled.
                      start_time:
                        type: string
                        format: date-time
                        nullable: true
                        description: Scheduled or actual start. Assembly orders have no separate due date; `start_time` and `end_time` are the schedule fields.
                      end_time:
                        type: string
                        format: date-time
                        nullable: true
                      bom_id:
                        type: integer
                        nullable: true
                        description: BOM used for the assembly.
                      rfq_id:
                        type: integer
                        description: ID of the product being assembled.
                      warehouse_id:
                        type: integer
                        nullable: true
                      product_name:
                        type: string
                        nullable: true
                        description: Name of the product being assembled.
                      sku:
                        type: string
                        nullable: true
                        description: SKU of the product being assembled.
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '400':
          description: A required field is missing or an ID does not exist
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Refused for a reason the Create Assembly Order screen also refuses
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/assembly-orders/{assemblyOrderId}':
    get:
      operationId: getAssemblyOrder
      tags:
        - Assembly Orders
      summary: Get an assembly order
      description: Get a single assembly order by ID. Disassembly orders return 404.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: assemblyOrderId
          required: true
          schema:
            type: integer
          description: ID of the assembly order
      responses:
        '200':
          description: The assembly order
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: An assembly order. Disassembly orders are not returned by these endpoints.
                    properties:
                      id:
                        type: integer
                      status:
                        type: string
                        enum:
                          - draft
                          - issued
                          - in_progress
                          - paused
                          - completed
                          - rolled_back
                      planned_quantity:
                        type: number
                        description: Quantity planned to assemble.
                      actual_quantity:
                        type: number
                        description: Quantity actually assembled.
                      start_time:
                        type: string
                        format: date-time
                        nullable: true
                        description: Scheduled or actual start. Assembly orders have no separate due date; `start_time` and `end_time` are the schedule fields.
                      end_time:
                        type: string
                        format: date-time
                        nullable: true
                      bom_id:
                        type: integer
                        nullable: true
                        description: BOM used for the assembly.
                      rfq_id:
                        type: integer
                        description: ID of the product being assembled.
                      warehouse_id:
                        type: integer
                        nullable: true
                      product_name:
                        type: string
                        nullable: true
                        description: Name of the product being assembled.
                      sku:
                        type: string
                        nullable: true
                        description: SKU of the product being assembled.
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Assembly order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/assembly-orders/{assemblyOrderId}/billable-lines':
    get:
      operationId: getAssemblyOrderBillableLines
      tags:
        - Bills
      summary: Get billable lines for an assembly order
      description: |
        Returns the assembly order component lines and extra costs (manufacturing
        service fees) that still have a remaining billable amount. Use this to
        pre-fill a bill form when creating a bill from an assembly order.

        Each line's `billable_amount` is the line total less any amount already
        billed through existing allocations; fully-billed lines are omitted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: assemblyOrderId
          required: true
          schema:
            type: integer
          description: Assembly order ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Identifier of the source line (assembly order line or extra cost).
                        line_type:
                          type: string
                          description: |
                            Line classification — `product` for assembly order component lines,
                            `other` for extra costs (manufacturing service fees).
                          enum:
                            - product
                            - other
                        assembly_order_id:
                          type: integer
                          description: Assembly order the line originates from.
                        assembly_order_line_id:
                          type: integer
                          nullable: true
                          description: Present on component (`product`) lines.
                        assembly_order_extra_cost_id:
                          type: integer
                          nullable: true
                          description: Present on extra-cost (`other`) lines.
                        rfq_id:
                          type: integer
                          nullable: true
                        sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        description:
                          type: string
                        planned_qty:
                          type: number
                        actual_qty:
                          type: number
                        unit_price:
                          type: number
                        line_total:
                          type: number
                        already_billed_amount:
                          type: number
                          description: Amount already billed against this line through prior allocations.
                        billable_amount:
                          type: number
                          description: Remaining billable amount (line total less already billed).
                        uom_name:
                          type: string
                          nullable: true
                          description: Unit of measure name; present on component lines.
                  vendor_id:
                    type: integer
                    nullable: true
                    description: 'Vendor resolved from the linked work order, if any.'
                  assembly_order_id:
                    type: integer
                    description: The assembly order these lines belong to.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/assembly-orders/{assemblyOrderId}/ledger-correction':
    parameters:
      - in: path
        name: assemblyOrderId
        required: true
        schema:
          type: integer
        description: ID of a completed assembly or disassembly order.
    get:
      operationId: previewAssemblyOrderLedgerCorrection
      tags:
        - Assembly Orders
      summary: Preview an assembly order ledger correction
      description: |
        Previews correcting the produced and component quantities of a **completed**
        assembly or disassembly order, without writing anything. Takes the same
        fields as `POST /assembly-orders/{assemblyOrderId}/ledger-correction` (except
        `reason`) as query parameters, for example:
        `?produced_quantity=12&lines[0][order_line_id]=88&lines[0][quantity]=24&balancing_entry[date]=2026-10-19`.

        The same eligibility rules as the save endpoint apply.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: produced_quantity
          required: false
          schema:
            type: number
            exclusiveMinimum: true
            minimum: 0
          description: New actual quantity of the order's own SKU. Greater than zero.
        - in: query
          name: lines
          required: false
          style: deepObject
          explode: true
          schema:
            type: array
            items:
              type: object
              properties:
                order_line_id:
                  type: integer
                quantity:
                  type: number
          description: |
            Component/output lines to change, as `lines[0][order_line_id]=88&lines[0][quantity]=24`.
        - in: query
          name: 'balancing_entry[date]'
          required: false
          schema:
            type: string
            format: date
          description: |
            Optional balancing adjustment date. Not in the future. When omitted (and
            `allow_shelf_change` is not true) the balancing entry is dated today.
        - in: query
          name: allow_shelf_change
          required: false
          schema:
            type: boolean
            default: false
          description: |
            `true` skips the balancing adjustment so today's on-hand moves by each
            change. Rejected (422) when later inventory movements exist on an
            affected stock.
      responses:
        '200':
          description: Preview of the correction
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  data:
                    type: object
                    description: |
                      Result of a ledger correction on a completed assembly or disassembly order.
                      The preview omits `correction_ids`, `adjustment_id`, `rematerialized_log_ids`
                      and `balance_warnings`.
                    properties:
                      order_id:
                        type: integer
                        example: 500
                      type:
                        type: string
                        description: Order type.
                        enum:
                          - assembly
                          - disassembly
                        example: assembly
                      rows:
                        type: array
                        description: One row per changed leg.
                        items:
                          type: object
                          properties:
                            order_line_id:
                              type: integer
                              nullable: true
                              description: 'Order line ID, or `null` for the order''s own SKU.'
                              example: 88
                            sku:
                              type: string
                              example: GASKET-02
                            role:
                              type: string
                              enum:
                                - produced
                                - consumed
                              description: |
                                `produced` when the leg adds stock (the finished good on an assembly,
                                the outputs on a disassembly); `consumed` when it removes stock.
                            old_quantity:
                              type: number
                              example: 2
                            new_quantity:
                              type: number
                              example: 24
                            onhand_delta:
                              type: number
                              description: Signed change to on-hand.
                              example: -22
                            onhand_after:
                              type: number
                              description: |
                                Today's on-hand after every change on that stock. With a balancing
                                entry (the default) this equals the current on-hand; with
                                `allow_shelf_change` it moves by the net change. A negative value
                                is allowed.
                              example: 78
                            later_count_warning:
                              type: boolean
                              description: |
                                A cycle count, adjustment entry or manual recount was posted on this
                                stock after the order. That count may already have absorbed the
                                difference, so consider a balancing entry. A warning, not a block.
                            later_count_transaction:
                              type: string
                              nullable: true
                              example: CYCLE COUNT
                            later_count_date:
                              type: string
                              format: date
                              nullable: true
                              example: '2026-10-02'
                      balancing_entry:
                        type: object
                        nullable: true
                        description: |
                          The balancing adjustment that keeps today's on-hand unchanged (dated
                          `balancing_entry.date`, or today when omitted). `null` only when
                          `allow_shelf_change` was true.
                        properties:
                          date:
                            type: string
                            format: date
                            example: '2026-10-19'
                          lines:
                            type: array
                            items:
                              type: object
                              properties:
                                sku:
                                  type: string
                                  example: GASKET-02
                                quantity:
                                  type: number
                                  description: Adjustment quantity (the opposite of the net change).
                                  example: 22
                                onhand_after:
                                  type: number
                                  example: 100
                      requires_full_core_rebuild:
                        type: boolean
                        description: Always `false`; rewritten quantity logs are rematerialized into Core immediately.
                        example: false
                      message:
                        type: string
                        example: Rewritten quantity logs were rematerialized into Core where Core tables exist.
                      correction_ids:
                        type: array
                        description: Save only. IDs of the correction records written.
                        items:
                          type: integer
                        example:
                          - 41
                      rematerialized_log_ids:
                        type: array
                        description: |
                          Save only. IDs of the rewritten quantity logs whose Core inventory
                          transactions were deleted and re-ingested. Empty when the tenant has no
                          Core tables.
                        items:
                          type: integer
                        example:
                          - 7781
                      adjustment_id:
                        type: integer
                        nullable: true
                        description: 'Save only. ID of the balancing adjustment entry, when one was posted.'
                        example: 9001
                      balance_warnings:
                        type: array
                        description: |
                          Save only. Stocks whose recomputed ledger balance differs from their
                          on-hand. On-hand is left unchanged in that case.
                        items:
                          type: object
                          additionalProperties: true
        '400':
          description: Request validation failure (e.g. quantity ≤ 0).
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Assembly order not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Assembly order not found.
        '422':
          description: The order cannot be corrected (see the save endpoint).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: applyAssemblyOrderLedgerCorrection
      tags:
        - Assembly Orders
      summary: Correct a completed assembly order's quantities
      description: |
        Corrects a **completed** assembly or disassembly order. You can set the
        produced quantity and each component line's actual quantity independently.
        The original quantity logs are rewritten in place, later running balances on
        each stock shift by the on-hand change, and the stock total and bin always
        move by the same delta. **By default a balancing adjustment then posts the
        opposite deltas so today's on-hand does not change** (a historical fix).
        Planned quantities are never changed. After apply, the rewritten quantity
        logs are rematerialized into Core inventory immediately; no full Core
        rebuild is needed.

        To rescale the finished good together with its planned quantity, use
        `POST /posted-quantity-corrections` instead (same balancing defaults). This
        endpoint never changes planned quantity.

        Send only the legs you want to change. A leg whose quantity equals the posted
        one is ignored; at least one leg must change. Each value is in the leg's order
        unit of measure, and the base quantity scales by the same ratio.

        **Balancing entry**

        - **Default** (no `balancing_entry.date`, `allow_shelf_change` not true): a
          balancing adjustment is posted **today** with the opposite of each stock's
          net change, so today's on-hand does not move.
        - **With `balancing_entry.date`**: the balancing adjustment is posted on that
          date instead (not in the future; a back-dated entry is dated at the start of
          that day).
        - **`allow_shelf_change: true`**: no balancing adjustment is posted and
          today's on-hand moves by each change. Use this only when the shelf really
          holds the corrected amount. Rejected (422) when a later shipment, location
          transfer, transfer order, fulfillment order, stock pull, cycle count,
          adjustment or recount already exists on an affected stock.

        The adjustment's remarks reference the order and the reason; running balances
        for those stocks are recomputed in date order from the earlier of the order's
        log and the adjustment.

        **Rejected (422) when** the order is not completed or not an
        assembly/disassembly order, a line id is not on this order, nothing changes,
        a changed leg does not have exactly one posted on-hand log, the balancing
        date is in the future, `allow_shelf_change` is true but later movements exist
        on an affected stock, or the order's completion date or the balancing date is
        in a closed period.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - reason
              properties:
                reason:
                  type: string
                  maxLength: 500
                  example: 'Counted 24 gaskets used, not 2'
                produced_quantity:
                  type: number
                  nullable: true
                  exclusiveMinimum: true
                  minimum: 0
                  description: |
                    New actual quantity of the order's own SKU (the finished good on an
                    assembly, the parent on a disassembly). Greater than zero.
                  example: 12
                lines:
                  type: array
                  nullable: true
                  items:
                    type: object
                    required:
                      - order_line_id
                      - quantity
                    properties:
                      order_line_id:
                        type: integer
                        description: A line on this order.
                        example: 88
                      quantity:
                        type: number
                        exclusiveMinimum: true
                        minimum: 0
                        description: New actual quantity of that line. Greater than zero.
                        example: 24
                balancing_entry:
                  type: object
                  nullable: true
                  properties:
                    date:
                      type: string
                      format: date
                      nullable: true
                      description: |
                        Date of the balancing adjustment. Not in the future. When
                        omitted (and `allow_shelf_change` is not true) the balancing
                        entry is dated today.
                      example: '2026-10-19'
                allow_shelf_change:
                  type: boolean
                  default: false
                  description: |
                    `true` skips the balancing adjustment so today's on-hand moves by
                    each change. Rejected (422) when later inventory movements exist
                    on an affected stock.
      responses:
        '200':
          description: Correction applied
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Order quantities corrected. Rewritten quantity logs were rematerialized into Core where Core tables exist.
                  data:
                    type: object
                    description: |
                      Result of a ledger correction on a completed assembly or disassembly order.
                      The preview omits `correction_ids`, `adjustment_id`, `rematerialized_log_ids`
                      and `balance_warnings`.
                    properties:
                      order_id:
                        type: integer
                        example: 500
                      type:
                        type: string
                        description: Order type.
                        enum:
                          - assembly
                          - disassembly
                        example: assembly
                      rows:
                        type: array
                        description: One row per changed leg.
                        items:
                          type: object
                          properties:
                            order_line_id:
                              type: integer
                              nullable: true
                              description: 'Order line ID, or `null` for the order''s own SKU.'
                              example: 88
                            sku:
                              type: string
                              example: GASKET-02
                            role:
                              type: string
                              enum:
                                - produced
                                - consumed
                              description: |
                                `produced` when the leg adds stock (the finished good on an assembly,
                                the outputs on a disassembly); `consumed` when it removes stock.
                            old_quantity:
                              type: number
                              example: 2
                            new_quantity:
                              type: number
                              example: 24
                            onhand_delta:
                              type: number
                              description: Signed change to on-hand.
                              example: -22
                            onhand_after:
                              type: number
                              description: |
                                Today's on-hand after every change on that stock. With a balancing
                                entry (the default) this equals the current on-hand; with
                                `allow_shelf_change` it moves by the net change. A negative value
                                is allowed.
                              example: 78
                            later_count_warning:
                              type: boolean
                              description: |
                                A cycle count, adjustment entry or manual recount was posted on this
                                stock after the order. That count may already have absorbed the
                                difference, so consider a balancing entry. A warning, not a block.
                            later_count_transaction:
                              type: string
                              nullable: true
                              example: CYCLE COUNT
                            later_count_date:
                              type: string
                              format: date
                              nullable: true
                              example: '2026-10-02'
                      balancing_entry:
                        type: object
                        nullable: true
                        description: |
                          The balancing adjustment that keeps today's on-hand unchanged (dated
                          `balancing_entry.date`, or today when omitted). `null` only when
                          `allow_shelf_change` was true.
                        properties:
                          date:
                            type: string
                            format: date
                            example: '2026-10-19'
                          lines:
                            type: array
                            items:
                              type: object
                              properties:
                                sku:
                                  type: string
                                  example: GASKET-02
                                quantity:
                                  type: number
                                  description: Adjustment quantity (the opposite of the net change).
                                  example: 22
                                onhand_after:
                                  type: number
                                  example: 100
                      requires_full_core_rebuild:
                        type: boolean
                        description: Always `false`; rewritten quantity logs are rematerialized into Core immediately.
                        example: false
                      message:
                        type: string
                        example: Rewritten quantity logs were rematerialized into Core where Core tables exist.
                      correction_ids:
                        type: array
                        description: Save only. IDs of the correction records written.
                        items:
                          type: integer
                        example:
                          - 41
                      rematerialized_log_ids:
                        type: array
                        description: |
                          Save only. IDs of the rewritten quantity logs whose Core inventory
                          transactions were deleted and re-ingested. Empty when the tenant has no
                          Core tables.
                        items:
                          type: integer
                        example:
                          - 7781
                      adjustment_id:
                        type: integer
                        nullable: true
                        description: 'Save only. ID of the balancing adjustment entry, when one was posted.'
                        example: 9001
                      balance_warnings:
                        type: array
                        description: |
                          Save only. Stocks whose recomputed ledger balance differs from their
                          on-hand. On-hand is left unchanged in that case.
                        items:
                          type: object
                          additionalProperties: true
        '400':
          description: 'Request validation failure (missing `reason`, quantity ≤ 0).'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Assembly order not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Assembly order not found.
        '422':
          description: The order cannot be corrected.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /posted-quantity-corrections/preview:
    get:
      operationId: previewPostedQuantityCorrection
      tags:
        - Assembly Orders
      summary: Preview a posted quantity correction
      description: |
        Previews rewriting the posted finished-good quantity of one completed
        historical transaction, without writing anything. Returns the same shape as
        `POST /posted-quantity-corrections`, minus `correction_id`.

        Supported `transaction_type` values:

        | `transaction_type` | `transaction_id` |
        | --- | --- |
        | `assembly_order` | Assembly order ID |
        | `disassembly_order` | Disassembly order ID |

        The same eligibility and balancing rules as the save endpoint apply
        (completed order, exactly one finished-good on-hand log, new quantity differs
        from the posted quantity, `transaction_type` matches the order's actual type).
        By default the preview includes the `balancing_entry` that would be posted so
        today's on-hand does not move; pass `allow_shelf_change=true` to preview the
        shelf absorbing the delta instead. See `POST /posted-quantity-corrections`.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: transaction_type
          required: true
          schema:
            type: string
            enum:
              - assembly_order
              - disassembly_order
          description: Type of transaction to correct.
        - in: query
          name: transaction_id
          required: true
          schema:
            type: integer
            minimum: 1
          description: ID of the transaction (assembly or disassembly order ID).
        - in: query
          name: quantity
          required: true
          schema:
            type: number
            exclusiveMinimum: true
            minimum: 0
          description: New finished-good quantity. Must be greater than zero.
        - in: query
          name: 'balancing_entry[date]'
          required: false
          schema:
            type: string
            format: date
          description: |
            Date of the balancing adjustment. Not in the future. When omitted (and
            `allow_shelf_change` is not true) the balancing entry is dated today.
        - in: query
          name: allow_shelf_change
          required: false
          schema:
            type: boolean
            default: false
          description: |
            `true` skips the balancing adjustment so today's on-hand moves by
            `onhand_delta`. Rejected (422) when a later shipment, transfer, count or
            adjustment already exists on the finished-good stock.
      responses:
        '200':
          description: Preview of the correction
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Posted quantity correction preview.
                  data:
                    type: object
                    description: Result of a posted-quantity correction (or its preview).
                    properties:
                      transaction_type:
                        type: string
                        enum:
                          - assembly_order
                          - disassembly_order
                        description: The transaction type that was corrected.
                      transaction_id:
                        type: integer
                        description: ID of the corrected transaction (assembly or disassembly order ID).
                      sku:
                        type: string
                        description: Internal SKU of the finished good.
                      old_quantity:
                        type: number
                        description: Finished-good quantity as originally posted.
                      new_quantity:
                        type: number
                        description: Corrected finished-good quantity.
                      onhand_delta:
                        type: number
                        description: |
                          Signed change to on-hand quantity (in base units). For an assembly order
                          (adds stock) this is new minus old; for a disassembly order (removes
                          stock) it is old minus new, so reducing a removal puts quantity back on hand.
                      message:
                        type: string
                        example: Rewritten quantity logs were rematerialized into Core where Core tables exist.
                      correction_id:
                        type: integer
                        nullable: true
                        description: ID of the stored correction record. `null` on the preview.
                      adjustment_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the balancing adjustment entry posted with the correction. `null`
                          on the preview, and `null` when `allow_shelf_change` was true.
                      balancing_entry:
                        type: object
                        nullable: true
                        description: |
                          The balancing adjustment (posted, or on the preview, to be posted) that
                          keeps today's on-hand unchanged. `null` only when `allow_shelf_change`
                          was true.
                        properties:
                          date:
                            type: string
                            format: date
                            example: '2026-10-19'
                          lines:
                            type: array
                            items:
                              type: object
                              properties:
                                sku:
                                  type: string
                                quantity:
                                  type: number
                                  description: Adjustment quantity (the opposite of `onhand_delta`).
                                onhand_after:
                                  type: number
                                  description: Today's on-hand after the correction and the balancing entry.
                      requires_full_core_rebuild:
                        type: boolean
                        description: Always `false`; the rewritten quantity log is rematerialized into Core immediately.
                        example: false
        '400':
          description: |
            Validation failure (`{ "error": "..." }`, e.g. unknown `transaction_type`)
            or the order was not found / `transaction_type` does not match the order
            (`{ "message": "..." }`).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            The order cannot be corrected (`{ "message": "..." }`): not completed,
            quantity unchanged, not exactly one finished-good on-hand log, balancing
            date in the future, `allow_shelf_change` with later movements on the stock,
            or the completion/balancing date is in a closed period.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /posted-quantity-corrections:
    post:
      operationId: createPostedQuantityCorrection
      tags:
        - Assembly Orders
      summary: Correct a posted quantity
      description: |
        Rewrites the posted finished-good quantity of one completed historical
        transaction in place, scales the order's planned quantity by the same ratio,
        and **by default posts a balancing adjustment so today's on-hand does not
        move** (a historical fix). The rewritten quantity log is rematerialized into
        Core inventory immediately; no full Core rebuild is needed.

        Supported `transaction_type` values:

        | `transaction_type` | `transaction_id` |
        | --- | --- |
        | `assembly_order` | Assembly order ID |
        | `disassembly_order` | Disassembly order ID |

        What changes:
        - The order's planned and actual quantities are scaled to the new quantity.
        - The finished-good on-hand quantity log is rewritten, and running balances
          of later on-hand logs for that stock are shifted by `onhand_delta`.
        - Finished-good on-hand (and the matching stock location / lot, if any) moves
          by `onhand_delta`, then (by default) a balancing adjustment entry with the
          opposite quantity is posted so today's on-hand ends where it started. Its
          ID is returned as `adjustment_id` and its lines as `balancing_entry`.
        - Component lines and their quantity logs stay as posted. Use
          `POST /assembly-orders/{assemblyOrderId}/ledger-correction` to change
          consumed quantities.
        - A correction record (with `reason`) is stored and its ID returned as `correction_id`.

        **Balancing entry**

        - **Default** (no `balancing_entry.date`, `allow_shelf_change` not true): the
          balancing adjustment is posted **today**, so today's on-hand does not move.
        - **With `balancing_entry.date`**: the balancing adjustment is posted on that
          date (not in the future; a back-dated entry is dated at the start of that day).
        - **`allow_shelf_change: true`**: no balancing adjustment is posted and today's
          on-hand moves by `onhand_delta`. Rejected (422) when a later shipment,
          transfer, cycle count, adjustment or stock pull already exists on the
          finished-good stock.

        Allowed only when the order is completed, has exactly one finished-good
        on-hand log, the new quantity differs from the posted quantity, and
        `transaction_type` matches the order's actual type. Use
        `GET /posted-quantity-corrections/preview` to check the result first.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - transaction_type
                - transaction_id
                - quantity
                - reason
              properties:
                transaction_type:
                  type: string
                  enum:
                    - assembly_order
                    - disassembly_order
                  description: Type of transaction to correct.
                transaction_id:
                  type: integer
                  minimum: 1
                  description: ID of the transaction (assembly or disassembly order ID).
                quantity:
                  type: number
                  exclusiveMinimum: true
                  minimum: 0
                  description: New finished-good quantity. Must be greater than zero.
                reason:
                  type: string
                  maxLength: 500
                  description: Why the posted quantity is being corrected. Stored with the correction record.
                balancing_entry:
                  type: object
                  nullable: true
                  properties:
                    date:
                      type: string
                      format: date
                      nullable: true
                      description: |
                        Date of the balancing adjustment. Not in the future. When
                        omitted (and `allow_shelf_change` is not true) the balancing
                        entry is dated today.
                      example: '2026-10-19'
                allow_shelf_change:
                  type: boolean
                  default: false
                  description: |
                    `true` skips the balancing adjustment so today's on-hand moves by
                    `onhand_delta`. Rejected (422) when a later shipment, transfer,
                    count or adjustment already exists on the finished-good stock.
            example:
              transaction_type: assembly_order
              transaction_id: 1616
              quantity: 75.2
              reason: Finished good was posted at the component quantity.
              balancing_entry:
                date: '2026-10-19'
      responses:
        '200':
          description: Correction saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Posted quantity corrected. Rewritten quantity logs were rematerialized into Core where Core tables exist.
                  data:
                    type: object
                    description: Result of a posted-quantity correction (or its preview).
                    properties:
                      transaction_type:
                        type: string
                        enum:
                          - assembly_order
                          - disassembly_order
                        description: The transaction type that was corrected.
                      transaction_id:
                        type: integer
                        description: ID of the corrected transaction (assembly or disassembly order ID).
                      sku:
                        type: string
                        description: Internal SKU of the finished good.
                      old_quantity:
                        type: number
                        description: Finished-good quantity as originally posted.
                      new_quantity:
                        type: number
                        description: Corrected finished-good quantity.
                      onhand_delta:
                        type: number
                        description: |
                          Signed change to on-hand quantity (in base units). For an assembly order
                          (adds stock) this is new minus old; for a disassembly order (removes
                          stock) it is old minus new, so reducing a removal puts quantity back on hand.
                      message:
                        type: string
                        example: Rewritten quantity logs were rematerialized into Core where Core tables exist.
                      correction_id:
                        type: integer
                        nullable: true
                        description: ID of the stored correction record. `null` on the preview.
                      adjustment_id:
                        type: integer
                        nullable: true
                        description: |
                          ID of the balancing adjustment entry posted with the correction. `null`
                          on the preview, and `null` when `allow_shelf_change` was true.
                      balancing_entry:
                        type: object
                        nullable: true
                        description: |
                          The balancing adjustment (posted, or on the preview, to be posted) that
                          keeps today's on-hand unchanged. `null` only when `allow_shelf_change`
                          was true.
                        properties:
                          date:
                            type: string
                            format: date
                            example: '2026-10-19'
                          lines:
                            type: array
                            items:
                              type: object
                              properties:
                                sku:
                                  type: string
                                quantity:
                                  type: number
                                  description: Adjustment quantity (the opposite of `onhand_delta`).
                                onhand_after:
                                  type: number
                                  description: Today's on-hand after the correction and the balancing entry.
                      requires_full_core_rebuild:
                        type: boolean
                        description: Always `false`; the rewritten quantity log is rematerialized into Core immediately.
                        example: false
              example:
                message: Posted quantity corrected. Rewritten quantity logs were rematerialized into Core where Core tables exist.
                data:
                  transaction_type: assembly_order
                  transaction_id: 1616
                  sku: SKU
                  old_quantity: 1184
                  new_quantity: 75.2
                  onhand_delta: -1108.8
                  message: Rewritten quantity logs were rematerialized into Core where Core tables exist.
                  correction_id: 1
                  adjustment_id: 9001
                  balancing_entry:
                    date: '2026-10-19'
                    lines:
                      - sku: SKU
                        quantity: 1108.8
                        onhand_after: 2000
                  requires_full_core_rebuild: false
        '400':
          description: |
            Validation failure (`{ "error": "..." }`, e.g. missing `reason` or unknown
            `transaction_type`), or the order was not found / `transaction_type` does
            not match the order / the posted actual quantity is zero
            (`{ "message": "..." }`).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            The order cannot be corrected (`{ "message": "..." }`): not completed,
            quantity unchanged, not exactly one finished-good on-hand log, balancing
            date in the future, `allow_shelf_change` with later movements on the stock,
            or the completion/balancing date is in a closed period.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/billable-lines':
    get:
      operationId: getWorkOrderBillableLines
      tags:
        - Bills
      summary: Get billable lines for a work order
      description: |
        Returns the billable lines aggregated from every assembly order linked to
        the work order — component lines and extra costs (manufacturing service
        fees) that still have a remaining billable amount. Use this to pre-fill a
        bill form when creating a bill from a work order.

        Work orders are the parent entity (like purchase orders); assembly orders
        are the batches (like shipments). Each line's `billable_amount` is the line
        total less any amount already billed through existing allocations;
        fully-billed lines are omitted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: Work order ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Identifier of the source line (assembly order line or extra cost).
                        line_type:
                          type: string
                          description: |
                            Line classification — `product` for assembly order component lines,
                            `other` for extra costs (manufacturing service fees).
                          enum:
                            - product
                            - other
                        assembly_order_id:
                          type: integer
                          description: Assembly order the line originates from.
                        assembly_order_line_id:
                          type: integer
                          nullable: true
                          description: Present on component (`product`) lines.
                        assembly_order_extra_cost_id:
                          type: integer
                          nullable: true
                          description: Present on extra-cost (`other`) lines.
                        rfq_id:
                          type: integer
                          nullable: true
                        sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        description:
                          type: string
                        planned_qty:
                          type: number
                        actual_qty:
                          type: number
                        unit_price:
                          type: number
                        line_total:
                          type: number
                        already_billed_amount:
                          type: number
                          description: Amount already billed against this line through prior allocations.
                        billable_amount:
                          type: number
                          description: Remaining billable amount (line total less already billed).
                        uom_name:
                          type: string
                          nullable: true
                          description: Unit of measure name; present on component lines.
                  vendor_id:
                    type: integer
                    nullable: true
                    description: 'Vendor associated with the work order, if any.'
                  work_order_id:
                    type: integer
                    description: The work order these lines belong to.
                  work_order_number:
                    type: string
                    nullable: true
                    description: Human-readable work order number.
                  assembly_orders:
                    type: array
                    description: The assembly orders linked to this work order.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        status:
                          type: string
                          nullable: true
                        planned_quantity:
                          type: number
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/billable-lines':
    get:
      operationId: getProductionBatchBillableLines
      tags:
        - Bills
      summary: Get billable lines for a production batch
      description: |
        Returns the billable lines aggregated from every work order in the
        production batch (production run), which in turn come from each work
        order's linked assembly orders — component lines and extra costs
        (manufacturing service fees) that still have a remaining billable amount.
        Use this to pre-fill a bill form when creating a bill from a production
        run.

        Production batches are the top-level entity that groups work orders
        (`Production Batch → Work Order[] → Assembly Order[]`). Each line's
        `billable_amount` is the line total less any amount already billed through
        existing allocations; fully-billed lines are omitted. Assembly orders that
        appear under more than one work order are de-duplicated.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: Production batch ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Identifier of the source line (assembly order line or extra cost).
                        line_type:
                          type: string
                          description: |
                            Line classification — `product` for assembly order component lines,
                            `other` for extra costs (manufacturing service fees).
                          enum:
                            - product
                            - other
                        assembly_order_id:
                          type: integer
                          description: Assembly order the line originates from.
                        assembly_order_line_id:
                          type: integer
                          nullable: true
                          description: Present on component (`product`) lines.
                        assembly_order_extra_cost_id:
                          type: integer
                          nullable: true
                          description: Present on extra-cost (`other`) lines.
                        rfq_id:
                          type: integer
                          nullable: true
                        sku:
                          type: string
                          nullable: true
                        product_name:
                          type: string
                          nullable: true
                        description:
                          type: string
                        planned_qty:
                          type: number
                        actual_qty:
                          type: number
                        unit_price:
                          type: number
                        line_total:
                          type: number
                        already_billed_amount:
                          type: number
                          description: Amount already billed against this line through prior allocations.
                        billable_amount:
                          type: number
                          description: Remaining billable amount (line total less already billed).
                        uom_name:
                          type: string
                          nullable: true
                          description: Unit of measure name; present on component lines.
                  vendor_id:
                    type: integer
                    nullable: true
                    description: 'Vendor associated with the production batch, if any.'
                  production_batch_id:
                    type: integer
                    description: The production batch these lines belong to.
                  production_batch_number:
                    type: string
                    nullable: true
                    description: Human-readable production batch (run) number.
                  work_orders:
                    type: array
                    description: The work orders contained in this production batch.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        work_order_number:
                          type: string
                          nullable: true
                        status:
                          type: string
                          nullable: true
                        assembly_order_count:
                          type: integer
                          description: Number of assembly orders linked to this work order.
                  assembly_orders:
                    type: array
                    description: 'The assembly orders across all work orders in this batch, de-duplicated by ID.'
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        status:
                          type: string
                          nullable: true
                        planned_quantity:
                          type: number
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/payment-obligations':
    get:
      operationId: getPurchaseOrderPaymentObligations
      tags:
        - Purchase Orders
      summary: List payment obligations for a purchase order
      description: |
        Returns a list of payment obligations for a specific purchase order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createPurchaseOrderPaymentObligation
      tags:
        - Purchase Orders
      summary: Create a payment obligation for a purchase order
      description: |
        Create a new payment obligation for a specific purchase order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '201':
          description: Payment obligation created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/purchase-orders/{purchaseOrderId}/payment-obligations/generate':
    post:
      operationId: generatePurchaseOrderPaymentObligations
      tags:
        - Purchase Orders
      summary: Generate payment obligations for a purchase order
      description: |
        Auto-generate payment obligations from purchase order terms.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: purchaseOrderId
          required: true
          schema:
            type: integer
          description: Purchase order ID
      responses:
        '200':
          description: Payment obligations generated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /payment-obligations/dashboard:
    get:
      operationId: getPaymentObligationsDashboard
      tags:
        - Payment Obligations
      summary: Get payment obligations dashboard
      description: |
        Returns dashboard summary data for payment obligations.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /payment-obligations:
    get:
      operationId: getPaymentObligations
      tags:
        - Payment Obligations
      summary: List payment obligations
      description: |
        Get a paginated list of payment obligations.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/payment-obligations/{id}':
    get:
      operationId: getPaymentObligationById
      tags:
        - Payment Obligations
      summary: Get a payment obligation
      description: |
        Get a single payment obligation by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Payment obligation ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updatePaymentObligation
      tags:
        - Payment Obligations
      summary: Update a payment obligation
      description: |
        Update an existing payment obligation.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Payment obligation ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Payment obligation updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/payment-obligations/{id}/status':
    patch:
      operationId: updatePaymentObligationStatus
      tags:
        - Payment Obligations
      summary: Update payment obligation status
      description: |
        Update the status of a payment obligation.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Payment obligation ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Status updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/payment-obligations/{id}/link-bill':
    post:
      operationId: linkBillToPaymentObligation
      tags:
        - Payment Obligations
      summary: Link a bill to a payment obligation
      description: |
        Link an existing bill to a payment obligation.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Payment obligation ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Bill linked successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/payment-obligations/{id}/bills/{billId}':
    delete:
      operationId: unlinkBillFromPaymentObligation
      tags:
        - Payment Obligations
      summary: Unlink a bill from a payment obligation
      description: |
        Remove the link between a bill and a payment obligation.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Payment obligation ID
        - in: path
          name: billId
          required: true
          schema:
            type: integer
          description: Bill ID
      responses:
        '200':
          description: Bill unlinked successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /prepayments:
    get:
      operationId: getPrepayments
      tags:
        - Prepayments
      summary: List prepayments
      description: |
        Get a paginated list of prepayments.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 15
          description: Number of items per page
        - in: query
          name: vendor_id
          schema:
            type: integer
          description: Only prepayments to this vendor (supplier) ID
        - in: query
          name: purchase_order_id
          schema:
            type: integer
          description: Only prepayments whose primary purchase order is this purchase order ID
        - in: query
          name: production_batch_id
          schema:
            type: integer
          description: |
            Only prepayments linked to any work order of this production run (production batch) ID.
            Returns no results when no prepayment has been linked to that run's work orders.
        - in: query
          name: purchase_order_shipment_id
          schema:
            type: integer
          description: Only prepayments paid for this purchase order shipment ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createPrepayment
      tags:
        - Prepayments
      summary: Create a prepayment
      description: |
        Create a new prepayment (vendor deposit) record, optionally linked to one or more
        purchase orders. A prepayment that exceeds a PO's remaining balance is accepted as-is
        (no overpayment confirmation is required through the API).

        Use `purchase_order_amounts` to split the deposit across its linked purchase orders.
        Each key must be a purchase order linked by `purchase_order_id` / `purchase_order_ids`,
        and the amounts cannot add up to more than `amount` (`422` otherwise). A linked PO left
        out of the map keeps a `null` (unsplit) share.

        Use `purchase_order_shipment_id` to record which purchase order shipment the deposit was
        paid for. It comes back as `purchase_order_shipment_id` and `purchase_order_shipment`
        (`id`, `reference_number`) on the list and create responses.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - vendor_id
                - currency_code
                - amount
                - exchange_rate
                - payment_date
              properties:
                vendor_id:
                  type: integer
                  description: Vendor (supplier) ID. Must exist.
                purchase_order_id:
                  type: integer
                  nullable: true
                  description: Home purchase order for the prepayment.
                purchase_order_ids:
                  type: array
                  nullable: true
                  items:
                    type: integer
                  description: Purchase orders to link the prepayment to.
                purchase_order_shipment_id:
                  type: integer
                  nullable: true
                  description: |
                    Purchase order shipment the deposit was paid for. Must be an existing, non-deleted
                    shipment. When `purchase_order_id` / `purchase_order_ids` is also sent, the shipment
                    must carry a line of at least one of those purchase orders
                    (`The shipment does not belong to the linked purchase order(s).`, `422`). The link is
                    informational: it does not change how the deposit is applied, synced to QuickBooks or
                    transferred.
                purchase_order_amounts:
                  type: object
                  nullable: true
                  additionalProperties:
                    type: number
                    minimum: 0
                  description: 'Optional share of the deposit per linked purchase order, keyed by purchase order ID (e.g. `{"123": 400.00}`). Every key must be a linked purchase order and the total cannot exceed `amount`.'
                  example:
                    '123': 400
                auto_apply:
                  type: boolean
                  nullable: true
                  description: Automatically apply the prepayment to matching bills.
                currency_code:
                  type: string
                  minLength: 3
                  maxLength: 3
                  description: ISO 4217 currency code.
                amount:
                  type: number
                  minimum: 0.0001
                exchange_rate:
                  type: number
                  minimum: 0
                payment_date:
                  type: string
                  format: date
                reference:
                  type: string
                  nullable: true
                  maxLength: 255
                notes:
                  type: string
                  nullable: true
                payment_method:
                  type: string
                  nullable: true
                  maxLength: 32
                  description: 'Payment method, used for QuickBooks account mapping.'
      responses:
        '201':
          description: Prepayment created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/prepayments/{id}/apply':
    post:
      operationId: applyPrepayment
      tags:
        - Prepayments
      summary: Apply a prepayment
      description: |
        Apply a prepayment to a bill or payment obligation.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Prepayment ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Prepayment applied successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/prepayments/{id}/transfer':
    post:
      operationId: transferPrepayment
      tags:
        - Prepayments
      summary: Transfer a prepayment to another purchase order
      description: |
        Move all or part of a prepayment's credit to another purchase order or production-run work
        order of the same vendor. Send exactly one target: `purchase_order_id` or `work_order_id`.

        - Omit `amount` to move everything still on the source. To another purchase order, from the
          home purchase order, the prepayment is repointed to the target (`purchase_order_id`
          changes).
        - Send a smaller `amount` to move part of it, or move any amount to a work order: the
          prepayment stays one record on its home PO and the moved slice is returned in `allocations`.
        - Send `from_work_order_id` to move credit off a production-run work order instead of off the
          home purchase order: the slices already moved onto that run, or the whole deposit when it
          was recorded straight onto that one run. A prepayment that is not on a purchase order can
          only be moved this way. Credit on a run settles no payment milestone, so it lands
          unscheduled on the target.

        A prepayment that settles a payment milestone on its PO moves onto the target's earliest
        open milestone of the same type; if the target has none, the transfer is refused (`422`).
        No over-value warning is raised for the target PO. QuickBooks is not called (the
        deposit is vendor-level and does not change).
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Prepayment ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                purchase_order_id:
                  type: integer
                  description: 'Target purchase order. Must be from the same vendor and not deleted. Required unless `work_order_id` is sent; send this or `work_order_id`, not both.'
                work_order_id:
                  type: integer
                  description: 'Target production-run work order. Must be from the same vendor and not cancelled. Required unless `purchase_order_id` is sent; send this or `purchase_order_id`, not both. Prepayments can be linked to work orders only on accounts where that is enabled; otherwise the transfer is refused (`422`).'
                amount:
                  type: number
                  nullable: true
                  exclusiveMinimum: true
                  minimum: 0
                  description: 'Amount to move. Must be more than 0 and no more than what is still on the source (the prepayment''s purchase order, or the work order named in `from_work_order_id`). Omit (or `null`) to move all of it.'
                from_work_order_id:
                  type: integer
                  nullable: true
                  description: 'Move credit off this production-run work order instead of off the prepayment''s purchase order. The run must hold slices moved onto it, or the whole deposit when it was recorded straight onto that one run.'
      responses:
        '200':
          description: 'The transferred prepayment (top-level object, not wrapped in `data`).'
          content:
            application/json:
              schema:
                type: object
                description: A vendor prepayment (deposit).
                properties:
                  id:
                    type: integer
                  vendor_id:
                    type: integer
                  purchase_order_id:
                    type: integer
                    nullable: true
                    description: The prepayment's home purchase order.
                  purchase_order_shipment_id:
                    type: integer
                    nullable: true
                    description: Purchase order shipment the deposit was paid for; `null` when none was given.
                  currency_code:
                    type: string
                  amount:
                    type: number
                  base_amount:
                    type: number
                  exchange_rate:
                    type: number
                  unapplied_amount:
                    type: number
                  base_unapplied_amount:
                    type: number
                  payment_date:
                    type: string
                    format: date
                    nullable: true
                  reference:
                    type: string
                    nullable: true
                  notes:
                    type: string
                    nullable: true
                  auto_apply:
                    type: boolean
                  voided_at:
                    type: string
                    format: date-time
                    nullable: true
                  void_reason:
                    type: string
                    nullable: true
                  is_voided:
                    type: boolean
                  quickbooks_sync_status:
                    type: string
                    nullable: true
                  quickbooks_detailed_message:
                    type: string
                    nullable: true
                  quickbooks_purchase_id:
                    type: string
                    nullable: true
                  quickbooks_last_synced_at:
                    type: string
                    format: date-time
                    nullable: true
                  bill_pay_owned:
                    type: boolean
                    nullable: true
                    description: Set by the list endpoint only; `null` on other responses.
                  created_at:
                    type: string
                    format: date-time
                    nullable: true
                  purchase_order_shipment:
                    type: object
                    nullable: true
                    description: 'The linked purchase order shipment, or `null` when none. Present on the list and create responses.'
                    properties:
                      id:
                        type: integer
                      reference_number:
                        type: string
                        nullable: true
                  vendor:
                    type: object
                    nullable: true
                    description: Present only when loaded.
                    properties:
                      id:
                        type: integer
                      factory_name:
                        type: string
                        nullable: true
                  applications:
                    type: array
                    description: Bill applications. Present only when loaded (list and show).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        bill_id:
                          type: integer
                        bill_number:
                          type: string
                          nullable: true
                        amount:
                          type: number
                        applied_at:
                          type: string
                          nullable: true
                        reversed_at:
                          type: string
                          nullable: true
                  purchase_orders:
                    type: array
                    description: Linked purchase orders. Present only when loaded.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        po_number:
                          type: string
                        linked_at:
                          type: string
                          nullable: true
                        linked_by:
                          type: integer
                          nullable: true
                        amount:
                          type: number
                          nullable: true
                          description: This purchase order's share of the deposit; `null` when the deposit was never split.
                  work_orders:
                    type: array
                    description: Linked production-run work orders. Present only when loaded.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        work_order_number:
                          type: string
                        production_batch_id:
                          type: integer
                          nullable: true
                        linked_at:
                          type: string
                          nullable: true
                        linked_by:
                          type: integer
                          nullable: true
                        amount:
                          type: number
                          nullable: true
                          description: This work order's share of the deposit; `null` when never split.
                  allocations:
                    type: array
                    description: Slices of the credit moved off the home purchase order by a partial transfer. `amount` minus the sum of these is what is still on `purchase_order_id`. Present only when loaded (e.g. on the transfer response).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        purchase_order_id:
                          type: integer
                          nullable: true
                        work_order_id:
                          type: integer
                          nullable: true
                        payment_obligation_id:
                          type: integer
                          nullable: true
                          description: 'The payment milestone the slice settles on its target, if any.'
                        amount:
                          type: number
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Prepayment not found, or the target purchase order, target work order or `from_work_order_id` work order not found.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: The prepayment changed while it was being transferred. Reload and try again.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (sending neither or both of `purchase_order_id` and `work_order_id`), or the transfer is refused: the prepayment is voided, not on a purchase order (and no `from_work_order_id` was sent), still applied to a live bill, or managed by a disconnected / unmapped bill-pay connection; the target PO is deleted, from another vendor, or already the prepayment''s PO; the target work order is cancelled, from another vendor, or already holds the credit being moved; the amount is out of range; or the prepayment settles a milestone and the target has no open milestone of that type.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/prepayments/{id}/applications/{applicationId}/reverse':
    post:
      operationId: reversePrepaymentApplication
      tags:
        - Prepayments
      summary: Reverse a prepayment application
      description: |
        Reverse a previously applied prepayment application.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Prepayment ID
        - in: path
          name: applicationId
          required: true
          schema:
            type: integer
          description: Application ID
      responses:
        '200':
          description: Prepayment application reversed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /vendor-credits:
    get:
      operationId: getVendorCredits
      tags:
        - Vendor Credits
      summary: List vendor credits
      description: |
        Get a paginated list of vendor credits.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createVendorCredit
      tags:
        - Vendor Credits
      summary: Create a vendor credit
      description: |
        Create a new vendor credit record.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '201':
          description: Vendor credit created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-credits/{id}':
    get:
      operationId: getVendorCreditById
      tags:
        - Vendor Credits
      summary: Get a vendor credit
      description: |
        Get a single vendor credit by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor credit ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-credits/{id}/apply':
    post:
      operationId: applyVendorCredit
      tags:
        - Vendor Credits
      summary: Apply a vendor credit
      description: |
        Apply a vendor credit to a bill or payment obligation.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor credit ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Vendor credit applied successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-credits/{id}/cancel':
    patch:
      operationId: cancelVendorCredit
      tags:
        - Vendor Credits
      summary: Cancel a vendor credit
      description: |
        Cancel an existing vendor credit.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor credit ID
      responses:
        '200':
          description: Vendor credit cancelled successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-credits/{id}/applications/{applicationId}':
    delete:
      operationId: deleteVendorCreditApplication
      tags:
        - Vendor Credits
      summary: Delete a vendor credit application
      description: |
        Delete a vendor credit application.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor credit ID
        - in: path
          name: applicationId
          required: true
          schema:
            type: integer
          description: Application ID
      responses:
        '200':
          description: Vendor credit application deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-credits/{id}/applications/{applicationId}/reverse':
    post:
      operationId: reverseVendorCreditApplication
      tags:
        - Vendor Credits
      summary: Reverse a vendor credit application
      description: |
        Reverse a previously applied vendor credit application.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor credit ID
        - in: path
          name: applicationId
          required: true
          schema:
            type: integer
          description: Application ID
      responses:
        '200':
          description: Vendor credit application reversed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /vendor-returns:
    get:
      operationId: getVendorReturns
      tags:
        - Vendor Returns
      summary: List vendor returns
      description: |
        Get a paginated list of vendor returns.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createVendorReturn
      tags:
        - Vendor Returns
      summary: Create a vendor return
      description: |
        Create a new vendor return record.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '201':
          description: Vendor return created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-returns/{id}':
    get:
      operationId: getVendorReturnById
      tags:
        - Vendor Returns
      summary: Get a vendor return
      description: |
        Get a single vendor return by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor return ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-returns/{id}/process':
    post:
      operationId: processVendorReturn
      tags:
        - Vendor Returns
      summary: Process a vendor return
      description: |
        Process a vendor return.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor return ID
      responses:
        '200':
          description: Vendor return processed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-returns/{id}/generate-credit':
    post:
      operationId: generateVendorReturnCredit
      tags:
        - Vendor Returns
      summary: Generate credit for a vendor return
      description: |
        Generate a vendor credit from a vendor return.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor return ID
      responses:
        '200':
          description: Vendor credit generated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendor-returns/{id}/cancel':
    patch:
      operationId: cancelVendorReturn
      tags:
        - Vendor Returns
      summary: Cancel a vendor return
      description: |
        Cancel an existing vendor return.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor return ID
      responses:
        '200':
          description: Vendor return cancelled successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/vendors/{id}/statement':
    get:
      operationId: getVendorStatement
      tags:
        - Vendor Credits
      summary: Get vendor statement
      description: |
        Returns a vendor statement in JSON or PDF format.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Vendor ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /currency/available:
    get:
      operationId: getAvailableCurrencies
      tags:
        - Currency
      summary: Get available currencies
      description: |
        Returns a list of available currencies.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /currency/base:
    get:
      operationId: getBaseCurrency
      tags:
        - Currency
      summary: Get base currency
      description: |
        Returns the configured base currency.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: setBaseCurrency
      tags:
        - Currency
      summary: Set base currency
      description: |
        Set the base currency for your account.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: Base currency updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /currency/rates/convert:
    get:
      operationId: convertCurrencyRate
      tags:
        - Currency
      summary: Convert currency
      description: |
        Convert an amount between currencies using current exchange rates.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: from
          schema:
            type: string
          description: Source currency code (e.g. USD)
        - in: query
          name: to
          schema:
            type: string
          description: Target currency code (e.g. EUR)
        - in: query
          name: amount
          schema:
            type: number
          description: Amount to convert
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /currency/rates:
    get:
      operationId: getCurrencyRates
      tags:
        - Currency
      summary: List currency rates
      description: |
        Get a list of currency exchange rates.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createCurrencyRate
      tags:
        - Currency
      summary: Create a currency rate
      description: |
        Create a new currency exchange rate.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
      responses:
        '201':
          description: Currency rate created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /unit-classes:
    get:
      operationId: listUnitClasses
      tags:
        - Unit Classes
      summary: List unit classes
      description: 'Paginated list of unit classes (e.g. Length, Weight, Volume).'
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: 'A grouping of related units of measure (e.g. "Length", "Weight"). Each class may have a base unit and a list of UOMs.'
                      properties:
                        id:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        status:
                          type: string
                          nullable: true
                        name:
                          type: string
                        base_class:
                          type: boolean
                          description: True for the system base class (read-only).
                        unit_of_measures:
                          type: array
                          description: Present when the relation is loaded.
                          items:
                            type: object
                            description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              status:
                                type: string
                                nullable: true
                              unit_class_id:
                                type: integer
                              unit_class:
                                type: object
                                description: Present when the relation is loaded.
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  base_class:
                                    type: boolean
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              base_unit:
                                type: boolean
                                description: True if this UOM is the base unit for its class.
                              unit_conversion_rules:
                                type: array
                                description: Present when the relation is loaded.
                                items:
                                  type: object
                                  description: |
                                    A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                    1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                  properties:
                                    id:
                                      type: integer
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    status:
                                      type: string
                                      nullable: true
                                    base_unit_of_measure_id:
                                      type: integer
                                    base_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    converted_unit_of_measure_id:
                                      type: integer
                                    converted_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    conversion_factor:
                                      type: number
                                      description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                    type:
                                      type: string
                                      enum:
                                        - SYSTEM
                                        - SKU
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Required when `type=SKU`; null when `type=SYSTEM`.
                                    product:
                                      type: object
                                      nullable: true
                                      description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                      additionalProperties: true
                                    product_alternate_skus:
                                      type: array
                                      description: Present when the relation is loaded.
                                      items:
                                        type: object
                                        additionalProperties: true
                        base_unit_of_measure:
                          description: Present when the relation is loaded.
                          nullable: true
                          allOf:
                            - type: object
                              description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                              properties:
                                id:
                                  type: integer
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                                status:
                                  type: string
                                  nullable: true
                                unit_class_id:
                                  type: integer
                                unit_class:
                                  type: object
                                  description: Present when the relation is loaded.
                                  nullable: true
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    base_class:
                                      type: boolean
                                name:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                                base_unit:
                                  type: boolean
                                  description: True if this UOM is the base unit for its class.
                                unit_conversion_rules:
                                  type: array
                                  description: Present when the relation is loaded.
                                  items:
                                    type: object
                                    description: |
                                      A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                      1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                    properties:
                                      id:
                                        type: integer
                                      created_at:
                                        type: string
                                        format: date-time
                                      updated_at:
                                        type: string
                                        format: date-time
                                      status:
                                        type: string
                                        nullable: true
                                      base_unit_of_measure_id:
                                        type: integer
                                      base_unit_of_measure:
                                        type: object
                                        description: Present when the relation is loaded.
                                        nullable: true
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          unit_class_id:
                                            type: integer
                                          base_unit:
                                            type: boolean
                                      converted_unit_of_measure_id:
                                        type: integer
                                      converted_unit_of_measure:
                                        type: object
                                        description: Present when the relation is loaded.
                                        nullable: true
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          unit_class_id:
                                            type: integer
                                          base_unit:
                                            type: boolean
                                      conversion_factor:
                                        type: number
                                        description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                      type:
                                        type: string
                                        enum:
                                          - SYSTEM
                                          - SKU
                                      product_id:
                                        type: integer
                                        nullable: true
                                        description: Required when `type=SKU`; null when `type=SYSTEM`.
                                      product:
                                        type: object
                                        nullable: true
                                        description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                        additionalProperties: true
                                      product_alternate_skus:
                                        type: array
                                        description: Present when the relation is loaded.
                                        items:
                                          type: object
                                          additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                      per_page:
                        type: integer
                      total:
                        type: integer
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createUnitClass
      tags:
        - Unit Classes
      summary: Create unit class
      description: Create a new unit class.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                base_class:
                  type: boolean
                  description: True if this should be marked as the system base class.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A grouping of related units of measure (e.g. "Length", "Weight"). Each class may have a base unit and a list of UOMs.'
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      name:
                        type: string
                      base_class:
                        type: boolean
                        description: True for the system base class (read-only).
                      unit_of_measures:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            status:
                              type: string
                              nullable: true
                            unit_class_id:
                              type: integer
                            unit_class:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                base_class:
                                  type: boolean
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            base_unit:
                              type: boolean
                              description: True if this UOM is the base unit for its class.
                            unit_conversion_rules:
                              type: array
                              description: Present when the relation is loaded.
                              items:
                                type: object
                                description: |
                                  A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                  1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                properties:
                                  id:
                                    type: integer
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  status:
                                    type: string
                                    nullable: true
                                  base_unit_of_measure_id:
                                    type: integer
                                  base_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  converted_unit_of_measure_id:
                                    type: integer
                                  converted_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  conversion_factor:
                                    type: number
                                    description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                  type:
                                    type: string
                                    enum:
                                      - SYSTEM
                                      - SKU
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Required when `type=SKU`; null when `type=SYSTEM`.
                                  product:
                                    type: object
                                    nullable: true
                                    description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                    additionalProperties: true
                                  product_alternate_skus:
                                    type: array
                                    description: Present when the relation is loaded.
                                    items:
                                      type: object
                                      additionalProperties: true
                      base_unit_of_measure:
                        description: Present when the relation is loaded.
                        nullable: true
                        allOf:
                          - type: object
                            description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              status:
                                type: string
                                nullable: true
                              unit_class_id:
                                type: integer
                              unit_class:
                                type: object
                                description: Present when the relation is loaded.
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  base_class:
                                    type: boolean
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              base_unit:
                                type: boolean
                                description: True if this UOM is the base unit for its class.
                              unit_conversion_rules:
                                type: array
                                description: Present when the relation is loaded.
                                items:
                                  type: object
                                  description: |
                                    A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                    1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                  properties:
                                    id:
                                      type: integer
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    status:
                                      type: string
                                      nullable: true
                                    base_unit_of_measure_id:
                                      type: integer
                                    base_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    converted_unit_of_measure_id:
                                      type: integer
                                    converted_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    conversion_factor:
                                      type: number
                                      description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                    type:
                                      type: string
                                      enum:
                                        - SYSTEM
                                        - SKU
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Required when `type=SKU`; null when `type=SYSTEM`.
                                    product:
                                      type: object
                                      nullable: true
                                      description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                      additionalProperties: true
                                    product_alternate_skus:
                                      type: array
                                      description: Present when the relation is loaded.
                                      items:
                                        type: object
                                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/unit-classes/{unitClassId}/default-unit-of-measure/{unitOfMeasureId}':
    post:
      operationId: setUnitClassDefaultUom
      tags:
        - Units of Measure
      summary: Set base UOM for a unit class
      description: |
        Mark a UOM as the base unit for its parent unit class. The previous base UOM (if any) is unset, and conversion
        factors continue to be expressed relative to the new base.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: unitClassId
          required: true
          schema:
            type: integer
          description: Unit class ID
        - in: path
          name: unitOfMeasureId
          required: true
          schema:
            type: integer
          description: ID of the UOM to mark as base
      responses:
        '200':
          description: Base UOM updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A grouping of related units of measure (e.g. "Length", "Weight"). Each class may have a base unit and a list of UOMs.'
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      name:
                        type: string
                      base_class:
                        type: boolean
                        description: True for the system base class (read-only).
                      unit_of_measures:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            status:
                              type: string
                              nullable: true
                            unit_class_id:
                              type: integer
                            unit_class:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                base_class:
                                  type: boolean
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            base_unit:
                              type: boolean
                              description: True if this UOM is the base unit for its class.
                            unit_conversion_rules:
                              type: array
                              description: Present when the relation is loaded.
                              items:
                                type: object
                                description: |
                                  A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                  1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                properties:
                                  id:
                                    type: integer
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  status:
                                    type: string
                                    nullable: true
                                  base_unit_of_measure_id:
                                    type: integer
                                  base_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  converted_unit_of_measure_id:
                                    type: integer
                                  converted_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  conversion_factor:
                                    type: number
                                    description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                  type:
                                    type: string
                                    enum:
                                      - SYSTEM
                                      - SKU
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Required when `type=SKU`; null when `type=SYSTEM`.
                                  product:
                                    type: object
                                    nullable: true
                                    description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                    additionalProperties: true
                                  product_alternate_skus:
                                    type: array
                                    description: Present when the relation is loaded.
                                    items:
                                      type: object
                                      additionalProperties: true
                      base_unit_of_measure:
                        description: Present when the relation is loaded.
                        nullable: true
                        allOf:
                          - type: object
                            description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              status:
                                type: string
                                nullable: true
                              unit_class_id:
                                type: integer
                              unit_class:
                                type: object
                                description: Present when the relation is loaded.
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  base_class:
                                    type: boolean
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              base_unit:
                                type: boolean
                                description: True if this UOM is the base unit for its class.
                              unit_conversion_rules:
                                type: array
                                description: Present when the relation is loaded.
                                items:
                                  type: object
                                  description: |
                                    A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                    1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                  properties:
                                    id:
                                      type: integer
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    status:
                                      type: string
                                      nullable: true
                                    base_unit_of_measure_id:
                                      type: integer
                                    base_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    converted_unit_of_measure_id:
                                      type: integer
                                    converted_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    conversion_factor:
                                      type: number
                                      description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                    type:
                                      type: string
                                      enum:
                                        - SYSTEM
                                        - SKU
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Required when `type=SKU`; null when `type=SYSTEM`.
                                    product:
                                      type: object
                                      nullable: true
                                      description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                      additionalProperties: true
                                    product_alternate_skus:
                                      type: array
                                      description: Present when the relation is loaded.
                                      items:
                                        type: object
                                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Unit class or UOM not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: UOM does not belong to the specified class
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/unit-classes/{id}':
    get:
      operationId: getUnitClass
      tags:
        - Unit Classes
      summary: Single unit class
      description: Retrieve a unit class by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit class ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A grouping of related units of measure (e.g. "Length", "Weight"). Each class may have a base unit and a list of UOMs.'
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      name:
                        type: string
                      base_class:
                        type: boolean
                        description: True for the system base class (read-only).
                      unit_of_measures:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            status:
                              type: string
                              nullable: true
                            unit_class_id:
                              type: integer
                            unit_class:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                base_class:
                                  type: boolean
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            base_unit:
                              type: boolean
                              description: True if this UOM is the base unit for its class.
                            unit_conversion_rules:
                              type: array
                              description: Present when the relation is loaded.
                              items:
                                type: object
                                description: |
                                  A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                  1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                properties:
                                  id:
                                    type: integer
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  status:
                                    type: string
                                    nullable: true
                                  base_unit_of_measure_id:
                                    type: integer
                                  base_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  converted_unit_of_measure_id:
                                    type: integer
                                  converted_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  conversion_factor:
                                    type: number
                                    description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                  type:
                                    type: string
                                    enum:
                                      - SYSTEM
                                      - SKU
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Required when `type=SKU`; null when `type=SYSTEM`.
                                  product:
                                    type: object
                                    nullable: true
                                    description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                    additionalProperties: true
                                  product_alternate_skus:
                                    type: array
                                    description: Present when the relation is loaded.
                                    items:
                                      type: object
                                      additionalProperties: true
                      base_unit_of_measure:
                        description: Present when the relation is loaded.
                        nullable: true
                        allOf:
                          - type: object
                            description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              status:
                                type: string
                                nullable: true
                              unit_class_id:
                                type: integer
                              unit_class:
                                type: object
                                description: Present when the relation is loaded.
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  base_class:
                                    type: boolean
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              base_unit:
                                type: boolean
                                description: True if this UOM is the base unit for its class.
                              unit_conversion_rules:
                                type: array
                                description: Present when the relation is loaded.
                                items:
                                  type: object
                                  description: |
                                    A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                    1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                  properties:
                                    id:
                                      type: integer
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    status:
                                      type: string
                                      nullable: true
                                    base_unit_of_measure_id:
                                      type: integer
                                    base_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    converted_unit_of_measure_id:
                                      type: integer
                                    converted_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    conversion_factor:
                                      type: number
                                      description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                    type:
                                      type: string
                                      enum:
                                        - SYSTEM
                                        - SKU
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Required when `type=SKU`; null when `type=SYSTEM`.
                                    product:
                                      type: object
                                      nullable: true
                                      description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                      additionalProperties: true
                                    product_alternate_skus:
                                      type: array
                                      description: Present when the relation is loaded.
                                      items:
                                        type: object
                                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Unit class not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: updateUnitClass
      tags:
        - Unit Classes
      summary: Update unit class
      description: Update an existing unit class.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit class ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                base_class:
                  type: boolean
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A grouping of related units of measure (e.g. "Length", "Weight"). Each class may have a base unit and a list of UOMs.'
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      name:
                        type: string
                      base_class:
                        type: boolean
                        description: True for the system base class (read-only).
                      unit_of_measures:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            status:
                              type: string
                              nullable: true
                            unit_class_id:
                              type: integer
                            unit_class:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                base_class:
                                  type: boolean
                            name:
                              type: string
                            description:
                              type: string
                              nullable: true
                            base_unit:
                              type: boolean
                              description: True if this UOM is the base unit for its class.
                            unit_conversion_rules:
                              type: array
                              description: Present when the relation is loaded.
                              items:
                                type: object
                                description: |
                                  A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                  1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                properties:
                                  id:
                                    type: integer
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  status:
                                    type: string
                                    nullable: true
                                  base_unit_of_measure_id:
                                    type: integer
                                  base_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  converted_unit_of_measure_id:
                                    type: integer
                                  converted_unit_of_measure:
                                    type: object
                                    description: Present when the relation is loaded.
                                    nullable: true
                                    properties:
                                      id:
                                        type: integer
                                      name:
                                        type: string
                                      unit_class_id:
                                        type: integer
                                      base_unit:
                                        type: boolean
                                  conversion_factor:
                                    type: number
                                    description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                  type:
                                    type: string
                                    enum:
                                      - SYSTEM
                                      - SKU
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Required when `type=SKU`; null when `type=SYSTEM`.
                                  product:
                                    type: object
                                    nullable: true
                                    description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                    additionalProperties: true
                                  product_alternate_skus:
                                    type: array
                                    description: Present when the relation is loaded.
                                    items:
                                      type: object
                                      additionalProperties: true
                      base_unit_of_measure:
                        description: Present when the relation is loaded.
                        nullable: true
                        allOf:
                          - type: object
                            description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              status:
                                type: string
                                nullable: true
                              unit_class_id:
                                type: integer
                              unit_class:
                                type: object
                                description: Present when the relation is loaded.
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  base_class:
                                    type: boolean
                              name:
                                type: string
                              description:
                                type: string
                                nullable: true
                              base_unit:
                                type: boolean
                                description: True if this UOM is the base unit for its class.
                              unit_conversion_rules:
                                type: array
                                description: Present when the relation is loaded.
                                items:
                                  type: object
                                  description: |
                                    A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                    1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                  properties:
                                    id:
                                      type: integer
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    status:
                                      type: string
                                      nullable: true
                                    base_unit_of_measure_id:
                                      type: integer
                                    base_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    converted_unit_of_measure_id:
                                      type: integer
                                    converted_unit_of_measure:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        unit_class_id:
                                          type: integer
                                        base_unit:
                                          type: boolean
                                    conversion_factor:
                                      type: number
                                      description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                    type:
                                      type: string
                                      enum:
                                        - SYSTEM
                                        - SKU
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Required when `type=SKU`; null when `type=SYSTEM`.
                                    product:
                                      type: object
                                      nullable: true
                                      description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                      additionalProperties: true
                                    product_alternate_skus:
                                      type: array
                                      description: Present when the relation is loaded.
                                      items:
                                        type: object
                                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Unit class not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteUnitClass
      tags:
        - Unit Classes
      summary: Delete unit class
      description: 'Delete a unit class. Returns 422 if any UOMs or conversion rules still reference it, or if it is the default unit class ("The default unit class cannot be deleted.").'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit class ID
      responses:
        '204':
          description: Deleted (no content)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Unit class not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Cannot delete (in use, or the default unit class)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /unit-of-measures:
    get:
      operationId: listUnitOfMeasures
      tags:
        - Units of Measure
      summary: List units of measure
      description: Paginated list of units of measure.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                      properties:
                        id:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        status:
                          type: string
                          nullable: true
                        unit_class_id:
                          type: integer
                        unit_class:
                          type: object
                          description: Present when the relation is loaded.
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            base_class:
                              type: boolean
                        name:
                          type: string
                        description:
                          type: string
                          nullable: true
                        base_unit:
                          type: boolean
                          description: True if this UOM is the base unit for its class.
                        unit_conversion_rules:
                          type: array
                          description: Present when the relation is loaded.
                          items:
                            type: object
                            description: |
                              A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                              1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                            properties:
                              id:
                                type: integer
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              status:
                                type: string
                                nullable: true
                              base_unit_of_measure_id:
                                type: integer
                              base_unit_of_measure:
                                type: object
                                description: Present when the relation is loaded.
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  unit_class_id:
                                    type: integer
                                  base_unit:
                                    type: boolean
                              converted_unit_of_measure_id:
                                type: integer
                              converted_unit_of_measure:
                                type: object
                                description: Present when the relation is loaded.
                                nullable: true
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  unit_class_id:
                                    type: integer
                                  base_unit:
                                    type: boolean
                              conversion_factor:
                                type: number
                                description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                              type:
                                type: string
                                enum:
                                  - SYSTEM
                                  - SKU
                              product_id:
                                type: integer
                                nullable: true
                                description: Required when `type=SKU`; null when `type=SYSTEM`.
                              product:
                                type: object
                                nullable: true
                                description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                additionalProperties: true
                              product_alternate_skus:
                                type: array
                                description: Present when the relation is loaded.
                                items:
                                  type: object
                                  additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                      per_page:
                        type: integer
                      total:
                        type: integer
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createUnitOfMeasure
      tags:
        - Units of Measure
      summary: Create unit of measure
      description: Create a new UOM under an existing unit class.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - unit_class_id
                - name
                - description
              properties:
                unit_class_id:
                  type: integer
                name:
                  type: string
                description:
                  type: string
                base_unit:
                  type: boolean
                  description: 'When true, this UOM becomes the base unit for its class.'
                conversion_factor:
                  type: number
                  minimum: 0
                  description: |
                    Optional. When provided alongside a non-base UOM, a SYSTEM conversion rule from the base UOM to this
                    new UOM is created automatically with the given factor.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      unit_class_id:
                        type: integer
                      unit_class:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          base_class:
                            type: boolean
                      name:
                        type: string
                      description:
                        type: string
                        nullable: true
                      base_unit:
                        type: boolean
                        description: True if this UOM is the base unit for its class.
                      unit_conversion_rules:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          description: |
                            A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                            1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            status:
                              type: string
                              nullable: true
                            base_unit_of_measure_id:
                              type: integer
                            base_unit_of_measure:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                unit_class_id:
                                  type: integer
                                base_unit:
                                  type: boolean
                            converted_unit_of_measure_id:
                              type: integer
                            converted_unit_of_measure:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                unit_class_id:
                                  type: integer
                                base_unit:
                                  type: boolean
                            conversion_factor:
                              type: number
                              description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                            type:
                              type: string
                              enum:
                                - SYSTEM
                                - SKU
                            product_id:
                              type: integer
                              nullable: true
                              description: Required when `type=SKU`; null when `type=SYSTEM`.
                            product:
                              type: object
                              nullable: true
                              description: Present when the relation is loaded. Shape mirrors the standard product resource.
                              additionalProperties: true
                            product_alternate_skus:
                              type: array
                              description: Present when the relation is loaded.
                              items:
                                type: object
                                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/unit-of-measures/{id}':
    get:
      operationId: getUnitOfMeasure
      tags:
        - Units of Measure
      summary: Single unit of measure
      description: Retrieve a UOM by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit of measure ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      unit_class_id:
                        type: integer
                      unit_class:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          base_class:
                            type: boolean
                      name:
                        type: string
                      description:
                        type: string
                        nullable: true
                      base_unit:
                        type: boolean
                        description: True if this UOM is the base unit for its class.
                      unit_conversion_rules:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          description: |
                            A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                            1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            status:
                              type: string
                              nullable: true
                            base_unit_of_measure_id:
                              type: integer
                            base_unit_of_measure:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                unit_class_id:
                                  type: integer
                                base_unit:
                                  type: boolean
                            converted_unit_of_measure_id:
                              type: integer
                            converted_unit_of_measure:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                unit_class_id:
                                  type: integer
                                base_unit:
                                  type: boolean
                            conversion_factor:
                              type: number
                              description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                            type:
                              type: string
                              enum:
                                - SYSTEM
                                - SKU
                            product_id:
                              type: integer
                              nullable: true
                              description: Required when `type=SKU`; null when `type=SYSTEM`.
                            product:
                              type: object
                              nullable: true
                              description: Present when the relation is loaded. Shape mirrors the standard product resource.
                              additionalProperties: true
                            product_alternate_skus:
                              type: array
                              description: Present when the relation is loaded.
                              items:
                                type: object
                                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Unit of measure not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: updateUnitOfMeasure
      tags:
        - Units of Measure
      summary: Update unit of measure
      description: Update an existing UOM.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit of measure ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - unit_class_id
                - name
                - description
              properties:
                unit_class_id:
                  type: integer
                name:
                  type: string
                description:
                  type: string
                base_unit:
                  type: boolean
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      unit_class_id:
                        type: integer
                      unit_class:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          base_class:
                            type: boolean
                      name:
                        type: string
                      description:
                        type: string
                        nullable: true
                      base_unit:
                        type: boolean
                        description: True if this UOM is the base unit for its class.
                      unit_conversion_rules:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          description: |
                            A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                            1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                          properties:
                            id:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            status:
                              type: string
                              nullable: true
                            base_unit_of_measure_id:
                              type: integer
                            base_unit_of_measure:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                unit_class_id:
                                  type: integer
                                base_unit:
                                  type: boolean
                            converted_unit_of_measure_id:
                              type: integer
                            converted_unit_of_measure:
                              type: object
                              description: Present when the relation is loaded.
                              nullable: true
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                                unit_class_id:
                                  type: integer
                                base_unit:
                                  type: boolean
                            conversion_factor:
                              type: number
                              description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                            type:
                              type: string
                              enum:
                                - SYSTEM
                                - SKU
                            product_id:
                              type: integer
                              nullable: true
                              description: Required when `type=SKU`; null when `type=SYSTEM`.
                            product:
                              type: object
                              nullable: true
                              description: Present when the relation is loaded. Shape mirrors the standard product resource.
                              additionalProperties: true
                            product_alternate_skus:
                              type: array
                              description: Present when the relation is loaded.
                              items:
                                type: object
                                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Unit of measure not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteUnitOfMeasure
      tags:
        - Units of Measure
      summary: Delete unit of measure
      description: 'Delete a UOM. Returns 422 if the UOM is the base unit of its unit class ("{name} is the base unit of the {class} unit class and cannot be deleted."), or if it is still referenced anywhere — conversion rules, product/kit default units, BOM and kit items, supplier SKUs, purchase/sales/transfer order lines, inventory transactions and adjustments, bills, etc. ("Used or referred unit of measure cannot be deleted.").'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit of measure ID
      responses:
        '204':
          description: Deleted (no content)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Unit of measure not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Cannot delete (base unit of its class, or still referenced)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /unit-conversion-rules:
    get:
      operationId: listUnitConversionRules
      tags:
        - Unit Conversion Rules
      summary: List unit conversion rules
      description: |
        Paginated list of `SYSTEM` and `SKU` conversion rules. Internal kit-scoped rules are excluded from this
        endpoint.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                        1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                      properties:
                        id:
                          type: integer
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        status:
                          type: string
                          nullable: true
                        base_unit_of_measure_id:
                          type: integer
                        base_unit_of_measure:
                          type: object
                          description: Present when the relation is loaded.
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            unit_class_id:
                              type: integer
                            base_unit:
                              type: boolean
                        converted_unit_of_measure_id:
                          type: integer
                        converted_unit_of_measure:
                          type: object
                          description: Present when the relation is loaded.
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                            unit_class_id:
                              type: integer
                            base_unit:
                              type: boolean
                        conversion_factor:
                          type: number
                          description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                        type:
                          type: string
                          enum:
                            - SYSTEM
                            - SKU
                        product_id:
                          type: integer
                          nullable: true
                          description: Required when `type=SKU`; null when `type=SYSTEM`.
                        product:
                          type: object
                          nullable: true
                          description: Present when the relation is loaded. Shape mirrors the standard product resource.
                          additionalProperties: true
                        product_alternate_skus:
                          type: array
                          description: Present when the relation is loaded.
                          items:
                            type: object
                            additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                      per_page:
                        type: integer
                      total:
                        type: integer
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createUnitConversionRule
      tags:
        - Unit Conversion Rules
      summary: Create unit conversion rule
      description: |
        Create a new conversion rule. Use `type=SYSTEM` for global per-class rules and `type=SKU` for product-specific
        overrides — when `type=SKU`, `product_id` is required (and must be omitted for `SYSTEM`).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - type
                - base_unit_of_measure_id
                - converted_unit_of_measure_id
                - conversion_factor
              properties:
                type:
                  type: string
                  enum:
                    - SYSTEM
                    - SKU
                product_id:
                  type: integer
                  description: Required when `type=SKU`; omit when `type=SYSTEM`.
                base_unit_of_measure_id:
                  type: integer
                converted_unit_of_measure_id:
                  type: integer
                conversion_factor:
                  type: number
                  minimum: 0
                  exclusiveMinimum: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                      1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      base_unit_of_measure_id:
                        type: integer
                      base_unit_of_measure:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          unit_class_id:
                            type: integer
                          base_unit:
                            type: boolean
                      converted_unit_of_measure_id:
                        type: integer
                      converted_unit_of_measure:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          unit_class_id:
                            type: integer
                          base_unit:
                            type: boolean
                      conversion_factor:
                        type: number
                        description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                      type:
                        type: string
                        enum:
                          - SYSTEM
                          - SKU
                      product_id:
                        type: integer
                        nullable: true
                        description: Required when `type=SKU`; null when `type=SYSTEM`.
                      product:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded. Shape mirrors the standard product resource.
                        additionalProperties: true
                      product_alternate_skus:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /unit-conversion-rules/resolve:
    get:
      operationId: resolveUnitConversionRule
      tags:
        - Unit Conversion Rules
      summary: Resolve effective conversion rule
      description: |
        Resolve the effective conversion rule for a `(product, base_uom, converted_uom)` triple. SKU-specific rules
        win over SYSTEM rules. Returns 404 when no matching rule exists.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: product_id
          required: true
          schema:
            type: integer
        - in: query
          name: base_unit_of_measure_id
          required: true
          schema:
            type: integer
        - in: query
          name: converted_unit_of_measure_id
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                      1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      base_unit_of_measure_id:
                        type: integer
                      base_unit_of_measure:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          unit_class_id:
                            type: integer
                          base_unit:
                            type: boolean
                      converted_unit_of_measure_id:
                        type: integer
                      converted_unit_of_measure:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          unit_class_id:
                            type: integer
                          base_unit:
                            type: boolean
                      conversion_factor:
                        type: number
                        description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                      type:
                        type: string
                        enum:
                          - SYSTEM
                          - SKU
                      product_id:
                        type: integer
                        nullable: true
                        description: Required when `type=SKU`; null when `type=SYSTEM`.
                      product:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded. Shape mirrors the standard product resource.
                        additionalProperties: true
                      product_alternate_skus:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: No matching rule
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/unit-conversion-rules/{id}':
    get:
      operationId: getUnitConversionRule
      tags:
        - Unit Conversion Rules
      summary: Single unit conversion rule
      description: Retrieve a unit conversion rule by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit conversion rule ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                      1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      base_unit_of_measure_id:
                        type: integer
                      base_unit_of_measure:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          unit_class_id:
                            type: integer
                          base_unit:
                            type: boolean
                      converted_unit_of_measure_id:
                        type: integer
                      converted_unit_of_measure:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          unit_class_id:
                            type: integer
                          base_unit:
                            type: boolean
                      conversion_factor:
                        type: number
                        description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                      type:
                        type: string
                        enum:
                          - SYSTEM
                          - SKU
                      product_id:
                        type: integer
                        nullable: true
                        description: Required when `type=SKU`; null when `type=SYSTEM`.
                      product:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded. Shape mirrors the standard product resource.
                        additionalProperties: true
                      product_alternate_skus:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Conversion rule not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: updateUnitConversionRule
      tags:
        - Unit Conversion Rules
      summary: Update unit conversion rule
      description: Update an existing conversion rule. Same payload shape and rules as create.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit conversion rule ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - type
                - base_unit_of_measure_id
                - converted_unit_of_measure_id
                - conversion_factor
              properties:
                type:
                  type: string
                  enum:
                    - SYSTEM
                    - SKU
                product_id:
                  type: integer
                  description: Required when `type=SKU`; omit when `type=SYSTEM`.
                base_unit_of_measure_id:
                  type: integer
                converted_unit_of_measure_id:
                  type: integer
                conversion_factor:
                  type: number
                  minimum: 0
                  exclusiveMinimum: true
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                      1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                    properties:
                      id:
                        type: integer
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      status:
                        type: string
                        nullable: true
                      base_unit_of_measure_id:
                        type: integer
                      base_unit_of_measure:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          unit_class_id:
                            type: integer
                          base_unit:
                            type: boolean
                      converted_unit_of_measure_id:
                        type: integer
                      converted_unit_of_measure:
                        type: object
                        description: Present when the relation is loaded.
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          unit_class_id:
                            type: integer
                          base_unit:
                            type: boolean
                      conversion_factor:
                        type: number
                        description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                      type:
                        type: string
                        enum:
                          - SYSTEM
                          - SKU
                      product_id:
                        type: integer
                        nullable: true
                        description: Required when `type=SKU`; null when `type=SYSTEM`.
                      product:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded. Shape mirrors the standard product resource.
                        additionalProperties: true
                      product_alternate_skus:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Conversion rule not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteUnitConversionRule
      tags:
        - Unit Conversion Rules
      summary: Delete unit conversion rule
      description: Delete a unit conversion rule.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Unit conversion rule ID
      responses:
        '204':
          description: Deleted (no content)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Conversion rule not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Cannot delete
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /channels:
    get:
      operationId: listChannels
      tags:
        - Channels
      summary: List channels
      description: |
        Paginated list of non-deleted channels with optional filters. Always allowed — `apiLocked` does not block
        reads.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 15
        - in: query
          name: sortField
          schema:
            type: string
        - in: query
          name: sortDirection
          schema:
            type: string
            enum:
              - asc
              - desc
        - in: query
          name: label
          schema:
            type: string
          description: Substring match on channel label.
        - in: query
          name: tagIds
          style: form
          explode: true
          schema:
            type: array
            items:
              type: integer
          description: Channels that have at least one of the listed tag IDs.
        - in: query
          name: status
          schema:
            type: integer
        - in: query
          name: isPosChannel
          schema:
            type: boolean
        - in: query
          name: isCustomerSpecific
          schema:
            type: boolean
        - in: query
          name: isPushOrderToOms
          schema:
            type: boolean
          description: 'When true, filters to channels that have a push-order integration mapping.'
        - in: query
          name: channelTypes
          schema:
            type: string
          description: 'Comma-separated list of channel types (e.g. `sales_channel,end_to_end_channel`).'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: |
                        A sales, fulfillment, or end-to-end channel. Channels carry per-OMS configuration (pull orders, push orders,
                        push stocks, push costs) and an `apiLocked` flag — when locked, mutating operations through the external API
                        return 403.
                      properties:
                        id:
                          type: integer
                        uuid:
                          type: string
                        label:
                          type: string
                        description:
                          type: string
                          nullable: true
                        channelType:
                          type: string
                          enum:
                            - sales_channel
                            - fulfillment_channel
                            - end_to_end_channel
                        apiLocked:
                          type: boolean
                          description: 'When true, PUT/DELETE/integration-products operations on this channel are blocked via the external API.'
                        warehouseGroupId:
                          type: integer
                          nullable: true
                        warehouseGroup:
                          type: object
                          nullable: true
                          description: Present when the relation is loaded.
                          additionalProperties: true
                        storeType:
                          type: string
                          nullable: true
                        enabled:
                          type: boolean
                        status:
                          type: integer
                        isPOSChannel:
                          type: boolean
                          nullable: true
                        isCustomerSpecific:
                          type: boolean
                          nullable: true
                        pullOrdersFromOms:
                          type: boolean
                        getProductsEnabled:
                          type: boolean
                        pushInventoryEnabled:
                          type: boolean
                        includeIncomingStocksEnabled:
                          type: boolean
                        includeDraftProductsEnabled:
                          type: boolean
                          description: 'When stock push to the OMS is enabled, whether draft-status products are included in the stock push. Set via the `includeDraftProducts` key inside `pushStocksToOmsOptions` on channel create/update.'
                        pullStocksEnabled:
                          type: boolean
                        pullShipmentsEnabled:
                          type: boolean
                        pushIncomingStocksFromSupplierPurchaseOrderEnabled:
                          type: boolean
                        pushStocksAppIntegrationAccountId:
                          type: integer
                          nullable: true
                        channelIntegrationMapping:
                          type: array
                          description: Present when the relation is loaded.
                          items:
                            type: object
                            additionalProperties: true
                        pullOrderIntegrationMapping:
                          type: object
                          nullable: true
                          description: Present when the relation is loaded.
                          additionalProperties: true
                        pushOrderIntegrationMapping:
                          type: object
                          nullable: true
                          description: Present when the relation is loaded.
                          additionalProperties: true
                        pushStockIntegrationMapping:
                          type: object
                          nullable: true
                          description: Present when the relation is loaded.
                          additionalProperties: true
                        pushCostIntegrationMapping:
                          type: object
                          nullable: true
                          description: Present when the relation is loaded.
                          additionalProperties: true
                        tags:
                          type: array
                          description: Present when the relation is loaded.
                          items:
                            type: object
                            additionalProperties: true
                        metafields:
                          type: array
                          description: Present when the relation is loaded. Channel-level settings/metadata key-value pairs.
                          items:
                            type: object
                            additionalProperties: true
                        isDropship:
                          type: boolean
                          nullable: true
                        dropshipSupplierId:
                          type: integer
                          nullable: true
                        dropshipPoDeliveryType:
                          type: string
                          nullable: true
                        dropshipPoDeliveryWarehouseId:
                          type: integer
                          nullable: true
                        dropshipAutoCreatePo:
                          type: boolean
                          nullable: true
                        dropshipAutoSendPo:
                          type: boolean
                          nullable: true
                        dropshipInventoryNotTracked:
                          type: boolean
                          nullable: true
                        autoPushOrderAfterMinutes:
                          type: integer
                          nullable: true
                        autoPushMode:
                          type: string
                          nullable: true
                        stockPushMaxQuantity:
                          type: integer
                          nullable: true
                          description: Channel-wide cap on the quantity pushed to the channel for any product. `null` = not set; products use their own value.
                        stockPushBufferQuantity:
                          type: integer
                          nullable: true
                          description: 'Channel-wide buffer held back from the pushed quantity, applied per `stockPushBufferType`. `null` = not set; products use their own value.'
                        stockPushBufferType:
                          type: string
                          nullable: true
                          enum:
                            - fixed
                            - percent
                          description: How `stockPushBufferQuantity` is applied — a fixed unit count or a percentage of available stock.
                        filters:
                          type: object
                          nullable: true
                          additionalProperties: true
                        restrictions:
                          type: object
                          nullable: true
                          additionalProperties: true
                        credentials:
                          type: object
                          nullable: true
                          additionalProperties: true
                        fees:
                          type: object
                          nullable: true
                          additionalProperties: true
                        createdAt:
                          type: integer
                          description: Unix timestamp
                        updatedAt:
                          type: integer
                          description: Unix timestamp
                        createdBy:
                          type: integer
                          nullable: true
                        updatedBy:
                          type: integer
                          nullable: true
                  meta:
                    type: object
                    additionalProperties: true
                  links:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createChannel
      tags:
        - Channels
      summary: Create channel
      description: |
        Create a channel of any type (`sales_channel`, `fulfillment_channel`, `end_to_end_channel`). New channels are
        created **unlocked** (`apiLocked: false`). Many fields are conditionally required based on `channelType` and
        the OMS integrations enabled — see the description on each property.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - channelType
                - label
              properties:
                channelType:
                  type: string
                  enum:
                    - sales_channel
                    - fulfillment_channel
                    - end_to_end_channel
                label:
                  type: string
                  description: Must be unique among active/disabled channels.
                description:
                  type: string
                  nullable: true
                warehouseGroupId:
                  type: integer
                  nullable: true
                  description: 'Required for `sales_channel`. Required for fulfillment/e2e unless dropship with `dropshipInventoryNotTracked: true`.'
                isCustomerSpecific:
                  type: boolean
                  nullable: true
                tagIds:
                  type: array
                  items:
                    type: integer
                pullOrdersFromOms:
                  type: boolean
                  nullable: true
                  description: Sales/e2e channels.
                pullOrderAppIntegrationAccountId:
                  type: integer
                  description: Required when `pullOrdersFromOms` is true.
                pullOrderOmsStoreId:
                  type: string
                  description: Required when `pullOrdersFromOms` is true and the integration app requires a store ID.
                pullOrdersFromOmsOptions:
                  type: object
                  additionalProperties: true
                pushOrdersToOms:
                  type: boolean
                  nullable: true
                  description: Fulfillment/e2e channels.
                pushOrderAppIntegrationAccountId:
                  type: integer
                  description: Required when `pushOrdersToOms` is true.
                pushOrderOmsStoreId:
                  type: string
                pushOrderIntegrationMappingId:
                  type: integer
                  nullable: true
                  description: Attach this `integration_mappings.id` as the channel's PUSH_ORDERS mapping. Creating a mapping does not attach it; set this field (or `pushOrdersToOmsOptions.integration_mapping_id`) or the channel keeps the default transformer.
                pushStocksToOms:
                  type: boolean
                  nullable: true
                pushStocksAppIntegrationAccountId:
                  type: integer
                  nullable: true
                pushCostsToOms:
                  type: boolean
                  nullable: true
                isDropship:
                  type: boolean
                  nullable: true
                dropshipSupplierId:
                  type: integer
                  nullable: true
                dropshipInventoryNotTracked:
                  type: boolean
                  nullable: true
                stockPushMaxQuantity:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: Channel-wide cap on the quantity pushed to the channel for any product. `null` = not set; products use their own value.
                stockPushBufferQuantity:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: Channel-wide buffer held back from the pushed quantity. Interpreted per `stockPushBufferType`. `null` = not set; products use their own value.
                stockPushBufferType:
                  type: string
                  nullable: true
                  enum:
                    - fixed
                    - percent
                  description: How `stockPushBufferQuantity` is applied — a fixed unit count or a percentage of available stock. `null` = not set.
                filters:
                  type: array
                  nullable: true
                  description: |
                    Incoming-order filters for the channel. Each entry has a `key` (order field), a `condition`, and a `value`.
                    `condition` must be one of `EQ`, `NEQ`, `IN`, `NCON`, `EXACT_IN`, `IN_LIST` (the conditions the order
                    matcher evaluates); any other condition returns **422**.
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        example: source_name
                      condition:
                        type: string
                        enum:
                          - EQ
                          - NEQ
                          - IN
                          - NCON
                          - EXACT_IN
                          - IN_LIST
                      value:
                        description: Value to compare against.
                    additionalProperties: true
                integrationProducts:
                  type: array
                  maxItems: 500
                  description: |
                    Optional. Inline batch of channel SKU → Luminous SKU mappings to create alongside the channel,
                    equivalent to following up with `POST /channels/{id}/integration-products`.
                  items:
                    type: object
                    additionalProperties: true
              additionalProperties: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A sales, fulfillment, or end-to-end channel. Channels carry per-OMS configuration (pull orders, push orders,
                      push stocks, push costs) and an `apiLocked` flag — when locked, mutating operations through the external API
                      return 403.
                    properties:
                      id:
                        type: integer
                      uuid:
                        type: string
                      label:
                        type: string
                      description:
                        type: string
                        nullable: true
                      channelType:
                        type: string
                        enum:
                          - sales_channel
                          - fulfillment_channel
                          - end_to_end_channel
                      apiLocked:
                        type: boolean
                        description: 'When true, PUT/DELETE/integration-products operations on this channel are blocked via the external API.'
                      warehouseGroupId:
                        type: integer
                        nullable: true
                      warehouseGroup:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      storeType:
                        type: string
                        nullable: true
                      enabled:
                        type: boolean
                      status:
                        type: integer
                      isPOSChannel:
                        type: boolean
                        nullable: true
                      isCustomerSpecific:
                        type: boolean
                        nullable: true
                      pullOrdersFromOms:
                        type: boolean
                      getProductsEnabled:
                        type: boolean
                      pushInventoryEnabled:
                        type: boolean
                      includeIncomingStocksEnabled:
                        type: boolean
                      includeDraftProductsEnabled:
                        type: boolean
                        description: 'When stock push to the OMS is enabled, whether draft-status products are included in the stock push. Set via the `includeDraftProducts` key inside `pushStocksToOmsOptions` on channel create/update.'
                      pullStocksEnabled:
                        type: boolean
                      pullShipmentsEnabled:
                        type: boolean
                      pushIncomingStocksFromSupplierPurchaseOrderEnabled:
                        type: boolean
                      pushStocksAppIntegrationAccountId:
                        type: integer
                        nullable: true
                      channelIntegrationMapping:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      pullOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushStockIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushCostIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      tags:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      metafields:
                        type: array
                        description: Present when the relation is loaded. Channel-level settings/metadata key-value pairs.
                        items:
                          type: object
                          additionalProperties: true
                      isDropship:
                        type: boolean
                        nullable: true
                      dropshipSupplierId:
                        type: integer
                        nullable: true
                      dropshipPoDeliveryType:
                        type: string
                        nullable: true
                      dropshipPoDeliveryWarehouseId:
                        type: integer
                        nullable: true
                      dropshipAutoCreatePo:
                        type: boolean
                        nullable: true
                      dropshipAutoSendPo:
                        type: boolean
                        nullable: true
                      dropshipInventoryNotTracked:
                        type: boolean
                        nullable: true
                      autoPushOrderAfterMinutes:
                        type: integer
                        nullable: true
                      autoPushMode:
                        type: string
                        nullable: true
                      stockPushMaxQuantity:
                        type: integer
                        nullable: true
                        description: Channel-wide cap on the quantity pushed to the channel for any product. `null` = not set; products use their own value.
                      stockPushBufferQuantity:
                        type: integer
                        nullable: true
                        description: 'Channel-wide buffer held back from the pushed quantity, applied per `stockPushBufferType`. `null` = not set; products use their own value.'
                      stockPushBufferType:
                        type: string
                        nullable: true
                        enum:
                          - fixed
                          - percent
                        description: How `stockPushBufferQuantity` is applied — a fixed unit count or a percentage of available stock.
                      filters:
                        type: object
                        nullable: true
                        additionalProperties: true
                      restrictions:
                        type: object
                        nullable: true
                        additionalProperties: true
                      credentials:
                        type: object
                        nullable: true
                        additionalProperties: true
                      fees:
                        type: object
                        nullable: true
                        additionalProperties: true
                      createdAt:
                        type: integer
                        description: Unix timestamp
                      updatedAt:
                        type: integer
                        description: Unix timestamp
                      createdBy:
                        type: integer
                        nullable: true
                      updatedBy:
                        type: integer
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /channels/sales:
    post:
      operationId: createSalesChannel
      tags:
        - Channels
      summary: Create sales channel (legacy)
      description: |
        Backward-compatible endpoint that creates a sales channel without requiring `channelType` in the body. Same
        underlying flow as `POST /channels` with `channelType=sales_channel`. Prefer `POST /channels` for new
        integrations.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - label
                - warehouseGroupId
              properties:
                label:
                  type: string
                description:
                  type: string
                  nullable: true
                warehouseGroupId:
                  type: integer
                isCustomerSpecific:
                  type: boolean
                  nullable: true
                pullOrdersFromOms:
                  type: boolean
                  nullable: true
                pullOrderAppIntegrationAccountId:
                  type: integer
                pullOrderOmsStoreId:
                  type: string
                tagIds:
                  type: array
                  items:
                    type: integer
                filters:
                  type: array
                  nullable: true
                  description: |
                    Incoming-order filters for the channel. Each entry has a `key` (order field), a `condition`, and a `value`.
                    `condition` must be one of `EQ`, `NEQ`, `IN`, `NCON`, `EXACT_IN`, `IN_LIST` (the conditions the order
                    matcher evaluates); any other condition returns **422**.
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        example: source_name
                      condition:
                        type: string
                        enum:
                          - EQ
                          - NEQ
                          - IN
                          - NCON
                          - EXACT_IN
                          - IN_LIST
                      value:
                        description: Value to compare against.
                    additionalProperties: true
              additionalProperties: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A sales, fulfillment, or end-to-end channel. Channels carry per-OMS configuration (pull orders, push orders,
                      push stocks, push costs) and an `apiLocked` flag — when locked, mutating operations through the external API
                      return 403.
                    properties:
                      id:
                        type: integer
                      uuid:
                        type: string
                      label:
                        type: string
                      description:
                        type: string
                        nullable: true
                      channelType:
                        type: string
                        enum:
                          - sales_channel
                          - fulfillment_channel
                          - end_to_end_channel
                      apiLocked:
                        type: boolean
                        description: 'When true, PUT/DELETE/integration-products operations on this channel are blocked via the external API.'
                      warehouseGroupId:
                        type: integer
                        nullable: true
                      warehouseGroup:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      storeType:
                        type: string
                        nullable: true
                      enabled:
                        type: boolean
                      status:
                        type: integer
                      isPOSChannel:
                        type: boolean
                        nullable: true
                      isCustomerSpecific:
                        type: boolean
                        nullable: true
                      pullOrdersFromOms:
                        type: boolean
                      getProductsEnabled:
                        type: boolean
                      pushInventoryEnabled:
                        type: boolean
                      includeIncomingStocksEnabled:
                        type: boolean
                      includeDraftProductsEnabled:
                        type: boolean
                        description: 'When stock push to the OMS is enabled, whether draft-status products are included in the stock push. Set via the `includeDraftProducts` key inside `pushStocksToOmsOptions` on channel create/update.'
                      pullStocksEnabled:
                        type: boolean
                      pullShipmentsEnabled:
                        type: boolean
                      pushIncomingStocksFromSupplierPurchaseOrderEnabled:
                        type: boolean
                      pushStocksAppIntegrationAccountId:
                        type: integer
                        nullable: true
                      channelIntegrationMapping:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      pullOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushStockIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushCostIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      tags:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      metafields:
                        type: array
                        description: Present when the relation is loaded. Channel-level settings/metadata key-value pairs.
                        items:
                          type: object
                          additionalProperties: true
                      isDropship:
                        type: boolean
                        nullable: true
                      dropshipSupplierId:
                        type: integer
                        nullable: true
                      dropshipPoDeliveryType:
                        type: string
                        nullable: true
                      dropshipPoDeliveryWarehouseId:
                        type: integer
                        nullable: true
                      dropshipAutoCreatePo:
                        type: boolean
                        nullable: true
                      dropshipAutoSendPo:
                        type: boolean
                        nullable: true
                      dropshipInventoryNotTracked:
                        type: boolean
                        nullable: true
                      autoPushOrderAfterMinutes:
                        type: integer
                        nullable: true
                      autoPushMode:
                        type: string
                        nullable: true
                      stockPushMaxQuantity:
                        type: integer
                        nullable: true
                        description: Channel-wide cap on the quantity pushed to the channel for any product. `null` = not set; products use their own value.
                      stockPushBufferQuantity:
                        type: integer
                        nullable: true
                        description: 'Channel-wide buffer held back from the pushed quantity, applied per `stockPushBufferType`. `null` = not set; products use their own value.'
                      stockPushBufferType:
                        type: string
                        nullable: true
                        enum:
                          - fixed
                          - percent
                        description: How `stockPushBufferQuantity` is applied — a fixed unit count or a percentage of available stock.
                      filters:
                        type: object
                        nullable: true
                        additionalProperties: true
                      restrictions:
                        type: object
                        nullable: true
                        additionalProperties: true
                      credentials:
                        type: object
                        nullable: true
                        additionalProperties: true
                      fees:
                        type: object
                        nullable: true
                        additionalProperties: true
                      createdAt:
                        type: integer
                        description: Unix timestamp
                      updatedAt:
                        type: integer
                        description: Unix timestamp
                      createdBy:
                        type: integer
                        nullable: true
                      updatedBy:
                        type: integer
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /channels/restriction-fields:
    get:
      operationId: getChannelRestrictionFields
      tags:
        - Channels
      summary: List channel restriction fields
      description: |
        Return the catalog of fields available for building channel restriction rules, along
        with the operators each field supports. Use this to construct a valid `restrictions`
        draft for `POST /channels/{channelId}/test-restrictions` or when configuring a channel.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Field definitions
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          example: shipTo.country
                        label:
                          type: string
                          example: Ship-to country
                        type:
                          type: string
                          enum:
                            - string
                            - number
                            - string_list
                        operators:
                          type: array
                          items:
                            type: string
                          example:
                            - equals
                            - not_equals
                            - in
                            - not_in
                            - contains
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/channels/{channelId}':
    get:
      operationId: getChannel
      tags:
        - Channels
      summary: Get channel
      description: 'Read full channel detail including loaded mappings, warehouse group, tags, and metafields. Always allowed.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: channelId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A sales, fulfillment, or end-to-end channel. Channels carry per-OMS configuration (pull orders, push orders,
                      push stocks, push costs) and an `apiLocked` flag — when locked, mutating operations through the external API
                      return 403.
                    properties:
                      id:
                        type: integer
                      uuid:
                        type: string
                      label:
                        type: string
                      description:
                        type: string
                        nullable: true
                      channelType:
                        type: string
                        enum:
                          - sales_channel
                          - fulfillment_channel
                          - end_to_end_channel
                      apiLocked:
                        type: boolean
                        description: 'When true, PUT/DELETE/integration-products operations on this channel are blocked via the external API.'
                      warehouseGroupId:
                        type: integer
                        nullable: true
                      warehouseGroup:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      storeType:
                        type: string
                        nullable: true
                      enabled:
                        type: boolean
                      status:
                        type: integer
                      isPOSChannel:
                        type: boolean
                        nullable: true
                      isCustomerSpecific:
                        type: boolean
                        nullable: true
                      pullOrdersFromOms:
                        type: boolean
                      getProductsEnabled:
                        type: boolean
                      pushInventoryEnabled:
                        type: boolean
                      includeIncomingStocksEnabled:
                        type: boolean
                      includeDraftProductsEnabled:
                        type: boolean
                        description: 'When stock push to the OMS is enabled, whether draft-status products are included in the stock push. Set via the `includeDraftProducts` key inside `pushStocksToOmsOptions` on channel create/update.'
                      pullStocksEnabled:
                        type: boolean
                      pullShipmentsEnabled:
                        type: boolean
                      pushIncomingStocksFromSupplierPurchaseOrderEnabled:
                        type: boolean
                      pushStocksAppIntegrationAccountId:
                        type: integer
                        nullable: true
                      channelIntegrationMapping:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      pullOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushStockIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushCostIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      tags:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      metafields:
                        type: array
                        description: Present when the relation is loaded. Channel-level settings/metadata key-value pairs.
                        items:
                          type: object
                          additionalProperties: true
                      isDropship:
                        type: boolean
                        nullable: true
                      dropshipSupplierId:
                        type: integer
                        nullable: true
                      dropshipPoDeliveryType:
                        type: string
                        nullable: true
                      dropshipPoDeliveryWarehouseId:
                        type: integer
                        nullable: true
                      dropshipAutoCreatePo:
                        type: boolean
                        nullable: true
                      dropshipAutoSendPo:
                        type: boolean
                        nullable: true
                      dropshipInventoryNotTracked:
                        type: boolean
                        nullable: true
                      autoPushOrderAfterMinutes:
                        type: integer
                        nullable: true
                      autoPushMode:
                        type: string
                        nullable: true
                      stockPushMaxQuantity:
                        type: integer
                        nullable: true
                        description: Channel-wide cap on the quantity pushed to the channel for any product. `null` = not set; products use their own value.
                      stockPushBufferQuantity:
                        type: integer
                        nullable: true
                        description: 'Channel-wide buffer held back from the pushed quantity, applied per `stockPushBufferType`. `null` = not set; products use their own value.'
                      stockPushBufferType:
                        type: string
                        nullable: true
                        enum:
                          - fixed
                          - percent
                        description: How `stockPushBufferQuantity` is applied — a fixed unit count or a percentage of available stock.
                      filters:
                        type: object
                        nullable: true
                        additionalProperties: true
                      restrictions:
                        type: object
                        nullable: true
                        additionalProperties: true
                      credentials:
                        type: object
                        nullable: true
                        additionalProperties: true
                      fees:
                        type: object
                        nullable: true
                        additionalProperties: true
                      createdAt:
                        type: integer
                        description: Unix timestamp
                      updatedAt:
                        type: integer
                        description: Unix timestamp
                      createdBy:
                        type: integer
                        nullable: true
                      updatedBy:
                        type: integer
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Channel not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateChannel
      tags:
        - Channels
      summary: Update channel
      description: |
        Update an existing channel. Validator uses **merge / PATCH semantics** — omitted keys are preserved.
        `channelType` cannot be changed once set (sending it returns 422).

        Returns **403** when the channel has `apiLocked: true`. Unlock via internal admin (`PATCH /api/v2/admin/channels/{id}/lock` with `apiLocked: false`) or the UI before retrying.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: channelId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                description:
                  type: string
                  nullable: true
                warehouseGroupId:
                  type: integer
                  nullable: true
                isCustomerSpecific:
                  type: boolean
                  nullable: true
                tagIds:
                  type: array
                  items:
                    type: integer
                pullOrdersFromOms:
                  type: boolean
                  nullable: true
                pullOrderAppIntegrationAccountId:
                  type: integer
                pullOrderOmsStoreId:
                  type: string
                pullOrdersFromOmsOptions:
                  type: object
                  additionalProperties: true
                pushOrdersToOms:
                  type: boolean
                  nullable: true
                pushOrderAppIntegrationAccountId:
                  type: integer
                pushOrderOmsStoreId:
                  type: string
                pushOrderIntegrationMappingId:
                  type: integer
                  nullable: true
                  description: Attach this `integration_mappings.id` as the channel's PUSH_ORDERS mapping. Omitted keys are preserved (PATCH semantics).
                pushStocksToOms:
                  type: boolean
                  nullable: true
                pushStocksAppIntegrationAccountId:
                  type: integer
                  nullable: true
                pushCostsToOms:
                  type: boolean
                  nullable: true
                isDropship:
                  type: boolean
                  nullable: true
                dropshipSupplierId:
                  type: integer
                  nullable: true
                dropshipInventoryNotTracked:
                  type: boolean
                  nullable: true
                stockPushMaxQuantity:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: Channel-wide cap on the quantity pushed to the channel for any product. Omit to leave unchanged; `null` clears it.
                stockPushBufferQuantity:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: Channel-wide buffer held back from the pushed quantity. Interpreted per `stockPushBufferType`. Omit to leave unchanged; `null` clears it.
                stockPushBufferType:
                  type: string
                  nullable: true
                  enum:
                    - fixed
                    - percent
                  description: How `stockPushBufferQuantity` is applied — a fixed unit count or a percentage of available stock. Omit to leave unchanged; `null` clears it.
                filters:
                  type: array
                  nullable: true
                  description: |
                    Incoming-order filters for the channel. Omit to leave unchanged. Each entry has a `key` (order field), a `condition`, and a `value`.
                    `condition` must be one of `EQ`, `NEQ`, `IN`, `NCON`, `EXACT_IN`, `IN_LIST` (the conditions the order
                    matcher evaluates); any other condition returns **422**.
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        example: source_name
                      condition:
                        type: string
                        enum:
                          - EQ
                          - NEQ
                          - IN
                          - NCON
                          - EXACT_IN
                          - IN_LIST
                      value:
                        description: Value to compare against.
                    additionalProperties: true
                invoiceBatchRunTime:
                  type: string
                  nullable: true
                  example: '18:00'
                  description: 'Time of day (`HH:mm`, 24-hour) the end-of-day invoice batch runs. Used when `invoiceCreateTiming` is `END_OF_DAY_BATCH`. Omit to leave unchanged; `null` clears it. Any other format returns **422**.'
                invoiceBatchTimezone:
                  type: string
                  nullable: true
                  example: America/Denver
                  description: IANA timezone for `invoiceBatchRunTime`. Omit to leave unchanged; `null` clears it. An unknown timezone returns **422**.
                invoiceCommsBatchRunTime:
                  type: string
                  nullable: true
                  example: '17:30'
                  description: 'Time of day (`HH:mm`, 24-hour) the invoice-communications batch runs, for channels whose `invoiceCreateTiming` is `INVOICE_AT_SHIPMENT_SEND_AT_BATCH` (invoices are created at shipment and sent in a batch). Omit to leave unchanged; `null` clears it.'
                invoiceCommsBatchTimezone:
                  type: string
                  nullable: true
                  example: America/Denver
                  description: IANA timezone for `invoiceCommsBatchRunTime`. Omit to leave unchanged; `null` clears it.
                invoiceCommsEmailEnabled:
                  type: boolean
                  nullable: true
                  description: Whether the invoice-communications batch emails invoices. Omit to leave unchanged.
                invoiceCommsQboEnabled:
                  type: boolean
                  nullable: true
                  description: Whether the invoice-communications batch pushes invoices to QuickBooks Online. Omit to leave unchanged.
                fulfilledExternally:
                  type: boolean
                  nullable: true
                  description: 'Orders on this channel are fulfilled by the marketplace (e.g. Amazon FBA, TikTok FBT), so Luminous does not create fulfillment orders for them. Omit to leave unchanged.'
                pushIncomingStocksFromSupplierPurchaseOrderEnabled:
                  type: boolean
                  nullable: true
                  description: Include incoming purchase-order stock in the stock pushed to the channel. Omit to leave unchanged.
                autoPushOrderAfterMinutes:
                  type: integer
                  nullable: true
                  minimum: 0
                  description: 'For channels without a push-order destination: minutes to wait before auto-pushing a new order. Omit to leave unchanged; `null` clears it.'
                autoPushMode:
                  type: string
                  nullable: true
                  enum:
                    - 'off'
                    - immediate
                    - pick_n_pack
                    - wave
                  description: 'For channels without a push-order destination: how new orders are auto-pushed. Omit to leave unchanged; `null` clears it. Any other value returns **422**.'
              additionalProperties: true
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A sales, fulfillment, or end-to-end channel. Channels carry per-OMS configuration (pull orders, push orders,
                      push stocks, push costs) and an `apiLocked` flag — when locked, mutating operations through the external API
                      return 403.
                    properties:
                      id:
                        type: integer
                      uuid:
                        type: string
                      label:
                        type: string
                      description:
                        type: string
                        nullable: true
                      channelType:
                        type: string
                        enum:
                          - sales_channel
                          - fulfillment_channel
                          - end_to_end_channel
                      apiLocked:
                        type: boolean
                        description: 'When true, PUT/DELETE/integration-products operations on this channel are blocked via the external API.'
                      warehouseGroupId:
                        type: integer
                        nullable: true
                      warehouseGroup:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      storeType:
                        type: string
                        nullable: true
                      enabled:
                        type: boolean
                      status:
                        type: integer
                      isPOSChannel:
                        type: boolean
                        nullable: true
                      isCustomerSpecific:
                        type: boolean
                        nullable: true
                      pullOrdersFromOms:
                        type: boolean
                      getProductsEnabled:
                        type: boolean
                      pushInventoryEnabled:
                        type: boolean
                      includeIncomingStocksEnabled:
                        type: boolean
                      includeDraftProductsEnabled:
                        type: boolean
                        description: 'When stock push to the OMS is enabled, whether draft-status products are included in the stock push. Set via the `includeDraftProducts` key inside `pushStocksToOmsOptions` on channel create/update.'
                      pullStocksEnabled:
                        type: boolean
                      pullShipmentsEnabled:
                        type: boolean
                      pushIncomingStocksFromSupplierPurchaseOrderEnabled:
                        type: boolean
                      pushStocksAppIntegrationAccountId:
                        type: integer
                        nullable: true
                      channelIntegrationMapping:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      pullOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushStockIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushCostIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      tags:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      metafields:
                        type: array
                        description: Present when the relation is loaded. Channel-level settings/metadata key-value pairs.
                        items:
                          type: object
                          additionalProperties: true
                      isDropship:
                        type: boolean
                        nullable: true
                      dropshipSupplierId:
                        type: integer
                        nullable: true
                      dropshipPoDeliveryType:
                        type: string
                        nullable: true
                      dropshipPoDeliveryWarehouseId:
                        type: integer
                        nullable: true
                      dropshipAutoCreatePo:
                        type: boolean
                        nullable: true
                      dropshipAutoSendPo:
                        type: boolean
                        nullable: true
                      dropshipInventoryNotTracked:
                        type: boolean
                        nullable: true
                      autoPushOrderAfterMinutes:
                        type: integer
                        nullable: true
                      autoPushMode:
                        type: string
                        nullable: true
                      stockPushMaxQuantity:
                        type: integer
                        nullable: true
                        description: Channel-wide cap on the quantity pushed to the channel for any product. `null` = not set; products use their own value.
                      stockPushBufferQuantity:
                        type: integer
                        nullable: true
                        description: 'Channel-wide buffer held back from the pushed quantity, applied per `stockPushBufferType`. `null` = not set; products use their own value.'
                      stockPushBufferType:
                        type: string
                        nullable: true
                        enum:
                          - fixed
                          - percent
                        description: How `stockPushBufferQuantity` is applied — a fixed unit count or a percentage of available stock.
                      filters:
                        type: object
                        nullable: true
                        additionalProperties: true
                      restrictions:
                        type: object
                        nullable: true
                        additionalProperties: true
                      credentials:
                        type: object
                        nullable: true
                        additionalProperties: true
                      fees:
                        type: object
                        nullable: true
                        additionalProperties: true
                      createdAt:
                        type: integer
                        description: Unix timestamp
                      updatedAt:
                        type: integer
                        description: Unix timestamp
                      createdBy:
                        type: integer
                        nullable: true
                      updatedBy:
                        type: integer
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Channel is api-locked
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Channel not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (e.g. attempting to change `channelType`, or a `filters[].condition` outside the allowed list)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteChannel
      tags:
        - Channels
      summary: Delete channel
      description: 'Soft-delete a channel. Returns **403** when `apiLocked: true`.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: channelId
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Deleted (no content)
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Channel is api-locked
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Channel not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/channels/{channelId}/lock':
    patch:
      operationId: lockChannel
      tags:
        - Channels
      summary: Lock channel
      description: |
        Set `apiLocked: true` on a channel to block subsequent external API mutations (`PUT`, `DELETE`,
        `POST /channels/{id}/integration-products`).

        The external API can **only** lock — sending `apiLocked: false` returns 422 with a fixed message
        (`"Channels can only be unlocked from the UI."`). To unlock, use the internal admin endpoint
        (`PATCH /api/v2/admin/channels/{id}/lock` with `apiLocked: false`) or the product UI.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: channelId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - apiLocked
              properties:
                apiLocked:
                  type: boolean
                  description: Must be `true`. Sending `false` returns 422.
      responses:
        '200':
          description: Locked
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: |
                      A sales, fulfillment, or end-to-end channel. Channels carry per-OMS configuration (pull orders, push orders,
                      push stocks, push costs) and an `apiLocked` flag — when locked, mutating operations through the external API
                      return 403.
                    properties:
                      id:
                        type: integer
                      uuid:
                        type: string
                      label:
                        type: string
                      description:
                        type: string
                        nullable: true
                      channelType:
                        type: string
                        enum:
                          - sales_channel
                          - fulfillment_channel
                          - end_to_end_channel
                      apiLocked:
                        type: boolean
                        description: 'When true, PUT/DELETE/integration-products operations on this channel are blocked via the external API.'
                      warehouseGroupId:
                        type: integer
                        nullable: true
                      warehouseGroup:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      storeType:
                        type: string
                        nullable: true
                      enabled:
                        type: boolean
                      status:
                        type: integer
                      isPOSChannel:
                        type: boolean
                        nullable: true
                      isCustomerSpecific:
                        type: boolean
                        nullable: true
                      pullOrdersFromOms:
                        type: boolean
                      getProductsEnabled:
                        type: boolean
                      pushInventoryEnabled:
                        type: boolean
                      includeIncomingStocksEnabled:
                        type: boolean
                      includeDraftProductsEnabled:
                        type: boolean
                        description: 'When stock push to the OMS is enabled, whether draft-status products are included in the stock push. Set via the `includeDraftProducts` key inside `pushStocksToOmsOptions` on channel create/update.'
                      pullStocksEnabled:
                        type: boolean
                      pullShipmentsEnabled:
                        type: boolean
                      pushIncomingStocksFromSupplierPurchaseOrderEnabled:
                        type: boolean
                      pushStocksAppIntegrationAccountId:
                        type: integer
                        nullable: true
                      channelIntegrationMapping:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      pullOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushOrderIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushStockIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      pushCostIntegrationMapping:
                        type: object
                        nullable: true
                        description: Present when the relation is loaded.
                        additionalProperties: true
                      tags:
                        type: array
                        description: Present when the relation is loaded.
                        items:
                          type: object
                          additionalProperties: true
                      metafields:
                        type: array
                        description: Present when the relation is loaded. Channel-level settings/metadata key-value pairs.
                        items:
                          type: object
                          additionalProperties: true
                      isDropship:
                        type: boolean
                        nullable: true
                      dropshipSupplierId:
                        type: integer
                        nullable: true
                      dropshipPoDeliveryType:
                        type: string
                        nullable: true
                      dropshipPoDeliveryWarehouseId:
                        type: integer
                        nullable: true
                      dropshipAutoCreatePo:
                        type: boolean
                        nullable: true
                      dropshipAutoSendPo:
                        type: boolean
                        nullable: true
                      dropshipInventoryNotTracked:
                        type: boolean
                        nullable: true
                      autoPushOrderAfterMinutes:
                        type: integer
                        nullable: true
                      autoPushMode:
                        type: string
                        nullable: true
                      stockPushMaxQuantity:
                        type: integer
                        nullable: true
                        description: Channel-wide cap on the quantity pushed to the channel for any product. `null` = not set; products use their own value.
                      stockPushBufferQuantity:
                        type: integer
                        nullable: true
                        description: 'Channel-wide buffer held back from the pushed quantity, applied per `stockPushBufferType`. `null` = not set; products use their own value.'
                      stockPushBufferType:
                        type: string
                        nullable: true
                        enum:
                          - fixed
                          - percent
                        description: How `stockPushBufferQuantity` is applied — a fixed unit count or a percentage of available stock.
                      filters:
                        type: object
                        nullable: true
                        additionalProperties: true
                      restrictions:
                        type: object
                        nullable: true
                        additionalProperties: true
                      credentials:
                        type: object
                        nullable: true
                        additionalProperties: true
                      fees:
                        type: object
                        nullable: true
                        additionalProperties: true
                      createdAt:
                        type: integer
                        description: Unix timestamp
                      updatedAt:
                        type: integer
                        description: Unix timestamp
                      createdBy:
                        type: integer
                        nullable: true
                      updatedBy:
                        type: integer
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Channel not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Tried to unlock via this endpoint
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/channels/{channelId}/integration-products':
    get:
      operationId: listChannelIntegrationProducts
      tags:
        - Channels
      summary: List channel integration products
      description: |
        List the channel SKU → Luminous SKU mappings on a sales or end-to-end channel: the read side of
        `POST /channels/{channelId}/integration-products`, using the same field names (the same rows as the
        Channel Products export). Results are ordered by id and paginated.

        `bufferQuantity`, `bufferType` and `maxPushQuantity` are the row's **own** values on this channel and are
        `null` when the row inherits from the product or channel defaults; the `effective*` fields show the values
        actually applied to stock pushes. A row can be posted back to the sync endpoint unchanged without pinning
        the inherited values.

        **Sales and end-to-end channels only** — returns 422 against fulfillment channels.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: channelId
          required: true
          schema:
            type: integer
        - in: query
          name: channelSku
          required: false
          description: Exact match on the channel SKU.
          schema:
            type: string
            maxLength: 255
        - in: query
          name: lumSku
          required: false
          description: Exact match on the mapped Luminous SKU. A channel-level remap takes precedence over the product's own Luminous SKU.
          schema:
            type: string
            maxLength: 255
        - in: query
          name: limit
          required: false
          description: Rows per page.
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - in: query
          name: page
          required: false
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: Paginated list of channel integration products
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        appIntegrationAccountId:
                          type: integer
                        channelSku:
                          type: string
                        channelProductName:
                          type: string
                        lumSku:
                          type: string
                          nullable: true
                        bufferQuantity:
                          type: number
                          nullable: true
                          description: This channel's own buffer; null when inherited.
                        bufferType:
                          type: string
                          enum:
                            - fixed
                            - percent
                          nullable: true
                          description: This channel's own buffer type; null when inherited.
                        maxPushQuantity:
                          type: integer
                          nullable: true
                          description: This channel's own max push quantity; null when inherited.
                        leadTimeDays:
                          type: integer
                          nullable: true
                        price:
                          type: number
                          nullable: true
                        gtin:
                          type: string
                          nullable: true
                        ignoreStock:
                          type: boolean
                        effectiveBufferQuantity:
                          type: number
                          nullable: true
                          description: 'Buffer actually applied to stock pushes (own, product, or channel default).'
                        effectiveBufferType:
                          type: string
                          enum:
                            - fixed
                            - percent
                          nullable: true
                        effectiveMaxPushQuantity:
                          type: integer
                          nullable: true
                          description: Max push quantity actually applied (own value or channel default).
                        lastPushedQuantity:
                          type: integer
                          nullable: true
                          description: Quantity last pushed to the channel for this SKU.
                        lastPushedAt:
                          type: string
                          nullable: true
                          description: 'When stock was last pushed for this SKU, in the app timezone.'
                  links:
                    type: object
                    additionalProperties: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Channel not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Invalid query parameter, or wrong channel type (sales or end-to-end channels only)'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: syncChannelIntegrationProducts
      tags:
        - Channels
      summary: Sync channel integration products
      description: |
        Bulk-create or update channel SKU → Luminous SKU mappings for a sales or end-to-end channel. Up to 500 items per call.
        Set `delete: true` on an item to remove its mapping.

        **Sales and end-to-end channels only** — returns 422 against fulfillment channels, and against an end-to-end
        channel that is not active. Returns **403** when the channel has `apiLocked: true`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: channelId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  minItems: 1
                  maxItems: 500
                  items:
                    type: object
                    required:
                      - appIntegrationAccountId
                      - channelSku
                      - channelProductName
                      - lumSku
                    properties:
                      appIntegrationAccountId:
                        type: integer
                      channelSku:
                        type: string
                        maxLength: 255
                      channelProductName:
                        type: string
                        maxLength: 500
                      lumSku:
                        type: string
                        maxLength: 255
                      bufferQuantity:
                        type: number
                        nullable: true
                      bufferType:
                        type: string
                        enum:
                          - fixed
                          - percent
                        nullable: true
                      maxPushQuantity:
                        type: integer
                        minimum: 0
                        nullable: true
                        description: 'Optional. Upper limit on the quantity pushed to the channel for this SKU. When set, the pushed available quantity is capped at this value (applied after any buffer). Null means no cap.'
                      leadTimeDays:
                        type: integer
                        minimum: 0
                        nullable: true
                      price:
                        type: number
                        nullable: true
                      gtin:
                        type: string
                        maxLength: 255
                        nullable: true
                      ignoreStock:
                        type: boolean
                        nullable: true
                      delete:
                        type: boolean
                        nullable: true
                        description: 'When true, remove this mapping instead of creating/updating it.'
      responses:
        '200':
          description: Synced
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Integration products synced.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: Channel is api-locked
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Channel not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, wrong channel type (sales or end-to-end channels only), or an inactive end-to-end channel'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/channels/{channelId}/test-restrictions':
    post:
      operationId: testChannelRestrictions
      tags:
        - Channels
      summary: Test channel restrictions against a sample order
      description: |
        Evaluate a channel's restriction rules against a sample order context and report
        whether the order would be **eligible** for that channel. Optionally send a
        `restrictions` draft to test unsaved rules instead of the channel's saved rules.

        Use `GET /channels/restriction-fields` to discover the available fields and operators.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: channelId
          required: true
          schema:
            type: integer
          description: Channel ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                restrictions:
                  type: array
                  nullable: true
                  description: Optional unsaved restriction ruleset to test instead of the channel's saved rules.
                  items:
                    type: object
                    additionalProperties: true
                country:
                  type: string
                  nullable: true
                  example: AE
                state:
                  type: string
                  nullable: true
                  example: Dubai
                postal_code:
                  type: string
                  nullable: true
                city:
                  type: string
                  nullable: true
                order_total:
                  type: number
                  nullable: true
                weight:
                  type: number
                  nullable: true
                currency:
                  type: string
                  nullable: true
                sku:
                  type: string
                  nullable: true
                tag_names:
                  type: array
                  nullable: true
                  items:
                    type: string
      responses:
        '200':
          description: Evaluation result
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      eligible:
                        type: boolean
                        description: True when the sample order passes the channel's restrictions.
                      reason_code:
                        type: string
                        nullable: true
                        description: Machine-readable code for the first failing rule (null when eligible).
                      message:
                        type: string
                        nullable: true
                        description: Human-readable explanation (null when eligible).
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Channel not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Invalid `restrictions` draft or sample payload
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration-accounts:
    get:
      operationId: listIntegrationAccounts
      tags:
        - Integration Accounts
      summary: List integration accounts
      description: |
        Paginated list of app integration accounts for this tenant. Returns `id`, `label`, `app`, and
        `status` (`connection_health_status`). **Credentials are never included.**
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
        - in: query
          name: per_page
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
        - in: query
          name: app
          schema:
            type: string
          description: 'Filter by integration app (e.g. `trackstar`, `shopify`).'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: App integration account without credentials.
                      properties:
                        id:
                          type: integer
                        label:
                          type: string
                        app:
                          type: string
                          description: 'Integration app identifier (e.g. `trackstar`, `shopify`).'
                        status:
                          type: string
                          nullable: true
                          description: 'Connection health status (`healthy`, `invalid_credentials`, `error`), or null if never checked.'
                  meta:
                    type: object
                    additionalProperties: true
                  links:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-accounts/{id}':
    get:
      operationId: getIntegrationAccount
      tags:
        - Integration Accounts
      summary: Get integration account
      description: |
        Returns `id`, `label`, `app`, and `status` for one integration account. **Credentials are never included.**
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: App integration account ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: App integration account without credentials.
                    properties:
                      id:
                        type: integer
                      label:
                        type: string
                      app:
                        type: string
                        description: 'Integration app identifier (e.g. `trackstar`, `shopify`).'
                      status:
                        type: string
                        nullable: true
                        description: 'Connection health status (`healthy`, `invalid_credentials`, `error`), or null if never checked.'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration account not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-accounts/{id}/shipping-methods':
    get:
      operationId: getIntegrationAccountShippingMethods
      tags:
        - Integration Accounts
      summary: List OMS shipping methods
      description: |
        Live-fetches available shipping methods from the destination OMS for the given
        integration account. Currently only TrackStar accounts are supported.

        The values in `id` (third-party shipping method ID) and `carrier` (code) are the
        same values you would set as targets when configuring carrier mappings in
        `integration/field-mappings`.

        When the WMS does not implement shipping methods (for example some Portless
        connections), the response is `422` with `code: not_supported_for_integration`.
        Use `GET /integration-mappings/schema` enums and examples instead of inventing IDs.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: App integration account ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Third-party (OMS) shipping method ID.
                        name:
                          type: string
                        carrier:
                          type: string
                          description: Carrier/code identifier.
                        description:
                          type: string
                          nullable: true
                        created_date:
                          type: string
                          format: date-time
                          nullable: true
                        updated_date:
                          type: string
                          format: date-time
                          nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration account not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Catalog is not supported for this integration
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  code:
                    type: string
                    description: Stable machine code. `not_supported_for_integration` when the OMS catalog cannot be listed.
                    example: not_supported_for_integration
  '/integration-accounts/{id}/warehouses':
    get:
      operationId: getIntegrationAccountWarehouses
      tags:
        - Integration Accounts
      summary: List OMS warehouses
      description: |
        Live-fetches warehouses from the destination OMS for the given integration account
        (TrackStar `GET /wms/warehouses`). Currently only TrackStar accounts are supported.

        When the WMS does not implement the catalog (for example some Portless connections),
        the response is `422` with `code: not_supported_for_integration`. Use
        `GET /integration-mappings/schema` enums and examples instead of inventing IDs.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: App integration account ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Third-party (OMS) warehouse ID.
                        name:
                          type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration account not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Catalog is not supported for this integration
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  code:
                    type: string
                    description: Stable machine code. `not_supported_for_integration` when the OMS catalog cannot be listed.
                    example: not_supported_for_integration
  '/integration-accounts/{id}/write-schema':
    get:
      operationId: getIntegrationAccountWriteSchema
      tags:
        - Integration Accounts
      summary: Get the write schema for a push action
      description: |
        Returns the write allow-list and destination JSON Schema for a push action on an integration account.
        Use this to discover which fields the connected system accepts (and their shapes) before calling a push
        endpoint such as `POST /products/{productId}/push`.

        Currently only `action=PUSH_PRODUCTS` is supported; any other action returns `422`. TrackStar-backed
        accounts additionally return live `write_operations` and `write_info` describing the create/update product
        operations. By default the schema is refreshed live from the third party — pass `refresh=false` to use the
        cached copy.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: App integration account ID.
        - in: query
          name: action
          required: true
          schema:
            type: string
            enum:
              - PUSH_PRODUCTS
          description: The push action to describe. Only `PUSH_PRODUCTS` is currently supported.
        - in: query
          name: refresh
          required: false
          schema:
            type: boolean
            default: true
          description: 'When `true` (default), fetches the latest schema live from the integration; `false` uses the cached copy.'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      integration_account_id:
                        type: integer
                      app:
                        type: string
                        description: Integration app identifier (e.g. `trackstar`).
                      integration_name:
                        type: string
                        nullable: true
                      available_actions:
                        type: array
                        items:
                          type: string
                        description: Actions the integration currently supports.
                      write_operations:
                        type: object
                        description: Create/update product write operations exposed by the integration.
                        properties:
                          create_product:
                            type: object
                            nullable: true
                            additionalProperties: true
                          update_product:
                            type: object
                            nullable: true
                            additionalProperties: true
                      write_info:
                        type: object
                        nullable: true
                        additionalProperties: true
                        description: Live product write metadata from the integration (present when refreshed).
                      destination_schema:
                        type: object
                        nullable: true
                        additionalProperties: true
                        description: JSON Schema for the destination push payload.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration account not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Unsupported action (only `PUSH_PRODUCTS` is supported today)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-accounts/{id}/oms-products':
    get:
      operationId: getIntegrationAccountOmsProducts
      tags:
        - Integration Accounts
      summary: List OMS product links
      description: |
        Lists the OMS product links for an integration account — the mapping between third-party (OMS/WMS)
        products and their Luminous SKUs. Optionally filter by third-party `sku` (exact match) or by
        `lum_sku_id`. Results are paginated and ordered most-recent first.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: App integration account ID.
        - in: query
          name: sku
          required: false
          schema:
            type: string
            maxLength: 255
          description: Filter by third-party (OMS) SKU (exact match).
        - in: query
          name: lum_sku_id
          required: false
          schema:
            type: integer
          description: Filter by the linked Luminous SKU (unit) ID.
        - in: query
          name: per_page
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
          description: Number of results per page (1–200).
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        sku:
                          type: string
                          nullable: true
                          description: Third-party (OMS) SKU.
                        product_id:
                          type: string
                          nullable: true
                          description: Third-party product ID.
                        variant_id:
                          type: string
                          nullable: true
                          description: Third-party variant ID.
                        inventory_item_id:
                          type: string
                          nullable: true
                          description: Third-party inventory item ID.
                        lum_sku_id:
                          type: integer
                          nullable: true
                          description: Linked Luminous SKU (unit) ID.
                        lum_status:
                          type: string
                          nullable: true
                          description: Link status on the Luminous side.
                        remote_status:
                          type: string
                          nullable: true
                          description: Product status reported by the third party.
                        published_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration account not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration-mappings:
    get:
      operationId: getIntegrationMappings
      tags:
        - Integration Mappings
      summary: List integration mappings
      description: |
        Get a paginated list of integration mappings.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
          description: Page number
        - in: query
          name: per_page
          schema:
            type: integer
          description: Number of results per page
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createIntegrationMapping
      tags:
        - Integration Mappings
      summary: Create an integration mapping
      description: |
        Create a new integration mapping.

        The `mapping_config` payload defines how source fields are transformed into the
        destination shape. See the [Integration Mapping Guide](/integration-mapping-guide)
        for the rule structure, field-path syntax, the full transformation catalogue, and
        fallback behavior.

        A mapping may optionally be seeded from an existing source record by passing one of
        the `source_*` foreign keys. `source_supplier_purchase_order_shipment_id` seeds the
        mapping from an inbound purchase-order shipment and is used together with
        `action: PUSH_INBOUND_SHIPMENT`. For inbound-shipment mappings you may pass
        `source_supplier_purchase_order_shipment_id` on its own — `source_purchase_order_id`
        is then inferred from the shipment's linked purchase-order items (the majority PO).
        The request is rejected if the shipment has no linked purchase-order items.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              required:
                - name
                - action
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Human-readable name for the mapping.
                description:
                  type: string
                  nullable: true
                action:
                  type: string
                  enum:
                    - PUSH_ORDERS
                    - PUSH_PRODUCTS
                    - PUSH_INBOUND_SHIPMENT
                  description: What the mapping transforms.
                source_type:
                  type: string
                  nullable: true
                  enum:
                    - FULFILLMENT_ORDER
                    - PRODUCT
                    - PURCHASE_ORDER
                  description: Type of record the mapping reads from.
                source_integration_account_id:
                  type: integer
                  nullable: true
                  description: Integration account the source payload comes from.
                destination_integration_account_id:
                  type: integer
                  nullable: true
                  description: Integration account the transformed payload is pushed to.
                source_order_id:
                  type: integer
                  nullable: true
                  description: Seed the mapping from an existing fulfillment order.
                source_product_id:
                  type: integer
                  nullable: true
                  description: Seed the mapping from an existing product.
                source_purchase_order_id:
                  type: integer
                  nullable: true
                  description: |
                    Seed the mapping from an existing purchase order. For
                    `PUSH_INBOUND_SHIPMENT` mappings this may be omitted when
                    `source_supplier_purchase_order_shipment_id` is provided — it is then
                    inferred from the shipment's majority linked purchase-order items.
                source_supplier_purchase_order_shipment_id:
                  type: integer
                  nullable: true
                  description: |
                    Seed the mapping from an existing inbound purchase-order shipment.
                    Used with `action: PUSH_INBOUND_SHIPMENT`. May be supplied without
                    `source_purchase_order_id`, in which case the purchase order is inferred
                    from the shipment's linked purchase-order items; the request is rejected
                    if the shipment has none.
                mapping_config:
                  type: array
                  nullable: true
                  description: |
                    Transformation rules. See the
                    [Integration Mapping Guide](/integration-mapping-guide) for the rule
                    structure and field-path syntax.
                  items:
                    type: object
                source_schema:
                  type: array
                  nullable: true
                  items:
                    type: object
                destination_schema:
                  type: array
                  nullable: true
                  items:
                    type: object
                is_active:
                  type: boolean
                  nullable: true
                operation_type:
                  type: string
                  nullable: true
                  enum:
                    - CREATE
                    - UPDATE
                    - BOTH
                  description: |
                    Which product-push operation this mapping applies to. Only meaningful for
                    `PUSH_PRODUCTS` mappings — it lets a channel use different field mappings when
                    creating a product versus updating one. Defaults to `BOTH` when omitted.
      responses:
        '201':
          description: Integration mapping created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration-mappings/transformations:
    get:
      operationId: getIntegrationMappingTransformations
      tags:
        - Integration Mappings
      summary: List available transformations
      description: |
        Return every transformation the mapping engine can execute, with the shape of each
        one's `transformationConfig`. The mapping editor renders directly from this catalogue,
        and it is parity-tested against the transformation engine, so this list is exactly what
        will run — never more, never less.

        Some entries carry an `aliases` array of legacy identifiers that resolve to that type
        (for example `round` accepts the legacy `roundToInt`). The engine accepts aliases on
        input; the canonical `type` is what should be stored going forward.

        Entries with `advanced: true` (such as `jsonExtract` and `customFunction`) are powerful
        and should be gated in customer-facing UI.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          description: Canonical transformation identifier used in `mapping_config`.
                        label:
                          type: string
                          description: Human-readable name for the transformation.
                        description:
                          type: string
                        group:
                          type: string
                          description: Grouping used by the editor.
                          enum:
                            - text
                            - number
                            - date
                            - lookup
                            - convert
                            - advanced
                        advanced:
                          type: boolean
                          description: Whether the transformation is advanced/powerful and should be gated in customer-facing UI.
                        note:
                          type: string
                          nullable: true
                        aliases:
                          type: array
                          nullable: true
                          description: Legacy identifiers that resolve to this `type`.
                          items:
                            type: string
                        config:
                          type: array
                          description: Settings the transformation accepts. Empty when the transformation takes no configuration.
                          items:
                            type: object
                            properties:
                              key:
                                type: string
                                description: Config key stored under `transformationConfig`.
                              label:
                                type: string
                              type:
                                type: string
                                description: Rendering hint for the setting.
                                enum:
                                  - string
                                  - number
                                  - boolean
                                  - select
                                  - keyValue
                                  - code
                                  - json
                              required:
                                type: boolean
                              default:
                                nullable: true
                                description: Default value used when the setting is omitted.
                              help:
                                type: string
                                nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-mappings/{id}':
    get:
      operationId: getIntegrationMappingById
      tags:
        - Integration Mappings
      summary: Get an integration mapping
      description: |
        Get details of a specific integration mapping by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    description: 'Integration mapping record. Source-linkage fields are listed below; additional fields (`name`, `action`, `mapping_config`, timestamps, etc.) are also returned.'
                    properties:
                      id:
                        type: integer
                      operation_type:
                        type: string
                        nullable: true
                        enum:
                          - CREATE
                          - UPDATE
                          - BOTH
                        description: Which product-push operation this mapping applies to (`PUSH_PRODUCTS` mappings only). `null` for other actions.
                      source_order_id:
                        type: integer
                        nullable: true
                      source_product_id:
                        type: integer
                        nullable: true
                      source_purchase_order_id:
                        type: integer
                        nullable: true
                      source_supplier_purchase_order_shipment_id:
                        type: integer
                        nullable: true
                        description: Inbound purchase-order shipment the mapping is sourced from (for `PUSH_INBOUND_SHIPMENT` mappings).
                      source_supplier_purchase_order_shipment:
                        type: object
                        nullable: true
                        description: Present only when the relation is loaded.
                        properties:
                          id:
                            type: integer
                          reference_number:
                            type: string
                            nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: updateIntegrationMapping
      tags:
        - Integration Mappings
      summary: Update an integration mapping
      description: |
        Update an existing integration mapping by ID.

        When changing `mapping_config`, see the [Integration Mapping Guide](/integration-mapping-guide)
        for the rule structure, field-path syntax, the full transformation catalogue, and
        fallback behavior.

        At most one of `source_order_id`, `source_product_id`, or `source_purchase_order_id`
        may be set on a single request. `source_supplier_purchase_order_shipment_id` links the
        mapping to an inbound purchase-order shipment (for `PUSH_INBOUND_SHIPMENT` mappings).
        On these inbound-shipment mappings, updating `source_supplier_purchase_order_shipment_id`
        alone re-infers `source_purchase_order_id` from the shipment's linked purchase-order
        items (the majority PO); the request is rejected if the shipment has none.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              properties:
                name:
                  type: string
                  maxLength: 255
                description:
                  type: string
                  nullable: true
                source_order_id:
                  type: integer
                  nullable: true
                  description: Source fulfillment order. Mutually exclusive with the other two `source_*` order fields.
                source_product_id:
                  type: integer
                  nullable: true
                  description: Source product. Mutually exclusive with the other two `source_*` order fields.
                source_purchase_order_id:
                  type: integer
                  nullable: true
                  description: Source purchase order. Mutually exclusive with the other two `source_*` order fields.
                source_supplier_purchase_order_shipment_id:
                  type: integer
                  nullable: true
                  description: Inbound purchase-order shipment the mapping is sourced from (for `PUSH_INBOUND_SHIPMENT` mappings). Setting this without `source_purchase_order_id` infers the purchase order from the shipment's linked purchase-order items; the request is rejected if the shipment has none.
                mapping_config:
                  type: array
                  nullable: true
                  items:
                    type: object
                is_active:
                  type: boolean
                  nullable: true
                operation_type:
                  type: string
                  nullable: true
                  enum:
                    - CREATE
                    - UPDATE
                    - BOTH
                  description: |
                    Which product-push operation this mapping applies to (`PUSH_PRODUCTS` mappings
                    only) — lets a channel use different field mappings when creating a product
                    versus updating one. Defaults to `BOTH`.
                restored_from_version_id:
                  type: integer
                  nullable: true
                  description: 'When this save restores an earlier version, set this to that version''s `id` (from `GET /integration-mappings/{id}/versions`) to tag the recorded snapshot as a restore. Leave unset for normal edits.'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    description: 'Updated integration mapping record (same shape as `GET /integration-mappings/{id}`).'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteIntegrationMapping
      tags:
        - Integration Mappings
      summary: Delete an integration mapping
      description: |
        Delete an integration mapping by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
      responses:
        '200':
          description: Integration mapping deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-mappings/{id}/preview':
    post:
      operationId: previewIntegrationMapping
      tags:
        - Integration Mappings
      summary: Preview a mapping (dry run)
      description: |
        Run the mapping's stored source sample (`source_order_json`) through the same
        transformation engine the push path uses, and return what the destination would
        receive. **This makes no OMS call and writes nothing** — it is how a mapping gets
        tested without pushing a real order.

        Pass `mapping_config` to preview unsaved edits from the mapping editor; omit it to
        preview the stored config. Pass `fulfillment_order_id` to dry-run against a live
        fulfillment order sample instead of the stored `source_order_json` — that sample is
        **not** persisted on the mapping.

        The returned `output` omits nulls and empty strings, matching what the push path sends.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                mapping_config:
                  type: array
                  description: Config to preview. Omit to preview the stored config. Each row requires a `pushField`.
                  items:
                    type: object
                    required:
                      - pushField
                    properties:
                      lumField:
                        type: string
                        description: Source field path.
                      pushField:
                        type: string
                        description: Destination field path.
                      transformation:
                        type: string
                        nullable: true
                      transformationConfig:
                        type: object
                        nullable: true
                fulfillment_order_id:
                  type: integer
                  nullable: true
                  description: Fulfillment order ID (`sales_orders_shipments.id`) to extract a live source sample from. Omit to use the mapping's stored `source_order_json`. Does not write to the mapping.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      output:
                        type: object
                        additionalProperties: true
                        description: 'The destination payload the mapping would produce. Nulls and empty strings are omitted, matching the push path.'
                      rows:
                        type: array
                        description: Per-row outcome of running each mapping rule.
                        items:
                          type: object
                          properties:
                            index:
                              type: integer
                            lumField:
                              type: string
                              nullable: true
                            pushField:
                              type: string
                            status:
                              type: string
                              description: |
                                Row outcome:
                                - `ok` — resolved to a usable value.
                                - `empty` — ran without error but resolved to null/empty; nothing written.
                                - `error` — the row threw; `message` explains why. The rest of the mapping still ran.
                              enum:
                                - ok
                                - empty
                                - error
                            message:
                              type: string
                              nullable: true
                            resolvedValue:
                              nullable: true
                              description: The value written for this row (null when `empty` or `error`).
                      summary:
                        type: object
                        properties:
                          total:
                            type: integer
                          ok:
                            type: integer
                          empty:
                            type: integer
                          error:
                            type: integer
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The mapping has no source sample yet — set `source_order_id` (or the product / purchase-order shipment equivalent) first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-mappings/{id}/versions':
    get:
      operationId: listIntegrationMappingVersions
      tags:
        - Integration Mappings
      summary: List a mapping's version history
      description: |
        List the version-history snapshots recorded for an integration mapping, newest first.

        A new snapshot is recorded automatically each time a mapping is saved. To restore an
        earlier version, load it with `GET /integration-mappings/{id}/versions/{versionId}`,
        apply its `mapping_config` back onto the mapping via
        `POST /integration-mappings/{id}`, and set `restored_from_version_id` on that update to
        tag the new snapshot as a restore.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A single version-history snapshot of an integration mapping. A new snapshot is recorded automatically every time a mapping is saved; the version endpoints let you list them and load an earlier one back into the editor.
                      properties:
                        id:
                          type: integer
                        integration_mapping_id:
                          type: integer
                          description: The mapping this snapshot belongs to.
                        version_number:
                          type: integer
                          description: Monotonically increasing version number; the highest number is the current mapping.
                        name:
                          type: string
                          nullable: true
                          description: The mapping's `name` at the time this snapshot was recorded.
                        description:
                          type: string
                          nullable: true
                          description: The mapping's `description` at the time this snapshot was recorded.
                        mapping_config:
                          type: array
                          nullable: true
                          description: 'The full mapping rule set captured in this snapshot, decoded from storage. Same shape as `mapping_config` on the mapping itself — see the [Integration Mapping Guide](/integration-mapping-guide) for the rule structure.'
                          items:
                            type: object
                        is_active:
                          type: boolean
                          description: Whether the mapping was active at the time this snapshot was recorded.
                        restored_from_version_id:
                          type: integer
                          nullable: true
                          description: 'When this snapshot was produced by restoring an earlier version, the `id` of the version it was restored from; `null` for snapshots saved from normal edits.'
                        created_by:
                          type: integer
                          nullable: true
                          description: ID of the user who saved this version.
                        created_by_user:
                          type: object
                          nullable: true
                          description: The user who saved this version.
                          properties:
                            id:
                              type: integer
                            full_name:
                              type: string
                              nullable: true
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: When this version was recorded.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration mapping not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-mappings/{id}/versions/{versionId}':
    get:
      operationId: getIntegrationMappingVersion
      tags:
        - Integration Mappings
      summary: Get a single mapping version
      description: |
        Get one version-history snapshot, including its full `mapping_config`, for diffing
        against the current mapping or loading back into the editor.

        To restore this version, apply its `mapping_config` back onto the mapping via
        `POST /integration-mappings/{id}` and set `restored_from_version_id` to this version's
        `id` so the resulting snapshot is tagged as a restore.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
        - in: path
          name: versionId
          required: true
          schema:
            type: integer
          description: Version snapshot ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A single version-history snapshot of an integration mapping. A new snapshot is recorded automatically every time a mapping is saved; the version endpoints let you list them and load an earlier one back into the editor.
                    properties:
                      id:
                        type: integer
                      integration_mapping_id:
                        type: integer
                        description: The mapping this snapshot belongs to.
                      version_number:
                        type: integer
                        description: Monotonically increasing version number; the highest number is the current mapping.
                      name:
                        type: string
                        nullable: true
                        description: The mapping's `name` at the time this snapshot was recorded.
                      description:
                        type: string
                        nullable: true
                        description: The mapping's `description` at the time this snapshot was recorded.
                      mapping_config:
                        type: array
                        nullable: true
                        description: 'The full mapping rule set captured in this snapshot, decoded from storage. Same shape as `mapping_config` on the mapping itself — see the [Integration Mapping Guide](/integration-mapping-guide) for the rule structure.'
                        items:
                          type: object
                      is_active:
                        type: boolean
                        description: Whether the mapping was active at the time this snapshot was recorded.
                      restored_from_version_id:
                        type: integer
                        nullable: true
                        description: 'When this snapshot was produced by restoring an earlier version, the `id` of the version it was restored from; `null` for snapshots saved from normal edits.'
                      created_by:
                        type: integer
                        nullable: true
                        description: ID of the user who saved this version.
                      created_by_user:
                        type: object
                        nullable: true
                        description: The user who saved this version.
                        properties:
                          id:
                            type: integer
                          full_name:
                            type: string
                            nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: When this version was recorded.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Mapping or version not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-mappings/{id}/ai/auto-map':
    post:
      operationId: aiAutoMapIntegrationMapping
      tags:
        - Integration Mappings
      summary: AI auto-map a mapping
      description: |
        Propose a full set of mapping rows from the mapping's source and destination schemas.

        **Returns a proposal only** — nothing is saved. Every proposed row is validated against
        the transformation catalogue and the two schemas before being returned, so the model
        cannot introduce a transformation the engine can't run. Rows that fail validation are
        dropped and listed in `rejected`, so a silent omission is never mistaken for a
        deliberate choice.

        Requires AI to be configured on the environment.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                instruction:
                  type: string
                  nullable: true
                  maxLength: 2000
                  description: Optional guidance to steer the proposed mapping.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      rows:
                        type: array
                        description: 'The proposed mapping rows. For `ai/edit` this is the complete updated list, not just the changes.'
                        items:
                          type: object
                          properties:
                            lumField:
                              type: string
                              nullable: true
                              description: Source field path.
                            pushField:
                              type: string
                              description: Destination field path.
                            transformation:
                              type: string
                              nullable: true
                              description: Transformation `type` from the transformation catalogue.
                            transformationConfig:
                              type: object
                              nullable: true
                              description: Settings for the transformation.
                      notes:
                        type: string
                        nullable: true
                        description: A short explanation of what the model proposed.
                      rejected:
                        type: array
                        description: 'Rows that validation dropped, so a silent omission is never mistaken for a deliberate choice. Rows are rejected for an unknown transformation, a transformation missing required settings, no destination field, no source and no static value, or an array source mapped onto a single destination field.'
                        items:
                          type: object
                          properties:
                            index:
                              type: integer
                            row:
                              type: object
                              additionalProperties: true
                            reason:
                              type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Bad request — for example the mapping has no destination schema to map on to.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '503':
          description: 'AI is not configured on the environment, or the model could not be reached / parsed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-mappings/{id}/ai/edit':
    post:
      operationId: aiEditIntegrationMapping
      tags:
        - Integration Mappings
      summary: AI edit a mapping
      description: |
        Apply a natural-language change to the rows the editor currently has (saved or not) and
        return the complete updated row list; the editor diffs it against what is on screen.

        **Returns a proposal only** — nothing is saved. Every proposed row is validated against
        the transformation catalogue and the two schemas before being returned. Rows that fail
        validation are dropped and listed in `rejected`.

        Requires AI to be configured on the environment.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - instruction
              properties:
                instruction:
                  type: string
                  maxLength: 2000
                  description: The natural-language change to apply to the rows.
                mapping_config:
                  type: array
                  description: The rows to edit. Omit to edit the mapping's stored rows.
                  items:
                    type: object
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      rows:
                        type: array
                        description: 'The proposed mapping rows. For `ai/edit` this is the complete updated list, not just the changes.'
                        items:
                          type: object
                          properties:
                            lumField:
                              type: string
                              nullable: true
                              description: Source field path.
                            pushField:
                              type: string
                              description: Destination field path.
                            transformation:
                              type: string
                              nullable: true
                              description: Transformation `type` from the transformation catalogue.
                            transformationConfig:
                              type: object
                              nullable: true
                              description: Settings for the transformation.
                      notes:
                        type: string
                        nullable: true
                        description: A short explanation of what the model proposed.
                      rejected:
                        type: array
                        description: 'Rows that validation dropped, so a silent omission is never mistaken for a deliberate choice. Rows are rejected for an unknown transformation, a transformation missing required settings, no destination field, no source and no static value, or an array source mapped onto a single destination field.'
                        items:
                          type: object
                          properties:
                            index:
                              type: integer
                            row:
                              type: object
                              additionalProperties: true
                            reason:
                              type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Missing instruction, or the mapping has no destination schema to map on to.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '503':
          description: 'AI is not configured on the environment, or the model could not be reached / parsed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration-mappings/{id}/ai/script':
    post:
      operationId: aiScriptIntegrationMapping
      tags:
        - Integration Mappings
      summary: AI draft a custom-function script
      description: |
        Draft a `customFunction` transformation script from a natural-language description.

        **Returns a proposal only** — nothing is saved, and the drafted code still passes
        through the usual conversion and security validation (risk-scored by the code security
        validator) before it can execute.

        Requires AI to be configured on the environment.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration mapping ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - instruction
              properties:
                instruction:
                  type: string
                  maxLength: 2000
                  description: Description of what the script should do.
                sample_value:
                  nullable: true
                  description: Optional sample input value to draft the script against.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      code:
                        type: string
                        description: The drafted script body.
                      notes:
                        type: string
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Missing instruction, or the request is otherwise invalid.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '503':
          description: 'AI is not configured on the environment, or the model could not be reached / parsed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings:
    get:
      operationId: getIntegrationFieldMappings
      tags:
        - Integration Field Mappings
      summary: List integration field mappings
      description: |
        Get a list of integration field mappings with optional filtering.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: app_integration_account_id
          schema:
            type: integer
          description: Filter by integration account ID
        - in: query
          name: field_name
          schema:
            type: string
          description: Filter by field name
        - in: query
          name: mapping_group
          schema:
            type: string
          description: Filter by mapping group
        - in: query
          name: global_only
          schema:
            type: boolean
          description: Return only global mappings (no account-specific)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createIntegrationFieldMapping
      tags:
        - Integration Field Mappings
      summary: Create an integration field mapping
      description: |
        Create a new integration field mapping.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - field_name
                - luminous_value
                - external_value
              properties:
                app_integration_account_id:
                  type: integer
                  nullable: true
                  description: Integration account ID (null for global mappings)
                field_name:
                  type: string
                  description: The field name to map
                luminous_value:
                  type: string
                  description: The Luminous-side value
                external_value:
                  type: string
                  description: The external system value
                mapping_group:
                  type: string
                  description: Optional mapping group
                is_active:
                  type: boolean
                  description: Whether the mapping is active
                priority:
                  type: integer
                  description: Priority order
                notes:
                  type: string
                  description: Optional notes
      responses:
        '201':
          description: Integration field mapping created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings/bulk:
    post:
      operationId: bulkCreateIntegrationFieldMappings
      tags:
        - Integration Field Mappings
      summary: Bulk create integration field mappings
      description: |
        Create multiple integration field mappings in a single request.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - mappings
              properties:
                mappings:
                  type: array
                  items:
                    type: object
                    required:
                      - field_name
                      - luminous_value
                      - external_value
                    properties:
                      app_integration_account_id:
                        type: integer
                        nullable: true
                        description: Integration account ID (null for global mappings)
                      field_name:
                        type: string
                        description: The field name to map
                      luminous_value:
                        type: string
                        description: The Luminous-side value
                      external_value:
                        type: string
                        description: The external system value
                      mapping_group:
                        type: string
                        description: Optional mapping group
                      is_active:
                        type: boolean
                        description: Whether the mapping is active
                      priority:
                        type: integer
                        description: Priority order
                      notes:
                        type: string
                        description: Optional notes
      responses:
        '201':
          description: Integration field mappings created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings/groups:
    get:
      operationId: getIntegrationFieldMappingGroups
      tags:
        - Integration Field Mappings
      summary: List mapping groups
      description: |
        Get a list of distinct mapping group values.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: app_integration_account_id
          schema:
            type: integer
          description: Filter by integration account ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings/fields:
    get:
      operationId: getIntegrationFieldMappingFields
      tags:
        - Integration Field Mappings
      summary: List mapping field names
      description: |
        Get a list of distinct field name values.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: app_integration_account_id
          schema:
            type: integer
          description: Filter by integration account ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings/quick-add:
    post:
      operationId: quickAddIntegrationFieldMappings
      tags:
        - Integration Field Mappings
      summary: Quick-add field mappings from recent orders
      description: |
        Seeds self-mappings from recent orders. Analyzes recent order data to automatically
        create field mappings where the Luminous value matches the external value.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                app_integration_account_id:
                  type: integer
                  description: Integration account ID
                days:
                  type: integer
                  maximum: 90
                  description: Number of days of recent orders to analyze (max 90)
                limit:
                  type: integer
                  maximum: 500
                  description: Maximum number of mappings to create (max 500)
                dry_run:
                  type: boolean
                  description: 'If true, returns what would be created without persisting'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings/bulk-delete:
    post:
      operationId: bulkDeleteIntegrationFieldMappings
      tags:
        - Integration Field Mappings
      summary: Bulk delete integration field mappings
      description: |
        Delete multiple integration field mappings by their IDs.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ids
              properties:
                ids:
                  type: array
                  items:
                    type: integer
                  description: Array of integration field mapping IDs to delete
      responses:
        '200':
          description: Integration field mappings deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings/suggest-carrier:
    post:
      operationId: suggestCarrierMapping
      tags:
        - Integration Field Mappings
      summary: Suggest carrier mapping
      description: |
        Fuzzy match a carrier value to Trackstar schema carrier enums. Returns suggested
        mappings based on the provided carrier value.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - app_integration_account_id
                - carrier_value
              properties:
                app_integration_account_id:
                  type: integer
                  description: Integration account ID
                carrier_value:
                  type: string
                  description: The carrier value to match
                field_name:
                  type: string
                  enum:
                    - carrier
                    - carrier_name
                    - shipping_method_name
                    - shipping_method
                  description: The field name to match against
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings/create-and-retry:
    post:
      operationId: createAndRetryIntegrationFieldMapping
      tags:
        - Integration Field Mappings
      summary: Create mapping and retry fulfillment
      description: |
        Creates a new field mapping and may retry the fulfillment push for the
        associated sales order.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - app_integration_account_id
                - field_name
                - luminous_value
                - external_value
              properties:
                app_integration_account_id:
                  type: integer
                  description: Integration account ID
                field_name:
                  type: string
                  description: The field name to map
                luminous_value:
                  type: string
                  description: The Luminous-side value
                external_value:
                  type: string
                  description: The external system value
                sales_order_id:
                  type: integer
                  description: Sales order ID to retry fulfillment push for
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /integration/field-mappings/auto-carrier-mapping:
    post:
      operationId: toggleAutoCarrierMapping
      tags:
        - Integration Field Mappings
      summary: Toggle auto carrier mapping
      description: |
        Toggles the auto carrier mapping setting for an integration account.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - app_integration_account_id
                - enabled
              properties:
                app_integration_account_id:
                  type: integer
                  description: Integration account ID
                enabled:
                  type: boolean
                  description: Whether to enable or disable auto carrier mapping
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/integration/field-mappings/{id}':
    get:
      operationId: getIntegrationFieldMappingById
      tags:
        - Integration Field Mappings
      summary: Get an integration field mapping
      description: |
        Get details of a specific integration field mapping by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration field mapping ID
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration field mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateIntegrationFieldMapping
      tags:
        - Integration Field Mappings
      summary: Update an integration field mapping
      description: |
        Update an existing integration field mapping by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration field mapping ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - field_name
                - luminous_value
                - external_value
              properties:
                app_integration_account_id:
                  type: integer
                  nullable: true
                  description: Integration account ID (null for global mappings)
                field_name:
                  type: string
                  description: The field name to map
                luminous_value:
                  type: string
                  description: The Luminous-side value
                external_value:
                  type: string
                  description: The external system value
                mapping_group:
                  type: string
                  description: Optional mapping group
                is_active:
                  type: boolean
                  description: Whether the mapping is active
                priority:
                  type: integer
                  description: Priority order
                notes:
                  type: string
                  description: Optional notes
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration field mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteIntegrationFieldMapping
      tags:
        - Integration Field Mappings
      summary: Delete an integration field mapping
      description: |
        Delete an integration field mapping by ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Integration field mapping ID
      responses:
        '200':
          description: Integration field mapping deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Integration field mapping not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /work-orders:
    get:
      operationId: listWorkOrders
      tags:
        - Work Orders
      summary: List work orders
      description: 'Return a paginated list of work orders, with optional filtering, sorting, and search.'
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          description: Page number to retrieve.
          schema:
            type: integer
            default: 1
        - in: query
          name: limit
          description: Number of records per page.
          schema:
            type: integer
            default: 25
        - in: query
          name: sort_by
          description: Field to sort the results by.
          schema:
            type: string
        - in: query
          name: sort_direction
          description: Direction to sort the results.
          schema:
            type: string
            enum:
              - asc
              - desc
        - in: query
          name: search
          description: Free-text search across work orders.
          schema:
            type: string
        - in: query
          name: status
          description: 'Comma-separated list of statuses to filter by (e.g. `status=draft,in_progress`; `status[]=...` and `status[in]=...` are equivalent). Use `status[notin]=...` to exclude work orders in the listed statuses instead (e.g. `status[notin]=completed,cancelled`).'
          schema:
            type: string
        - in: query
          name: produced_sku_id
          description: Filter by the SKU being produced.
          schema:
            type: integer
        - in: query
          name: vendor_name
          description: Filter by vendor name.
          schema:
            type: string
        - in: query
          name: production_warehouse_id
          description: Filter by the production warehouse.
          schema:
            type: integer
        - in: query
          name: destination_warehouse_id
          description: Filter by the destination warehouse.
          schema:
            type: integer
        - in: query
          name: work_order_number
          description: Filter by work order number.
          schema:
            type: string
        - in: query
          name: alternate_id
          description: Filter by alternate identifier.
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        work_order_number:
                          type: string
                        status:
                          type: string
                          description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                        is_on_hold:
                          type: boolean
                        produced_sku_id:
                          type: integer
                          nullable: true
                          description: ID of the SKU (request_for_quotes record) being produced.
                        produced_sku:
                          type: object
                          nullable: true
                          description: Present only when the producedSku relation is loaded.
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                            description:
                              type: string
                              nullable: true
                        planned_qty:
                          type: number
                          description: Quantity planned to be produced.
                        completion_trigger:
                          type: string
                          nullable: true
                          description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                          enum:
                            - manual
                            - finish_step
                            - receipt
                        expected_completion_date:
                          type: string
                          format: date
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        production_warehouse_id:
                          type: integer
                          nullable: true
                        production_warehouse:
                          type: object
                          nullable: true
                          description: Present only when the productionWarehouse relation is loaded.
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        destination_warehouse_id:
                          type: integer
                          nullable: true
                        destination_warehouse:
                          type: object
                          nullable: true
                          description: Present only when the destinationWarehouse relation is loaded.
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        vendor_id:
                          type: integer
                          nullable: true
                          description: Co-manufacturer (subcontract) vendor ID.
                        co_manufacturer_id:
                          type: integer
                          nullable: true
                          description: Alias of `vendor_id` (always the same value).
                        vendor:
                          type: object
                          nullable: true
                          description: Present only when the vendor relation is loaded.
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        co_manufacturer:
                          type: object
                          nullable: true
                          description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        bom_id:
                          type: integer
                          nullable: true
                        work_order_kind:
                          type: string
                          enum:
                            - build
                            - service
                          description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                        service_unit_price:
                          type: number
                          nullable: true
                          description: Per-unit service fee for subcontract production.
                        cost_rule_resolution:
                          type: object
                          nullable: true
                          description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                          properties:
                            used_cost_rule:
                              type: boolean
                              description: True when a cost rule produced the price; false for a fallback resolution.
                            cost_rule_id:
                              type: integer
                              nullable: true
                            cost_rule_name:
                              type: string
                              nullable: true
                            resolved_unit_cost:
                              type: number
                              nullable: true
                              description: The per-unit cost the engine resolved to.
                            fallback_source:
                              type: string
                              nullable: true
                              description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                            tier_min_qty:
                              type: number
                              nullable: true
                              description: Minimum quantity of the matched cost-rule tier.
                            breakdown:
                              type: array
                              description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                              items:
                                type: object
                                properties:
                                  effect:
                                    type: string
                                    description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                  description:
                                    type: string
                                    nullable: true
                                  amount:
                                    type: string
                                    description: 'The step''s amount, as a string. Defaults to `0`.'
                                  delta:
                                    type: string
                                    description: 'Change applied at this step, as a string. Defaults to `0`.'
                                  result:
                                    type: string
                                    description: 'Running total after this step, as a string. Defaults to `0`.'
                                  costRuleId:
                                    type: integer
                                    nullable: true
                                    description: Identity of the rule that contributed this step.
                                  costRuleName:
                                    type: string
                                    nullable: true
                            next_tier_hint:
                              type: object
                              nullable: true
                              description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                              properties:
                                min_qty:
                                  type: number
                                  nullable: true
                                unit_cost:
                                  type: number
                                  nullable: true
                                savings:
                                  type: number
                                  nullable: true
                        notes:
                          type: string
                          nullable: true
                        hold_reason:
                          type: string
                          nullable: true
                        cancel_reason:
                          type: string
                          nullable: true
                        held_at:
                          type: string
                          format: date-time
                          nullable: true
                        created_by:
                          type: integer
                          nullable: true
                        updated_by:
                          type: integer
                          nullable: true
                        held_by:
                          type: integer
                          nullable: true
                        production_batch_id:
                          type: integer
                          nullable: true
                        steps:
                          type: array
                          description: Production steps. Present only when the steps relation is loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              work_order_id:
                                type: integer
                              sequence:
                                type: integer
                                description: Order of the step within the work order's routing.
                              status:
                                type: string
                                description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                              output_sku_id:
                                type: integer
                                nullable: true
                              output_sku:
                                type: object
                                nullable: true
                                description: Present only when the outputSku relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  sku:
                                    type: string
                                  description:
                                    type: string
                                    nullable: true
                              planned_qty:
                                type: number
                                description: Quantity planned to be produced by this step.
                              completed_qty:
                                type: number
                                description: Quantity completed so far for this step.
                              is_outside_processing:
                                type: boolean
                                description: Whether this step is performed by an outside (subcontract) vendor.
                              supply_mode:
                                type: string
                                nullable: true
                              vendor_id:
                                type: integer
                                nullable: true
                              skipped_at:
                                type: string
                                format: date-time
                                nullable: true
                              skipped_by:
                                type: integer
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        custom_fields:
                          type: object
                          nullable: true
                          description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties: true
                        alternate_ids:
                          type: array
                          description: External alternate identifiers. Present only when loaded.
                          items:
                            type: string
                        links:
                          type: object
                          description: HATEOAS links to related sub-resources.
                          properties:
                            self:
                              type: string
                            steps:
                              type: string
                            completions:
                              type: string
                            production_entries:
                              type: string
                            status_history:
                              type: string
                  links:
                    type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
    post:
      operationId: createWorkOrder
      tags:
        - Work Orders
      summary: Create a work order
      description: Create a new work order.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - produced_sku_id
                - planned_qty
                - destination_warehouse_id
              properties:
                produced_sku_id:
                  type: integer
                  description: ID of the SKU to produce (references a request_for_quotes SKU record).
                planned_qty:
                  type: number
                  minimum: 0.0001
                  description: Planned quantity to produce. Must be at least 0.0001.
                production_warehouse_id:
                  type: integer
                  nullable: true
                  description: Warehouse where production occurs.
                destination_warehouse_id:
                  type: integer
                  description: Warehouse where the produced goods are received.
                vendor_id:
                  type: integer
                  nullable: true
                  description: Vendor performing the work (for subcontracted production).
                co_manufacturer_id:
                  type: integer
                  nullable: true
                  description: 'Alias of `vendor_id`. When both are sent, `vendor_id` wins.'
                bom_id:
                  type: integer
                  nullable: true
                  description: Bill of materials to use for this work order.
                expected_completion_date:
                  type: string
                  format: date
                  nullable: true
                  description: Expected completion date for the work order.
                completion_trigger:
                  type: string
                  nullable: true
                  enum:
                    - manual
                    - finish_step
                    - receipt
                  description: 'Event that marks the work order as complete. `manual` (closes only when someone completes the work order), `finish_step`, or `receipt`. When omitted, the work order gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                service_unit_price:
                  type: number
                  minimum: 0
                  nullable: true
                  description: Per-unit service price for subcontracted production.
                notes:
                  type: string
                  nullable: true
                  description: Free-form notes for the work order.
                custom_fields:
                  type: object
                  nullable: true
                  additionalProperties: true
                  description: Custom field key/value pairs.
                alternate_ids:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: Alternate identifiers for the work order.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /work-orders/bulk:
    post:
      operationId: bulkCreateWorkOrders
      tags:
        - Work Orders
      summary: Bulk create work orders
      description: |
        Create multiple work orders in a single request, optionally auto-generating related purchase
        orders, transfer orders, and steps. The work orders are grouped into one production batch;
        send `production_batch` to name it and set its vendor, dates and warehouses.

        To spread a master SKU total across its variants first, call
        `POST /distribution-templates/distribute` and send one work order per returned cell.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - work_orders
              properties:
                work_orders:
                  type: array
                  minItems: 1
                  description: Work orders to create.
                  items:
                    type: object
                    required:
                      - produced_sku_id
                      - planned_qty
                      - destination_warehouse_id
                    properties:
                      produced_sku_id:
                        type: integer
                        description: ID of the SKU to produce. Must reference an existing SKU; an invalid ID returns a 422 validation error.
                      planned_qty:
                        type: number
                        minimum: 0.0001
                        description: Planned quantity to produce. Must be at least 0.0001.
                      destination_warehouse_id:
                        type: integer
                        description: Warehouse where the produced goods are received. Must reference an existing warehouse; an invalid ID returns a 422 validation error.
                      completion_trigger:
                        type: string
                        nullable: true
                        enum:
                          - manual
                          - finish_step
                          - receipt
                        description: 'Event that marks the work order as complete. `manual` (closes only when someone completes the work order), `finish_step` (once every step is finished), or `receipt` (when its finished goods are received). When omitted, the work order gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                auto_generate_po:
                  type: boolean
                  nullable: true
                  description: Whether to automatically generate purchase orders. Defaults to `false`.
                auto_generate_to:
                  type: boolean
                  nullable: true
                  description: Whether to automatically generate transfer orders. Defaults to `false`.
                auto_generate_steps:
                  type: boolean
                  nullable: true
                  description: Whether to automatically generate work order steps.
                skip_subcontract_po:
                  type: boolean
                  nullable: true
                  description: Whether to skip generating subcontract purchase orders.
                production_batch:
                  type: object
                  nullable: true
                  description: Optional details for the production batch created for these work orders.
                  properties:
                    name:
                      type: string
                      nullable: true
                      maxLength: 255
                      description: Batch name
                    vendor_id:
                      type: integer
                      nullable: true
                      description: Supplier ID of the vendor producing the batch. Must reference an existing supplier.
                    notes:
                      type: string
                      nullable: true
                      maxLength: 65535
                    expected_completion_date:
                      type: string
                      format: date
                      nullable: true
                    production_warehouse_id:
                      type: integer
                      nullable: true
                      description: Warehouse where production takes place. Must reference an existing warehouse.
                    destination_warehouse_id:
                      type: integer
                      nullable: true
                      description: Warehouse the batch's finished goods go to. Must reference an existing warehouse.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      work_orders:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                            is_on_hold:
                              type: boolean
                            produced_sku_id:
                              type: integer
                              nullable: true
                              description: ID of the SKU (request_for_quotes record) being produced.
                            produced_sku:
                              type: object
                              nullable: true
                              description: Present only when the producedSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced.
                            completion_trigger:
                              type: string
                              nullable: true
                              description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                              enum:
                                - manual
                                - finish_step
                                - receipt
                            expected_completion_date:
                              type: string
                              format: date
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            production_warehouse_id:
                              type: integer
                              nullable: true
                            production_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the productionWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            destination_warehouse_id:
                              type: integer
                              nullable: true
                            destination_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the destinationWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            vendor_id:
                              type: integer
                              nullable: true
                              description: Co-manufacturer (subcontract) vendor ID.
                            co_manufacturer_id:
                              type: integer
                              nullable: true
                              description: Alias of `vendor_id` (always the same value).
                            vendor:
                              type: object
                              nullable: true
                              description: Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            co_manufacturer:
                              type: object
                              nullable: true
                              description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            bom_id:
                              type: integer
                              nullable: true
                            work_order_kind:
                              type: string
                              enum:
                                - build
                                - service
                              description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                            service_unit_price:
                              type: number
                              nullable: true
                              description: Per-unit service fee for subcontract production.
                            cost_rule_resolution:
                              type: object
                              nullable: true
                              description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                              properties:
                                used_cost_rule:
                                  type: boolean
                                  description: True when a cost rule produced the price; false for a fallback resolution.
                                cost_rule_id:
                                  type: integer
                                  nullable: true
                                cost_rule_name:
                                  type: string
                                  nullable: true
                                resolved_unit_cost:
                                  type: number
                                  nullable: true
                                  description: The per-unit cost the engine resolved to.
                                fallback_source:
                                  type: string
                                  nullable: true
                                  description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                tier_min_qty:
                                  type: number
                                  nullable: true
                                  description: Minimum quantity of the matched cost-rule tier.
                                breakdown:
                                  type: array
                                  description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                  items:
                                    type: object
                                    properties:
                                      effect:
                                        type: string
                                        description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                      description:
                                        type: string
                                        nullable: true
                                      amount:
                                        type: string
                                        description: 'The step''s amount, as a string. Defaults to `0`.'
                                      delta:
                                        type: string
                                        description: 'Change applied at this step, as a string. Defaults to `0`.'
                                      result:
                                        type: string
                                        description: 'Running total after this step, as a string. Defaults to `0`.'
                                      costRuleId:
                                        type: integer
                                        nullable: true
                                        description: Identity of the rule that contributed this step.
                                      costRuleName:
                                        type: string
                                        nullable: true
                                next_tier_hint:
                                  type: object
                                  nullable: true
                                  description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                  properties:
                                    min_qty:
                                      type: number
                                      nullable: true
                                    unit_cost:
                                      type: number
                                      nullable: true
                                    savings:
                                      type: number
                                      nullable: true
                            notes:
                              type: string
                              nullable: true
                            hold_reason:
                              type: string
                              nullable: true
                            cancel_reason:
                              type: string
                              nullable: true
                            held_at:
                              type: string
                              format: date-time
                              nullable: true
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            held_by:
                              type: integer
                              nullable: true
                            production_batch_id:
                              type: integer
                              nullable: true
                            steps:
                              type: array
                              description: Production steps. Present only when the steps relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  work_order_id:
                                    type: integer
                                  sequence:
                                    type: integer
                                    description: Order of the step within the work order's routing.
                                  status:
                                    type: string
                                    description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                  output_sku_id:
                                    type: integer
                                    nullable: true
                                  output_sku:
                                    type: object
                                    nullable: true
                                    description: Present only when the outputSku relation is loaded.
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  planned_qty:
                                    type: number
                                    description: Quantity planned to be produced by this step.
                                  completed_qty:
                                    type: number
                                    description: Quantity completed so far for this step.
                                  is_outside_processing:
                                    type: boolean
                                    description: Whether this step is performed by an outside (subcontract) vendor.
                                  supply_mode:
                                    type: string
                                    nullable: true
                                  vendor_id:
                                    type: integer
                                    nullable: true
                                  skipped_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  skipped_by:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            custom_fields:
                              type: object
                              nullable: true
                              description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties: true
                            alternate_ids:
                              type: array
                              description: External alternate identifiers. Present only when loaded.
                              items:
                                type: string
                            links:
                              type: object
                              description: HATEOAS links to related sub-resources.
                              properties:
                                self:
                                  type: string
                                steps:
                                  type: string
                                completions:
                                  type: string
                                production_entries:
                                  type: string
                                status_history:
                                  type: string
                      production_batch:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: bulkDeleteWorkOrders
      tags:
        - Work Orders
      summary: Bulk delete work orders
      description: Delete multiple work orders in a single request.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ids
              properties:
                ids:
                  type: array
                  minItems: 1
                  description: IDs of the work orders to delete.
                  items:
                    type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /work-orders/bulk/status:
    post:
      operationId: bulkUpdateWorkOrderStatus
      tags:
        - Work Orders
      summary: Bulk update work order status
      description: Update the status of multiple work orders in a single request.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - work_order_ids
                - status
              properties:
                work_order_ids:
                  type: array
                  minItems: 1
                  description: IDs of the work orders to update.
                  items:
                    type: integer
                status:
                  type: string
                  enum:
                    - draft
                    - planned
                    - in_progress
                  description: New status to apply to the work orders.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /work-orders/bulk/quick-complete:
    post:
      operationId: bulkQuickCompleteWorkOrders
      tags:
        - Work Orders
      summary: Bulk quick-complete work orders
      description: Quick-complete multiple work orders in a single request (up to 100 at a time).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - work_order_ids
              properties:
                work_order_ids:
                  type: array
                  minItems: 1
                  maxItems: 100
                  description: IDs of the work orders to quick-complete.
                  items:
                    type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}':
    get:
      operationId: getWorkOrderById
      tags:
        - Work Orders
      summary: Get a work order
      description: Retrieve a single work order by its ID.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order.
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateWorkOrder
      tags:
        - Work Orders
      summary: Update a work order
      description: |
        Update an existing work order. All fields are optional; only the provided fields are updated.

        Only **draft**, **planned** and **in progress** work orders can be updated. Any other status
        returns `422` (`Only draft or planned work orders can be updated`).

        **In progress work orders** accept only `planned_qty` and/or `service_unit_price` (for example
        when a co-packer's final bill lands while the run is still going). Sending any other field
        (including `alternate_ids`, even an empty list, `tag_ids` or `custom_fields`) returns `422`
        naming the refused fields (`Only the planned quantity and service unit price can be updated on
        an in progress work order. Not allowed: notes, alternate_ids`). A request with neither field
        returns `422` (`An in progress work order takes planned_qty or service_unit_price, and this
        request had neither`). A new `planned_qty` cannot be below the quantity already assembled
        (`422`, `Planned quantity cannot be below the X already assembled`). When the planned
        quantity changes, every step is rescaled in proportion and the stock reservation is resynced
        for what is left to build.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order.
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                produced_sku_id:
                  type: integer
                  description: ID of the SKU to produce (references a request_for_quotes SKU record).
                planned_qty:
                  type: number
                  minimum: 0.0001
                  description: Planned quantity to produce. Must be at least 0.0001.
                production_warehouse_id:
                  type: integer
                  nullable: true
                  description: Warehouse where production occurs.
                destination_warehouse_id:
                  type: integer
                  description: Warehouse where the produced goods are received.
                vendor_id:
                  type: integer
                  nullable: true
                  description: Vendor performing the work (for subcontracted production). Omit this field to leave the existing vendor unchanged; send an explicit `null` to clear it.
                co_manufacturer_id:
                  type: integer
                  nullable: true
                  description: 'Alias of `vendor_id`. When both are sent, `vendor_id` wins. Sending either key (including an explicit `null`) updates the vendor.'
                bom_id:
                  type: integer
                  nullable: true
                  description: Bill of materials to use for this work order. Omit this field to leave the existing BOM unchanged; send an explicit `null` to clear it.
                expected_completion_date:
                  type: string
                  format: date
                  nullable: true
                  description: Expected completion date for the work order.
                completion_trigger:
                  type: string
                  nullable: true
                  enum:
                    - manual
                    - finish_step
                    - receipt
                  description: 'Event that marks the work order as complete. `manual` (closes only when someone completes the work order), `finish_step`, or `receipt`. Omit to leave unchanged.'
                service_unit_price:
                  type: number
                  minimum: 0
                  nullable: true
                  description: Per-unit service price for subcontracted production. Omit this field to leave the existing service fee unchanged; send an explicit `null` (or `0`) to clear the fee. A change to the work order's BOM on its own will not alter a service fee that was set this way.
                notes:
                  type: string
                  nullable: true
                  description: Free-form notes for the work order.
                custom_fields:
                  type: object
                  nullable: true
                  additionalProperties: true
                  description: Custom field key/value pairs.
                alternate_ids:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: Alternate identifiers for the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, the work order is not draft, planned or in progress, or an in progress work order was sent a field other than `planned_qty` / `service_unit_price` (the message lists the refused fields), neither of those fields, or a `planned_qty` below the quantity already assembled.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteWorkOrder
      tags:
        - Work Orders
      summary: Delete a work order
      description: Delete a work order. Only work orders in the draft status can be deleted.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order.
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (e.g. the work order is not in draft status)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/plan':
    post:
      operationId: planWorkOrder
      tags:
        - Work Orders
      summary: Plan a work order
      description: Plan a work order. Triggers BOM explosion for the produced SKU and generates the work order's production steps. Returns the updated work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order to plan.
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/start':
    post:
      operationId: startWorkOrder
      tags:
        - Work Orders
      summary: Start a work order
      description: 'Start a work order, transitioning it to the in_progress status. Returns the updated work order.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order to start.
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/complete':
    post:
      operationId: completeWorkOrder
      tags:
        - Work Orders
      summary: Complete a work order
      description: |-
        Complete a work order, transitioning it to the completed status. Set force to true to complete the work order even when validation checks (such as outstanding steps) would otherwise prevent completion. Returns the updated work order.
        If the account's work order setting to block completing without production is on, completing a work order whose producing steps (skipped steps don't count) have recorded no production returns 422 with `noProductionRecorded: true`, even when force is true. Record production, or cancel the work order instead.
        Completing a work order releases any incoming purchase order stock allocated to its BOM lines back to the incoming pool, the same way cancelling does.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order to complete.
          schema:
            type: integer
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                force:
                  type: boolean
                  description: 'When true, force completion even if validation checks would otherwise prevent it. Defaults to false.'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'The work order cannot be completed. When completion is refused because steps are incomplete or sub-assembly orders were never built (and force is not true), the body also carries the details needed to confirm a forced completion: `underProduction`, `incompleteSteps`, `draftSubAssemblies`, and `draftSubAssemblyOrders`. When the account blocks completing without production and none has been recorded, the body carries `noProductionRecorded: true` (force does not override this). Other refusals (for example, a work order that is not in progress) return only `message`.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Work order has incomplete steps. Confirm to complete anyway.
                  noProductionRecorded:
                    type: boolean
                    description: True when completion was refused because no production has been recorded and the account blocks completing without production. Not overridden by force.
                  underProduction:
                    type: boolean
                    description: True when one or more steps are not completed.
                  incompleteSteps:
                    type: array
                    description: Steps that are not completed.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        name:
                          type: string
                          description: 'Output SKU internal SKU or product name, or "Step {sequence}".'
                        plannedQty:
                          type: number
                        completedQty:
                          type: number
                  draftSubAssemblies:
                    type: boolean
                    description: True when one or more sub-assembly orders were never built.
                  draftSubAssemblyOrders:
                    type: array
                    description: Sub-assembly orders that are still Draft.
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Assembly order ID.
                        name:
                          type: string
                          description: 'SKU internal SKU or product name, or "Assembly order'
                        plannedQty:
                          type: number
  '/work-orders/{workOrderId}/cancel':
    post:
      operationId: cancelWorkOrder
      tags:
        - Work Orders
      summary: Cancel a work order
      description: 'Cancel a work order, transitioning it to the cancelled status. An optional reason can be supplied. Returns the updated work order.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order to cancel.
          schema:
            type: integer
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  nullable: true
                  maxLength: 1000
                  description: Optional reason for cancelling the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/hold':
    post:
      operationId: holdWorkOrder
      tags:
        - Work Orders
      summary: Hold a work order
      description: Place a work order on hold. An optional reason can be supplied. Returns the updated work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order to place on hold.
          schema:
            type: integer
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  nullable: true
                  maxLength: 1000
                  description: Optional reason for placing the work order on hold.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/unhold':
    post:
      operationId: unholdWorkOrder
      tags:
        - Work Orders
      summary: Release a work order from hold
      description: 'Release a work order from hold, returning it to its prior status. Returns the updated work order.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order to release from hold.
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/refresh':
    post:
      operationId: refreshWorkOrder
      tags:
        - Work Orders
      summary: Refresh a work order
      description: 'Refresh a work order, re-evaluating its plan and recalculating derived data. Returns a result describing the outcome of the refresh and, when available, the updated work order.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          description: ID of the work order to refresh.
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        description: Whether the refresh completed successfully.
                      message:
                        type: string
                        description: Human-readable description of the refresh outcome.
                      summary:
                        type: object
                        nullable: true
                        additionalProperties: true
                        description: Summary of changes applied during the refresh.
                      work_order:
                        nullable: true
                        allOf:
                          - type: object
                            properties:
                              id:
                                type: integer
                              work_order_number:
                                type: string
                              status:
                                type: string
                                description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                              is_on_hold:
                                type: boolean
                              produced_sku_id:
                                type: integer
                                nullable: true
                                description: ID of the SKU (request_for_quotes record) being produced.
                              produced_sku:
                                type: object
                                nullable: true
                                description: Present only when the producedSku relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  sku:
                                    type: string
                                  description:
                                    type: string
                                    nullable: true
                              planned_qty:
                                type: number
                                description: Quantity planned to be produced.
                              completion_trigger:
                                type: string
                                nullable: true
                                description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                                enum:
                                  - manual
                                  - finish_step
                                  - receipt
                              expected_completion_date:
                                type: string
                                format: date
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              production_warehouse_id:
                                type: integer
                                nullable: true
                              production_warehouse:
                                type: object
                                nullable: true
                                description: Present only when the productionWarehouse relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              destination_warehouse_id:
                                type: integer
                                nullable: true
                              destination_warehouse:
                                type: object
                                nullable: true
                                description: Present only when the destinationWarehouse relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              vendor_id:
                                type: integer
                                nullable: true
                                description: Co-manufacturer (subcontract) vendor ID.
                              co_manufacturer_id:
                                type: integer
                                nullable: true
                                description: Alias of `vendor_id` (always the same value).
                              vendor:
                                type: object
                                nullable: true
                                description: Present only when the vendor relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              co_manufacturer:
                                type: object
                                nullable: true
                                description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              bom_id:
                                type: integer
                                nullable: true
                              work_order_kind:
                                type: string
                                enum:
                                  - build
                                  - service
                                description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                              service_unit_price:
                                type: number
                                nullable: true
                                description: Per-unit service fee for subcontract production.
                              cost_rule_resolution:
                                type: object
                                nullable: true
                                description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                                properties:
                                  used_cost_rule:
                                    type: boolean
                                    description: True when a cost rule produced the price; false for a fallback resolution.
                                  cost_rule_id:
                                    type: integer
                                    nullable: true
                                  cost_rule_name:
                                    type: string
                                    nullable: true
                                  resolved_unit_cost:
                                    type: number
                                    nullable: true
                                    description: The per-unit cost the engine resolved to.
                                  fallback_source:
                                    type: string
                                    nullable: true
                                    description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                  tier_min_qty:
                                    type: number
                                    nullable: true
                                    description: Minimum quantity of the matched cost-rule tier.
                                  breakdown:
                                    type: array
                                    description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                    items:
                                      type: object
                                      properties:
                                        effect:
                                          type: string
                                          description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                        description:
                                          type: string
                                          nullable: true
                                        amount:
                                          type: string
                                          description: 'The step''s amount, as a string. Defaults to `0`.'
                                        delta:
                                          type: string
                                          description: 'Change applied at this step, as a string. Defaults to `0`.'
                                        result:
                                          type: string
                                          description: 'Running total after this step, as a string. Defaults to `0`.'
                                        costRuleId:
                                          type: integer
                                          nullable: true
                                          description: Identity of the rule that contributed this step.
                                        costRuleName:
                                          type: string
                                          nullable: true
                                  next_tier_hint:
                                    type: object
                                    nullable: true
                                    description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                    properties:
                                      min_qty:
                                        type: number
                                        nullable: true
                                      unit_cost:
                                        type: number
                                        nullable: true
                                      savings:
                                        type: number
                                        nullable: true
                              notes:
                                type: string
                                nullable: true
                              hold_reason:
                                type: string
                                nullable: true
                              cancel_reason:
                                type: string
                                nullable: true
                              held_at:
                                type: string
                                format: date-time
                                nullable: true
                              created_by:
                                type: integer
                                nullable: true
                              updated_by:
                                type: integer
                                nullable: true
                              held_by:
                                type: integer
                                nullable: true
                              production_batch_id:
                                type: integer
                                nullable: true
                              steps:
                                type: array
                                description: Production steps. Present only when the steps relation is loaded.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    work_order_id:
                                      type: integer
                                    sequence:
                                      type: integer
                                      description: Order of the step within the work order's routing.
                                    status:
                                      type: string
                                      description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                    output_sku_id:
                                      type: integer
                                      nullable: true
                                    output_sku:
                                      type: object
                                      nullable: true
                                      description: Present only when the outputSku relation is loaded.
                                      properties:
                                        id:
                                          type: integer
                                        sku:
                                          type: string
                                        description:
                                          type: string
                                          nullable: true
                                    planned_qty:
                                      type: number
                                      description: Quantity planned to be produced by this step.
                                    completed_qty:
                                      type: number
                                      description: Quantity completed so far for this step.
                                    is_outside_processing:
                                      type: boolean
                                      description: Whether this step is performed by an outside (subcontract) vendor.
                                    supply_mode:
                                      type: string
                                      nullable: true
                                    vendor_id:
                                      type: integer
                                      nullable: true
                                    skipped_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    skipped_by:
                                      type: integer
                                      nullable: true
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                              custom_fields:
                                type: object
                                nullable: true
                                description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties: true
                              alternate_ids:
                                type: array
                                description: External alternate identifiers. Present only when loaded.
                                items:
                                  type: string
                              links:
                                type: object
                                description: HATEOAS links to related sub-resources.
                                properties:
                                  self:
                                    type: string
                                  steps:
                                    type: string
                                  completions:
                                    type: string
                                  production_entries:
                                    type: string
                                  status_history:
                                    type: string
                        description: 'The updated work order, when available.'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/steps':
    get:
      operationId: listWorkOrderSteps
      tags:
        - Work Orders
      summary: List work order steps
      description: Return the ordered list of production steps for a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        work_order_id:
                          type: integer
                        sequence:
                          type: integer
                          description: Order of the step within the work order's routing.
                        status:
                          type: string
                          description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                        output_sku_id:
                          type: integer
                          nullable: true
                        output_sku:
                          type: object
                          nullable: true
                          description: Present only when the outputSku relation is loaded.
                          properties:
                            id:
                              type: integer
                            sku:
                              type: string
                            description:
                              type: string
                              nullable: true
                        planned_qty:
                          type: number
                          description: Quantity planned to be produced by this step.
                        completed_qty:
                          type: number
                          description: Quantity completed so far for this step.
                        is_outside_processing:
                          type: boolean
                          description: Whether this step is performed by an outside (subcontract) vendor.
                        supply_mode:
                          type: string
                          nullable: true
                        vendor_id:
                          type: integer
                          nullable: true
                        skipped_at:
                          type: string
                          format: date-time
                          nullable: true
                        skipped_by:
                          type: integer
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/steps/{stepId}/complete':
    post:
      operationId: completeWorkOrderStep
      tags:
        - Work Orders
      summary: Complete a work order step
      description: 'Mark a work order step as completed, recording the quantity produced and optionally the warehouse the output is produced into.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: stepId
          required: true
          schema:
            type: integer
          description: ID of the work order step to complete.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - completed_qty
              properties:
                completed_qty:
                  type: number
                  minimum: 0.0001
                  description: Quantity completed for this step. Must be at least 0.0001.
                produced_warehouse_id:
                  type: integer
                  nullable: true
                  description: Warehouse the produced output is recorded into.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      completion:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/steps/{stepId}/skip':
    post:
      operationId: skipWorkOrderStep
      tags:
        - Work Orders
      summary: Skip a work order step
      description: Mark a work order step as skipped.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: stepId
          required: true
          schema:
            type: integer
          description: ID of the work order step to skip.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      step:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Step not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/generate-steps':
    post:
      operationId: generateWorkOrderSteps
      tags:
        - Work Orders
      summary: Generate work order steps
      description: Generate the production steps for a work order based on its routing or bill of materials. Returns the updated work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/regenerate-steps':
    post:
      operationId: regenerateWorkOrderSteps
      tags:
        - Work Orders
      summary: Regenerate work order steps
      description: Discard the existing production steps for a work order and regenerate them from its routing or bill of materials. Returns the updated work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/completions':
    get:
      operationId: listWorkOrderCompletions
      tags:
        - Work Orders
      summary: List work order step completions
      description: Return the step completion records logged against a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/production-entries':
    get:
      operationId: listWorkOrderProductionEntries
      tags:
        - Work Orders
      summary: List production entries
      description: Return the production entries recorded against a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createWorkOrderProductionEntry
      tags:
        - Work Orders
      summary: Create a production entry
      description: Record a production entry against a work order. Production entries can only be added to work orders that are in progress.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - quantity_produced
              properties:
                quantity_produced:
                  type: number
                  minimum: 0
                  description: Quantity produced in this entry.
                quantity_scrapped:
                  type: number
                  minimum: 0
                  nullable: true
                  description: Quantity scrapped in this entry. Defaults to 0.
                notes:
                  type: string
                  nullable: true
                  description: Optional notes for this entry.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      production_entry:
                        type: object
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or the work order is not in progress'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/production-entries/{entryId}':
    delete:
      operationId: deleteWorkOrderProductionEntry
      tags:
        - Work Orders
      summary: Delete a production entry
      description: Delete a single production entry from a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: entryId
          required: true
          schema:
            type: integer
          description: ID of the production entry to delete.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order or production entry not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/status-history':
    get:
      operationId: getWorkOrderStatusHistory
      tags:
        - Work Orders
      summary: Get status history
      description: Return the status change history for a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/events':
    get:
      operationId: getWorkOrderEvents
      tags:
        - Work Orders
      summary: Get work order events
      description: Return the event log for a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
  '/work-orders/{workOrderId}/custom-fields':
    patch:
      operationId: updateWorkOrderCustomFields
      tags:
        - Work Orders
      summary: Update custom fields
      description: 'Update the custom field values on a work order. Entries are merged into the work order''s existing values by custom field ID, so fields omitted from the payload keep their current value. Each entry must be an object with an integer `custom_field` (the custom field definition ID) and a `value`; any other shape (a label-keyed map such as `{"Brand": "X"}`, a bare scalar or positional array entry, a missing or non-integer `custom_field`) is rejected with a 422 validation error.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - custom_fields
              properties:
                custom_fields:
                  type: array
                  minItems: 1
                  description: Custom field values to set on the work order. Merged with the existing values by custom field ID.
                  items:
                    type: object
                    required:
                      - custom_field
                      - value
                    properties:
                      custom_field:
                        type: integer
                        description: ID of the custom field definition.
                      value:
                        nullable: true
                        description: 'Value to store. Must be present; an empty value leaves the field unset. Type depends on the custom field (string, number, date, or option value).'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error: missing or empty `custom_fields`, a malformed entry (not a `{custom_field, value}` object, or non-integer `custom_field`), or a required custom field left empty.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/notes':
    patch:
      operationId: updateWorkOrderNotes
      tags:
        - Work Orders
      summary: Update notes
      description: Update the notes on a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - notes
              properties:
                notes:
                  type: string
                  description: Notes to set on the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/service-fee':
    patch:
      operationId: updateWorkOrderServiceFee
      tags:
        - Work Orders
      summary: Set service fee
      description: |
        Set the per-unit service fee (`service_unit_price`) on a draft, planned or in-progress work order.
        Returns the work order.

        - The fee is one value: a second call replaces the first. To add up several charges, use
          extra-cost lines (`POST /work-orders/{workOrderId}/extra-costs`).
        - A fee of `0` is not "no fee": at completion, a zero fee falls back to the produced SKU's
          manufacturing fee.
        - At completion, the fee multiplied by the quantity produced may not exceed 99,999,999.99; a
          completion over it is refused with `422` and that step posts nothing.
        - Work orders in any other status return `422` and nothing changes.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - service_unit_price
              properties:
                service_unit_price:
                  type: number
                  minimum: 0
                  maximum: 99999999.99
                  description: 'Per-unit service fee, up to 6 decimal places.'
                  example: 12.5
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or the work order is not draft, planned or in progress.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/alternate-ids':
    patch:
      operationId: updateWorkOrderAlternateIds
      tags:
        - Work Orders
      summary: Update alternate IDs
      description: Replace a work order's alternate IDs. Works on a work order in any status. The list you send replaces the existing one; send an empty array to clear them.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - alternate_ids
              properties:
                alternate_ids:
                  type: array
                  description: 'The complete list of alternate IDs. Send `[]` to clear them.'
                  items:
                    type: string
                    maxLength: 255
                  example:
                    - CM-PO-4471
                    - LOT-B12
      responses:
        '200':
          description: Successful response. The work order includes `alternate_ids`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/expected-completion-date':
    patch:
      operationId: updateWorkOrderExpectedCompletionDate
      tags:
        - Work Orders
      summary: Update expected completion date
      description: 'Set the expected completion date on a draft, planned or in-progress work order. The date is used for planning only: changing it does not commit stock or change the work order''s steps.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - expected_completion_date
              properties:
                expected_completion_date:
                  type: string
                  format: date
                  nullable: true
                  description: New expected completion date. Send `null` to clear it.
                  example: '2026-11-20'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or the work order is completed or cancelled. Nothing is changed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/destination-warehouse':
    patch:
      operationId: updateWorkOrderDestinationWarehouse
      tags:
        - Work Orders
      summary: Update destination warehouse
      description: 'Set the destination warehouse on a draft, planned or in-progress work order. Output reported after the change is received into the new warehouse; output already received stays where it is. The change is refused once a shipment is planned for the work order, since that shipment is already headed to the current destination.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - destination_warehouse_id
              properties:
                destination_warehouse_id:
                  type: integer
                  description: ID of an active top-level warehouse (not a bin or sub-location).
                  example: 12
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error (`destination_warehouse_id` missing or not an active top-level warehouse); the work order is not draft, planned or in progress; a shipment is already planned for the work order; or the work order is a service work order that refuses the change. Nothing is changed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/extra-costs':
    get:
      operationId: listWorkOrderExtraCosts
      tags:
        - Work Orders
      summary: List extra costs
      description: |
        List the assembly cost lines on a work order (the work order's COGS tab), including lines
        created by cost rules. Each line rolls into the finished item's cost when production is reported.

        Lines are **per unit produced**: `quantity` is multiplied by the quantity produced, so
        quantity 2 at $50 on a 10-unit work order costs $1,000. `line_total` is the amount for one unit.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Unique identifier for the extra cost line
                        name:
                          type: string
                          description: Name/description of the cost
                        quantity:
                          type: number
                          format: float
                          description: Quantity **per unit produced**. Multiplied by the quantity produced when the cost reaches the finished item.
                        unit_price:
                          type: number
                          format: float
                          description: Unit price for this cost
                        line_total:
                          type: number
                          format: float
                          description: 'quantity × unit_price, the cost for **one** unit produced. Read-only.'
                        source:
                          type: string
                          nullable: true
                          description: |
                            Where the line came from. `work_order` (or `null`) lines were added on the work order and
                            can be changed or removed. Any other value (for example `rule`, a line created by a cost rule) is read-only here.
                        created_at:
                          type: string
                          format: date-time
                          description: Timestamp when the line was created
                        updated_at:
                          type: string
                          format: date-time
                          description: Timestamp when the line was last updated
                      required:
                        - id
                        - name
                        - quantity
                        - unit_price
                        - line_total
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: addWorkOrderExtraCost
      tags:
        - Work Orders
      summary: Add an extra cost
      description: |
        Add one assembly cost line to a draft, planned or in-progress work order. Other lines are unchanged.

        - **Lines are per unit produced.** `quantity` is multiplied by the quantity produced at completion.
        - **A line reaches only assembly orders created after it is added.** An assembly order that already
          exists keeps the lines it had, so add lines before quick-complete or before completing a step.
        - **Line limit:** `quantity × unit_price` may not exceed 99,999,999.99; larger lines return `422`
          (split them). The same limit applies at completion to each line multiplied by the quantity
          produced: a completion over it is refused with `422` and that step posts nothing.
        - Completed and cancelled work orders return `422` and nothing changes. Writes also return `422`
          when the cost rules feature is not enabled on the account.
        - The COGS tab in the app saves all its lines at once, so a save from a tab opened earlier can
          overwrite a line added here in the meantime.
        - Document charges (the Charges tab) are not covered; they never reach cost.

        ## Retries and idempotency
        Accepts an optional `Idempotency-Key` header. Send one so a retry can't add the cost twice: a
        retry with the same key and body replays the first response (with an `Idempotent-Replay: true`
        header); the same key with a different body returns `409`. Keys are kept for 24 hours and are
        scoped to your API token.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: |
            Optional idempotency token. A retry with the same key and body replays the original stored
            response instead of adding a second line. Reusing the key with a different body returns `409`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - quantity
                - unit_price
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Name/description of the cost.
                  example: Plating
                quantity:
                  type: number
                  minimum: 0
                  maximum: 1000000000000
                  description: 'Quantity **per unit produced**, up to 6 decimal places.'
                  example: 2
                unit_price:
                  type: number
                  minimum: 0
                  maximum: 99999999.99
                  description: 'Unit price, up to 2 decimal places. `quantity × unit_price` may not exceed 99,999,999.99.'
                  example: 50
      responses:
        '201':
          description: Extra cost line added
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the extra cost line
                      name:
                        type: string
                        description: Name/description of the cost
                      quantity:
                        type: number
                        format: float
                        description: Quantity **per unit produced**. Multiplied by the quantity produced when the cost reaches the finished item.
                      unit_price:
                        type: number
                        format: float
                        description: Unit price for this cost
                      line_total:
                        type: number
                        format: float
                        description: 'quantity × unit_price, the cost for **one** unit produced. Read-only.'
                      source:
                        type: string
                        nullable: true
                        description: |
                          Where the line came from. `work_order` (or `null`) lines were added on the work order and
                          can be changed or removed. Any other value (for example `rule`, a line created by a cost rule) is read-only here.
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the line was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the line was last updated
                    required:
                      - id
                      - name
                      - quantity
                      - unit_price
                      - line_total
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '409':
          description: 'Idempotency conflict (key in flight, or reused with a different body).'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error, the work order is completed or cancelled, the line total exceeds
            99,999,999.99 (`That comes to more than we can record on one line. Please split it.`), or
            the cost rules feature is not enabled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/extra-costs/{extraCostId}':
    put:
      operationId: updateWorkOrderExtraCost
      tags:
        - Work Orders
      summary: Update an extra cost
      description: |
        Change one assembly cost line on a draft, planned or in-progress work order. All three fields
        are required. Only lines with `source` `work_order` or `null` can be changed; a line created by a
        cost rule, or a line id that isn't on this work order, returns `404`.

        The same per-line limit (`quantity × unit_price` ≤ 99,999,999.99) and status rules apply as for
        `POST /work-orders/{workOrderId}/extra-costs`. A change reaches only assembly orders created after it.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: extraCostId
          required: true
          schema:
            type: integer
          description: ID of the extra cost line.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - quantity
                - unit_price
              properties:
                name:
                  type: string
                  maxLength: 255
                  description: Name/description of the cost.
                  example: Plating
                quantity:
                  type: number
                  minimum: 0
                  maximum: 1000000000000
                  description: 'Quantity **per unit produced**, up to 6 decimal places.'
                  example: 2
                unit_price:
                  type: number
                  minimum: 0
                  maximum: 99999999.99
                  description: 'Unit price, up to 2 decimal places. `quantity × unit_price` may not exceed 99,999,999.99.'
                  example: 50
      responses:
        '200':
          description: Extra cost line updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Unique identifier for the extra cost line
                      name:
                        type: string
                        description: Name/description of the cost
                      quantity:
                        type: number
                        format: float
                        description: Quantity **per unit produced**. Multiplied by the quantity produced when the cost reaches the finished item.
                      unit_price:
                        type: number
                        format: float
                        description: Unit price for this cost
                      line_total:
                        type: number
                        format: float
                        description: 'quantity × unit_price, the cost for **one** unit produced. Read-only.'
                      source:
                        type: string
                        nullable: true
                        description: |
                          Where the line came from. `work_order` (or `null`) lines were added on the work order and
                          can be changed or removed. Any other value (for example `rule`, a line created by a cost rule) is read-only here.
                      created_at:
                        type: string
                        format: date-time
                        description: Timestamp when the line was created
                      updated_at:
                        type: string
                        format: date-time
                        description: Timestamp when the line was last updated
                    required:
                      - id
                      - name
                      - quantity
                      - unit_price
                      - line_total
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Work order not found, or the line is not on this work order or is not editable.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: |
            Validation error, the work order is completed or cancelled, the line total exceeds
            99,999,999.99, or the cost rules feature is not enabled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteWorkOrderExtraCost
      tags:
        - Work Orders
      summary: Delete an extra cost
      description: |
        Remove one assembly cost line from a draft, planned or in-progress work order. Only lines with
        `source` `work_order` or `null` can be removed; a line created by a cost rule, or a line id that
        isn't on this work order, returns `404`. Assembly orders that already exist keep the line.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: extraCostId
          required: true
          schema:
            type: integer
          description: ID of the extra cost line.
      responses:
        '200':
          description: Extra cost line removed
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Work order extra cost deleted.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'Work order not found, or the line is not on this work order or is not editable.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'The work order is completed or cancelled, or the cost rules feature is not enabled.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/raw-materials':
    get:
      operationId: getWorkOrderRawMaterials
      tags:
        - Work Orders
      summary: List work order raw materials
      description: Return the raw material requirements for a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: The ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/bom-items':
    get:
      operationId: getWorkOrderBomItems
      tags:
        - Work Orders
      summary: List work order BOM items
      description: |
        Return the bill of materials (BOM) items for a work order.

        The list also includes components added directly to the work order that are not on
        the master BOM. These entries are appended after the master BOM items and are marked
        with `source: "added"`, `id: null`, and `bom_item_id: 0`. Their per-output quantity
        comes from the work order's quantity override (defaulting to 1).

        For a completed work order every line reports no shortage: `short_quantity` and
        `suggested_purchase_quantity` are 0 and `has_component_shortage` is false, since a
        completed work order consumes nothing more.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: The ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/sub-assembly-stock':
    get:
      operationId: getWorkOrderSubAssemblyStock
      tags:
        - Work Orders
      summary: Get work order sub-assembly stock
      description: Return stock information for the sub-assemblies (RFQs) of a work order. The rfq_ids query parameter is required and must be a comma-separated list of RFQ IDs.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: The ID of the work order.
        - in: query
          name: rfq_ids
          required: true
          description: Comma-separated list of RFQ (sub-assembly) integer IDs to retrieve stock for.
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (e.g. rfq_ids missing)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/receive':
    post:
      operationId: receiveWorkOrderFinishedGoods
      tags:
        - Work Orders
      summary: Receive finished goods
      description: 'Receive finished goods for a work order, recording the completed quantity.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: The ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - completed_qty
              properties:
                completed_qty:
                  type: number
                  minimum: 0.0001
                  description: The quantity of finished goods completed and received.
                produced_warehouse_id:
                  type: integer
                  nullable: true
                  description: The warehouse to receive the finished goods into.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      work_order_number:
                        type: string
                      status:
                        type: string
                        description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                      is_on_hold:
                        type: boolean
                      produced_sku_id:
                        type: integer
                        nullable: true
                        description: ID of the SKU (request_for_quotes record) being produced.
                      produced_sku:
                        type: object
                        nullable: true
                        description: Present only when the producedSku relation is loaded.
                        properties:
                          id:
                            type: integer
                          sku:
                            type: string
                          description:
                            type: string
                            nullable: true
                      planned_qty:
                        type: number
                        description: Quantity planned to be produced.
                      completion_trigger:
                        type: string
                        nullable: true
                        description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                        enum:
                          - manual
                          - finish_step
                          - receipt
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      production_warehouse_id:
                        type: integer
                        nullable: true
                      production_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the productionWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: Present only when the destinationWarehouse relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      vendor_id:
                        type: integer
                        nullable: true
                        description: Co-manufacturer (subcontract) vendor ID.
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      co_manufacturer:
                        type: object
                        nullable: true
                        description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      bom_id:
                        type: integer
                        nullable: true
                      work_order_kind:
                        type: string
                        enum:
                          - build
                          - service
                        description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                      service_unit_price:
                        type: number
                        nullable: true
                        description: Per-unit service fee for subcontract production.
                      cost_rule_resolution:
                        type: object
                        nullable: true
                        description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                        properties:
                          used_cost_rule:
                            type: boolean
                            description: True when a cost rule produced the price; false for a fallback resolution.
                          cost_rule_id:
                            type: integer
                            nullable: true
                          cost_rule_name:
                            type: string
                            nullable: true
                          resolved_unit_cost:
                            type: number
                            nullable: true
                            description: The per-unit cost the engine resolved to.
                          fallback_source:
                            type: string
                            nullable: true
                            description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                          tier_min_qty:
                            type: number
                            nullable: true
                            description: Minimum quantity of the matched cost-rule tier.
                          breakdown:
                            type: array
                            description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                            items:
                              type: object
                              properties:
                                effect:
                                  type: string
                                  description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                description:
                                  type: string
                                  nullable: true
                                amount:
                                  type: string
                                  description: 'The step''s amount, as a string. Defaults to `0`.'
                                delta:
                                  type: string
                                  description: 'Change applied at this step, as a string. Defaults to `0`.'
                                result:
                                  type: string
                                  description: 'Running total after this step, as a string. Defaults to `0`.'
                                costRuleId:
                                  type: integer
                                  nullable: true
                                  description: Identity of the rule that contributed this step.
                                costRuleName:
                                  type: string
                                  nullable: true
                          next_tier_hint:
                            type: object
                            nullable: true
                            description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                            properties:
                              min_qty:
                                type: number
                                nullable: true
                              unit_cost:
                                type: number
                                nullable: true
                              savings:
                                type: number
                                nullable: true
                      notes:
                        type: string
                        nullable: true
                      hold_reason:
                        type: string
                        nullable: true
                      cancel_reason:
                        type: string
                        nullable: true
                      held_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      held_by:
                        type: integer
                        nullable: true
                      production_batch_id:
                        type: integer
                        nullable: true
                      steps:
                        type: array
                        description: Production steps. Present only when the steps relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_id:
                              type: integer
                            sequence:
                              type: integer
                              description: Order of the step within the work order's routing.
                            status:
                              type: string
                              description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                            output_sku_id:
                              type: integer
                              nullable: true
                            output_sku:
                              type: object
                              nullable: true
                              description: Present only when the outputSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced by this step.
                            completed_qty:
                              type: number
                              description: Quantity completed so far for this step.
                            is_outside_processing:
                              type: boolean
                              description: Whether this step is performed by an outside (subcontract) vendor.
                            supply_mode:
                              type: string
                              nullable: true
                            vendor_id:
                              type: integer
                              nullable: true
                            skipped_at:
                              type: string
                              format: date-time
                              nullable: true
                            skipped_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      alternate_ids:
                        type: array
                        description: External alternate identifiers. Present only when loaded.
                        items:
                          type: string
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          steps:
                            type: string
                          completions:
                            type: string
                          production_entries:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/quick-complete':
    post:
      operationId: quickCompleteWorkOrder
      tags:
        - Work Orders
      summary: Quick complete a work order
      description: 'Quickly complete a work order, optionally specifying the quantity to complete. If no quantity is provided, the full work order quantity is used.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: The ID of the work order.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                quantity:
                  type: number
                  nullable: true
                  minimum: 0.0001
                  description: The quantity to complete. Defaults to the full work order quantity.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/adjust-committed-stock':
    post:
      operationId: adjustWorkOrderCommittedStock
      tags:
        - Work Orders
      summary: Adjust committed stock
      description: Adjust the committed stock quantity for a specific RFQ (sub-assembly) on a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: The ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - rfq_id
                - quantity
              properties:
                rfq_id:
                  type: integer
                  description: The RFQ (sub-assembly) ID whose committed stock is being adjusted.
                quantity:
                  type: number
                  minimum: 0.01
                  description: The committed stock quantity to set or adjust.
                reason:
                  type: string
                  nullable: true
                  maxLength: 500
                  description: An optional reason for the adjustment.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/po-links':
    get:
      operationId: getWorkOrderPoLinks
      tags:
        - Work Orders
      summary: List work order purchase order links
      description: Return the purchase order links associated with a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: addWorkOrderPoLink
      tags:
        - Work Orders
      summary: Add a purchase order link to a work order
      description: Link a purchase order to a work order as a raw material or subcontract source.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - purchase_order_id
              properties:
                purchase_order_id:
                  type: integer
                  description: The purchase order to link to the work order.
                link_type:
                  type: string
                  nullable: true
                  enum:
                    - raw_material
                    - subcontract
                  description: The type of link between the purchase order and the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      link:
                        type: object
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/po-links/{linkId}':
    delete:
      operationId: removeWorkOrderPoLink
      tags:
        - Work Orders
      summary: Remove a purchase order link from a work order
      description: Remove an existing purchase order link from a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
        - in: path
          name: linkId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/allocate-incoming-stock':
    post:
      operationId: allocateWorkOrderIncomingStock
      tags:
        - Work Orders
      summary: Allocate incoming stock to a work order
      description: Allocate quantities from incoming purchase orders to a work order's RFQ requirements. Returns 422 with the message "Incoming stock cannot be allocated to a completed or cancelled work order" when the work order is completed or cancelled.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - rfq_id
                - allocations
              properties:
                rfq_id:
                  type: integer
                  description: The RFQ to allocate incoming stock against.
                allocations:
                  type: array
                  minItems: 1
                  description: Allocations of incoming purchase order quantities.
                  items:
                    type: object
                    required:
                      - po_id
                      - quantity
                    properties:
                      po_id:
                        type: integer
                        description: The purchase order to allocate from.
                      quantity:
                        type: number
                        minimum: 0.01
                        description: The quantity to allocate.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/ao-links':
    get:
      operationId: getWorkOrderAoLinks
      tags:
        - Work Orders
      summary: List work order assembly order links
      description: Return the assembly order links associated with a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/receiving-reports':
    get:
      operationId: getWorkOrderReceivingReports
      tags:
        - Work Orders
      summary: List work order receiving reports
      description: Return the receiving reports associated with a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/generate-purchase-orders':
    post:
      operationId: generateWorkOrderPurchaseOrders
      tags:
        - Work Orders
      summary: Generate purchase orders for a work order
      description: |
        Generate purchase orders for a work order's raw material and/or subcontract requirements.

        Repeated requests are safe to retry. If an active or draft raw-material PO from the same vendor was created for this work order in the last 5 minutes and already carries every requested SKU, that PO is returned in `data.result.purchaseOrders` instead of a duplicate being created. It is not linked, allocated or costed a second time. Concurrent requests for the same work order are serialized.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                include_raw_materials:
                  type: boolean
                  nullable: true
                  default: true
                  description: Whether to include raw material requirements. Defaults to true.
                include_subcontract:
                  type: boolean
                  nullable: true
                  default: true
                  description: Whether to include subcontract requirements. Defaults to true.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/generate-purchase-orders-from-bom':
    post:
      operationId: generateWorkOrderPurchaseOrdersFromBom
      tags:
        - Work Orders
      summary: Generate purchase orders from a work order BOM
      description: |
        Generate purchase orders for a work order based on its bill of materials, optionally with edited groups.

        Component lines come only from the BOM the work order has selected (`bom_id`). Work orders with no `bom_id` fall back to every BOM linked to the produced SKU. This stops a component that appears in several BOMs of the same finished good from producing duplicate PO lines.

        Repeated requests are safe to retry. If an active or draft raw-material PO from the same vendor was created for this work order in the last 5 minutes and already carries every requested SKU, that PO is returned in `data.result.purchaseOrders` instead of a duplicate being created. It is not linked, allocated or costed a second time. Concurrent requests for the same work order are serialized.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                edited_groups:
                  type: array
                  nullable: true
                  description: Optional edited BOM groups to use when generating purchase orders.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/generate-transfer-orders-from-bom':
    post:
      operationId: generateWorkOrderTransferOrdersFromBom
      tags:
        - Work Orders
      summary: Generate transfer orders from a work order BOM
      description: |
        Generate transfer orders for a work order based on its bill of materials.

        Component lines come only from the BOM the work order has selected (`bom_id`). Work orders with no `bom_id` fall back to every BOM linked to the produced SKU, so a component shared by several BOMs of the same finished good is not duplicated.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/generate-finished-goods-transfer-order':
    post:
      operationId: generateWorkOrderFinishedGoodsTransferOrder
      tags:
        - Work Orders
      summary: Generate a finished goods transfer order for a work order
      description: Generate a transfer order moving finished goods produced by a work order to a destination warehouse.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                destination_warehouse_id:
                  type: integer
                  nullable: true
                  description: The warehouse to transfer the finished goods into.
                quantity:
                  type: number
                  nullable: true
                  minimum: 0.01
                  description: The quantity of finished goods to transfer.
                inbound_shipment_id:
                  type: integer
                  nullable: true
                  description: The inbound shipment to associate with the transfer order.
                status:
                  type: string
                  nullable: true
                  enum:
                    - DRAFT
                    - POSTED
                  description: The status of the generated transfer order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/create-assembly-order':
    post:
      operationId: createWorkOrderDraftAssemblyOrder
      tags:
        - Work Orders
      summary: Create a draft assembly order for a work order
      description: Create a new draft assembly order for the work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      assembly_order:
                        type: object
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/create-assembly-order-from-bom-item':
    post:
      operationId: createWorkOrderDraftAssemblyOrderFromBomItem
      tags:
        - Work Orders
      summary: Create a draft assembly order from a work order BOM item
      description: Create a new draft assembly order for a work order based on a specific bill of materials item.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - rfq_id
                - quantity
              properties:
                rfq_id:
                  type: integer
                  description: The RFQ associated with the BOM item.
                quantity:
                  type: number
                  minimum: 0.01
                  description: The quantity for the assembly order.
                step_id:
                  type: integer
                  nullable: true
                  description: The work order step to associate the assembly order with.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      assembly_order:
                        type: object
                        additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/create-assembly-orders-from-bom-items':
    post:
      operationId: createWorkOrderAssemblyOrdersFromBomItems
      tags:
        - Work Orders
      summary: Create draft assembly orders from work order BOM items
      description: Create draft assembly orders for a work order based on its bill of materials items.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/comments':
    get:
      operationId: listWorkOrderComments
      tags:
        - Work Orders
      summary: List work order comments
      description: 'Return all comments for the given work order, including the authoring user and any attachments.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                      properties:
                        id:
                          type: integer
                        work_order_id:
                          type: integer
                        comment:
                          type: string
                        created_by:
                          type: integer
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                        created_by_user:
                          type: object
                          nullable: true
                          additionalProperties: true
                        attachments:
                          type: array
                          items:
                            type: object
                            additionalProperties: true
    post:
      operationId: createWorkOrderComment
      tags:
        - Work Orders
      summary: Create a work order comment
      description: Add a new comment to the given work order. The authenticated user is recorded as the author.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - comment
              properties:
                comment:
                  type: string
                  description: The comment text.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    properties:
                      id:
                        type: integer
                      work_order_id:
                        type: integer
                      comment:
                        type: string
                      created_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by_user:
                        type: object
                        nullable: true
                        additionalProperties: true
                      attachments:
                        type: array
                        items:
                          type: object
                          additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/comments/{commentId}':
    delete:
      operationId: deleteWorkOrderComment
      tags:
        - Work Orders
      summary: Delete a work order comment
      description: Delete a comment from the given work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: commentId
          required: true
          schema:
            type: integer
          description: ID of the comment to delete.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Comment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/comments/{commentId}/attachments':
    post:
      operationId: createWorkOrderCommentAttachment
      tags:
        - Work Orders
      summary: Upload a work order comment attachment
      description: Upload a file attachment to a comment on the given work order. The comment is returned refreshed with its attachments.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: commentId
          required: true
          schema:
            type: integer
          description: ID of the comment to attach the file to.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The file to upload.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    properties:
                      id:
                        type: integer
                      work_order_id:
                        type: integer
                      comment:
                        type: string
                      created_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      created_by_user:
                        type: object
                        nullable: true
                        additionalProperties: true
                      attachments:
                        type: array
                        items:
                          type: object
                          additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Comment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (a valid file is required)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '500':
          description: Upload failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/comments/{commentId}/attachments/{attachmentId}':
    get:
      operationId: downloadWorkOrderCommentAttachment
      tags:
        - Work Orders
      summary: Download a work order comment attachment
      description: Download the binary file for an attachment on a work order comment.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: commentId
          required: true
          schema:
            type: integer
          description: ID of the comment the attachment belongs to.
        - in: path
          name: attachmentId
          required: true
          schema:
            type: integer
          description: ID of the attachment to download.
      responses:
        '200':
          description: The binary attachment file.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '404':
          description: 'Comment, attachment, or file not found'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteWorkOrderCommentAttachment
      tags:
        - Work Orders
      summary: Delete a work order comment attachment
      description: Delete an attachment from a work order comment.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: commentId
          required: true
          schema:
            type: integer
          description: ID of the comment the attachment belongs to.
        - in: path
          name: attachmentId
          required: true
          schema:
            type: integer
          description: ID of the attachment to delete.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Comment or attachment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/material-scrap':
    get:
      operationId: listWorkOrderMaterialScrap
      tags:
        - Work Orders
      summary: List work order material scrap
      description: 'Return all material scrap entries recorded against the given work order, including the component SKU, step requirement, and authoring user.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                      properties:
                        id:
                          type: integer
                        work_order_id:
                          type: integer
                        component_sku_id:
                          type: integer
                        work_order_step_requirement_id:
                          type: integer
                          nullable: true
                        quantity_scrapped:
                          type: number
                        scrap_reason:
                          type: string
                          nullable: true
                        notes:
                          type: string
                          nullable: true
                        created_by:
                          type: integer
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
    post:
      operationId: createWorkOrderMaterialScrap
      tags:
        - Work Orders
      summary: Record work order material scrap
      description: Record a material scrap entry against the given work order. Scrap cannot be recorded for draft work orders.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - component_sku_id
                - quantity_scrapped
              properties:
                component_sku_id:
                  type: integer
                  description: SKU of the component being scrapped.
                work_order_step_requirement_id:
                  type: integer
                  nullable: true
                  description: Optional work order step requirement the scrap is attributed to.
                quantity_scrapped:
                  type: number
                  minimum: 0.0001
                  description: Quantity of the component scrapped. Must be at least 0.0001.
                scrap_reason:
                  type: string
                  nullable: true
                  description: Optional reason for the scrap.
                notes:
                  type: string
                  nullable: true
                  description: Optional free-form notes.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    properties:
                      id:
                        type: integer
                      work_order_id:
                        type: integer
                      component_sku_id:
                        type: integer
                      work_order_step_requirement_id:
                        type: integer
                        nullable: true
                      quantity_scrapped:
                        type: number
                      scrap_reason:
                        type: string
                        nullable: true
                      notes:
                        type: string
                        nullable: true
                      created_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (material scrap cannot be recorded for draft work orders)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/shipments':
    get:
      operationId: listWorkOrderShipments
      tags:
        - Work Orders
      summary: List work order shipments
      description: Return the shipments recorded against a work order. Each item is a raw shipment record.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                      properties:
                        id:
                          type: integer
                        work_order_id:
                          type: integer
                        quantity_shipped:
                          type: number
                        carrier:
                          type: string
                          nullable: true
                        tracking_number:
                          type: string
                          nullable: true
                        status:
                          type: string
                          nullable: true
                        ship_notes:
                          type: string
                          nullable: true
                        shipped_at:
                          type: string
                          format: date-time
                          nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createWorkOrderShipment
      tags:
        - Work Orders
      summary: Create a work order shipment
      description: Record a new shipment against a work order. Not allowed for draft work orders.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - quantity_shipped
              properties:
                quantity_shipped:
                  type: number
                  description: Quantity shipped. Must be at least 0.0001.
                carrier:
                  type: string
                  nullable: true
                  description: Shipping carrier.
                tracking_number:
                  type: string
                  nullable: true
                  description: Carrier tracking number.
                status:
                  type: string
                  nullable: true
                  description: Shipment status.
                notes:
                  type: string
                  nullable: true
                  description: Free-form shipment notes.
                shipped_at:
                  type: string
                  format: date
                  nullable: true
                  description: Date the shipment was sent.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    properties:
                      id:
                        type: integer
                      work_order_id:
                        type: integer
                      quantity_shipped:
                        type: number
                      carrier:
                        type: string
                        nullable: true
                      tracking_number:
                        type: string
                        nullable: true
                      status:
                        type: string
                        nullable: true
                      ship_notes:
                        type: string
                        nullable: true
                      shipped_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (including when the work order is a draft)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/shipments/{shipmentId}':
    put:
      operationId: updateWorkOrderShipment
      tags:
        - Work Orders
      summary: Update a work order shipment
      description: Update mutable fields on an existing work order shipment.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: shipmentId
          required: true
          schema:
            type: integer
          description: ID of the shipment.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                carrier:
                  type: string
                  description: Shipping carrier.
                tracking_number:
                  type: string
                  description: Carrier tracking number.
                status:
                  type: string
                  description: Shipment status.
                notes:
                  type: string
                  description: Free-form shipment notes.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    properties:
                      id:
                        type: integer
                      work_order_id:
                        type: integer
                      quantity_shipped:
                        type: number
                      carrier:
                        type: string
                        nullable: true
                      tracking_number:
                        type: string
                        nullable: true
                      status:
                        type: string
                        nullable: true
                      ship_notes:
                        type: string
                        nullable: true
                      shipped_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order or shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/shipments/{shipmentId}/receive':
    post:
      operationId: receiveWorkOrderShipment
      tags:
        - Work Orders
      summary: Receive a work order shipment
      description: Record receipt of a previously created work order shipment. Returns a 422 if the shipment has already been received.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: shipmentId
          required: true
          schema:
            type: integer
          description: ID of the shipment.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - quantity_received
              properties:
                quantity_received:
                  type: number
                  description: Quantity received. Must be at least 0.
                quantity_damaged:
                  type: number
                  nullable: true
                  description: Quantity received damaged. Must be at least 0.
                notes:
                  type: string
                  nullable: true
                  description: Free-form receipt notes.
                received_at:
                  type: string
                  format: date
                  nullable: true
                  description: Date the shipment was received.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    properties:
                      id:
                        type: integer
                      work_order_id:
                        type: integer
                      quantity_shipped:
                        type: number
                      carrier:
                        type: string
                        nullable: true
                      tracking_number:
                        type: string
                        nullable: true
                      status:
                        type: string
                        nullable: true
                      ship_notes:
                        type: string
                        nullable: true
                      shipped_at:
                        type: string
                        format: date-time
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order or shipment not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (including when the shipment has already been received)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/shipment-receipts':
    get:
      operationId: listWorkOrderShipmentReceipts
      tags:
        - Work Orders
      summary: List work order shipment receipts
      description: Return the shipment receipts recorded against a work order. Each item is a raw shipment receipt record.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createWorkOrderShipmentReceipt
      tags:
        - Work Orders
      summary: Create a work order shipment receipt
      description: Record a new shipment receipt against a work order. Not allowed for draft work orders.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - quantity_received
              properties:
                quantity_received:
                  type: number
                  description: Quantity received. Must be at least 0.0001.
                notes:
                  type: string
                  nullable: true
                  description: Free-form receipt notes.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error (including when the work order is a draft)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/work-orders/{workOrderId}/shipment-receipts/{receiptId}':
    delete:
      operationId: deleteWorkOrderShipmentReceipt
      tags:
        - Work Orders
      summary: Delete a work order shipment receipt
      description: Delete a shipment receipt from a work order.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
          description: ID of the work order.
        - in: path
          name: receiptId
          required: true
          schema:
            type: integer
          description: ID of the shipment receipt.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Work order or shipment receipt not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /production-batches:
    get:
      operationId: listProductionBatches
      tags:
        - Production Batches
      summary: List production batches
      description: Return a paginated list of production batches.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
        - in: query
          name: limit
          schema:
            type: integer
            default: 25
        - in: query
          name: sort_by
          schema:
            type: string
        - in: query
          name: sort_direction
          schema:
            type: string
            enum:
              - asc
              - desc
        - in: query
          name: search
          schema:
            type: string
        - in: query
          name: status
          description: 'Comma-separated list of statuses to filter by (e.g. `status=draft,in_progress`; `status[]=...` and `status[in]=...` are equivalent). Use `status[notin]=...` to exclude batches in the listed statuses instead (e.g. `status[notin]=completed,cancelled`).'
          schema:
            type: string
        - in: query
          name: vendor_id
          description: Filter batches by vendor.
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        batch_number:
                          type: string
                        name:
                          type: string
                          nullable: true
                        status:
                          type: string
                          description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                        vendor_id:
                          type: integer
                          nullable: true
                        co_manufacturer_id:
                          type: integer
                          nullable: true
                          description: Alias of `vendor_id` (always the same value).
                        vendor:
                          type: object
                          nullable: true
                          description: Present only when the vendor relation is loaded.
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        production_warehouse_id:
                          type: integer
                          nullable: true
                          description: ID of the warehouse where the batch is produced.
                        production_warehouse:
                          type: object
                          nullable: true
                          description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        destination_warehouse_id:
                          type: integer
                          nullable: true
                          description: ID of the warehouse that receives the finished goods.
                        destination_warehouse:
                          type: object
                          nullable: true
                          description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        work_order_count:
                          type: integer
                          description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                        work_orders:
                          type: array
                          description: Work orders in the batch. Present only when the workOrders relation is loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              work_order_number:
                                type: string
                              status:
                                type: string
                                description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                              is_on_hold:
                                type: boolean
                              produced_sku_id:
                                type: integer
                                nullable: true
                                description: ID of the SKU (request_for_quotes record) being produced.
                              produced_sku:
                                type: object
                                nullable: true
                                description: Present only when the producedSku relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  sku:
                                    type: string
                                  description:
                                    type: string
                                    nullable: true
                              planned_qty:
                                type: number
                                description: Quantity planned to be produced.
                              completion_trigger:
                                type: string
                                nullable: true
                                description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                                enum:
                                  - manual
                                  - finish_step
                                  - receipt
                              expected_completion_date:
                                type: string
                                format: date
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              production_warehouse_id:
                                type: integer
                                nullable: true
                              production_warehouse:
                                type: object
                                nullable: true
                                description: Present only when the productionWarehouse relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              destination_warehouse_id:
                                type: integer
                                nullable: true
                              destination_warehouse:
                                type: object
                                nullable: true
                                description: Present only when the destinationWarehouse relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              vendor_id:
                                type: integer
                                nullable: true
                                description: Co-manufacturer (subcontract) vendor ID.
                              co_manufacturer_id:
                                type: integer
                                nullable: true
                                description: Alias of `vendor_id` (always the same value).
                              vendor:
                                type: object
                                nullable: true
                                description: Present only when the vendor relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              co_manufacturer:
                                type: object
                                nullable: true
                                description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              bom_id:
                                type: integer
                                nullable: true
                              work_order_kind:
                                type: string
                                enum:
                                  - build
                                  - service
                                description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                              service_unit_price:
                                type: number
                                nullable: true
                                description: Per-unit service fee for subcontract production.
                              cost_rule_resolution:
                                type: object
                                nullable: true
                                description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                                properties:
                                  used_cost_rule:
                                    type: boolean
                                    description: True when a cost rule produced the price; false for a fallback resolution.
                                  cost_rule_id:
                                    type: integer
                                    nullable: true
                                  cost_rule_name:
                                    type: string
                                    nullable: true
                                  resolved_unit_cost:
                                    type: number
                                    nullable: true
                                    description: The per-unit cost the engine resolved to.
                                  fallback_source:
                                    type: string
                                    nullable: true
                                    description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                  tier_min_qty:
                                    type: number
                                    nullable: true
                                    description: Minimum quantity of the matched cost-rule tier.
                                  breakdown:
                                    type: array
                                    description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                    items:
                                      type: object
                                      properties:
                                        effect:
                                          type: string
                                          description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                        description:
                                          type: string
                                          nullable: true
                                        amount:
                                          type: string
                                          description: 'The step''s amount, as a string. Defaults to `0`.'
                                        delta:
                                          type: string
                                          description: 'Change applied at this step, as a string. Defaults to `0`.'
                                        result:
                                          type: string
                                          description: 'Running total after this step, as a string. Defaults to `0`.'
                                        costRuleId:
                                          type: integer
                                          nullable: true
                                          description: Identity of the rule that contributed this step.
                                        costRuleName:
                                          type: string
                                          nullable: true
                                  next_tier_hint:
                                    type: object
                                    nullable: true
                                    description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                    properties:
                                      min_qty:
                                        type: number
                                        nullable: true
                                      unit_cost:
                                        type: number
                                        nullable: true
                                      savings:
                                        type: number
                                        nullable: true
                              notes:
                                type: string
                                nullable: true
                              hold_reason:
                                type: string
                                nullable: true
                              cancel_reason:
                                type: string
                                nullable: true
                              held_at:
                                type: string
                                format: date-time
                                nullable: true
                              created_by:
                                type: integer
                                nullable: true
                              updated_by:
                                type: integer
                                nullable: true
                              held_by:
                                type: integer
                                nullable: true
                              production_batch_id:
                                type: integer
                                nullable: true
                              steps:
                                type: array
                                description: Production steps. Present only when the steps relation is loaded.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    work_order_id:
                                      type: integer
                                    sequence:
                                      type: integer
                                      description: Order of the step within the work order's routing.
                                    status:
                                      type: string
                                      description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                    output_sku_id:
                                      type: integer
                                      nullable: true
                                    output_sku:
                                      type: object
                                      nullable: true
                                      description: Present only when the outputSku relation is loaded.
                                      properties:
                                        id:
                                          type: integer
                                        sku:
                                          type: string
                                        description:
                                          type: string
                                          nullable: true
                                    planned_qty:
                                      type: number
                                      description: Quantity planned to be produced by this step.
                                    completed_qty:
                                      type: number
                                      description: Quantity completed so far for this step.
                                    is_outside_processing:
                                      type: boolean
                                      description: Whether this step is performed by an outside (subcontract) vendor.
                                    supply_mode:
                                      type: string
                                      nullable: true
                                    vendor_id:
                                      type: integer
                                      nullable: true
                                    skipped_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    skipped_by:
                                      type: integer
                                      nullable: true
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                              custom_fields:
                                type: object
                                nullable: true
                                description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties: true
                              alternate_ids:
                                type: array
                                description: External alternate identifiers. Present only when loaded.
                                items:
                                  type: string
                              links:
                                type: object
                                description: HATEOAS links to related sub-resources.
                                properties:
                                  self:
                                    type: string
                                  steps:
                                    type: string
                                  completions:
                                    type: string
                                  production_entries:
                                    type: string
                                  status_history:
                                    type: string
                        expected_completion_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                        notes:
                          type: string
                          nullable: true
                        payment_terms:
                          type: string
                          nullable: true
                          description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                          example: Net 30
                        custom_fields:
                          type: object
                          nullable: true
                          description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        created_by:
                          type: integer
                          nullable: true
                        updated_by:
                          type: integer
                          nullable: true
                        links:
                          type: object
                          description: HATEOAS links to related sub-resources.
                          properties:
                            self:
                              type: string
                            work_orders:
                              type: string
                            summary:
                              type: string
                            po_links:
                              type: string
                            ao_links:
                              type: string
                            status_history:
                              type: string
                  links:
                    type: object
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
    post:
      operationId: createProductionBatch
      tags:
        - Production Batches
      summary: Create a production batch
      description: 'Create a new production batch, optionally linking work orders.'
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Name of the production batch.
                vendor_id:
                  type: integer
                  nullable: true
                  description: Vendor associated with the batch.
                co_manufacturer_id:
                  type: integer
                  nullable: true
                  description: 'Alias of `vendor_id`. When both are sent, `vendor_id` wins.'
                production_warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the warehouse where the batch is produced.
                destination_warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the warehouse that receives the finished goods.
                notes:
                  type: string
                  nullable: true
                  description: Free-form notes for the batch.
                payment_terms:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: 'Payment terms for the batch. Must exactly match one of Luminous''s standard payment term names (e.g. `Net 30`, `50/50`, `Due on Receipt`, `100% Down`); matching is case-sensitive and any other value returns `422`.'
                  example: Net 30
                work_order_ids:
                  type: array
                  nullable: true
                  description: Work order IDs to link to the batch on creation.
                  items:
                    type: integer
                custom_fields:
                  type: object
                  nullable: true
                  description: 'Custom field values for the production batch, keyed by field label.'
                  additionalProperties:
                    oneOf:
                      - type: string
                      - type: number
                      - type: boolean
                  example:
                    Line: Line A
                    Shift: Night
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      batch_number:
                        type: string
                      name:
                        type: string
                        nullable: true
                      status:
                        type: string
                        description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                      vendor_id:
                        type: integer
                        nullable: true
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      production_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse where the batch is produced.
                      production_warehouse:
                        type: object
                        nullable: true
                        description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse that receives the finished goods.
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      work_order_count:
                        type: integer
                        description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                      work_orders:
                        type: array
                        description: Work orders in the batch. Present only when the workOrders relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                            is_on_hold:
                              type: boolean
                            produced_sku_id:
                              type: integer
                              nullable: true
                              description: ID of the SKU (request_for_quotes record) being produced.
                            produced_sku:
                              type: object
                              nullable: true
                              description: Present only when the producedSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced.
                            completion_trigger:
                              type: string
                              nullable: true
                              description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                              enum:
                                - manual
                                - finish_step
                                - receipt
                            expected_completion_date:
                              type: string
                              format: date
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            production_warehouse_id:
                              type: integer
                              nullable: true
                            production_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the productionWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            destination_warehouse_id:
                              type: integer
                              nullable: true
                            destination_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the destinationWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            vendor_id:
                              type: integer
                              nullable: true
                              description: Co-manufacturer (subcontract) vendor ID.
                            co_manufacturer_id:
                              type: integer
                              nullable: true
                              description: Alias of `vendor_id` (always the same value).
                            vendor:
                              type: object
                              nullable: true
                              description: Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            co_manufacturer:
                              type: object
                              nullable: true
                              description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            bom_id:
                              type: integer
                              nullable: true
                            work_order_kind:
                              type: string
                              enum:
                                - build
                                - service
                              description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                            service_unit_price:
                              type: number
                              nullable: true
                              description: Per-unit service fee for subcontract production.
                            cost_rule_resolution:
                              type: object
                              nullable: true
                              description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                              properties:
                                used_cost_rule:
                                  type: boolean
                                  description: True when a cost rule produced the price; false for a fallback resolution.
                                cost_rule_id:
                                  type: integer
                                  nullable: true
                                cost_rule_name:
                                  type: string
                                  nullable: true
                                resolved_unit_cost:
                                  type: number
                                  nullable: true
                                  description: The per-unit cost the engine resolved to.
                                fallback_source:
                                  type: string
                                  nullable: true
                                  description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                tier_min_qty:
                                  type: number
                                  nullable: true
                                  description: Minimum quantity of the matched cost-rule tier.
                                breakdown:
                                  type: array
                                  description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                  items:
                                    type: object
                                    properties:
                                      effect:
                                        type: string
                                        description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                      description:
                                        type: string
                                        nullable: true
                                      amount:
                                        type: string
                                        description: 'The step''s amount, as a string. Defaults to `0`.'
                                      delta:
                                        type: string
                                        description: 'Change applied at this step, as a string. Defaults to `0`.'
                                      result:
                                        type: string
                                        description: 'Running total after this step, as a string. Defaults to `0`.'
                                      costRuleId:
                                        type: integer
                                        nullable: true
                                        description: Identity of the rule that contributed this step.
                                      costRuleName:
                                        type: string
                                        nullable: true
                                next_tier_hint:
                                  type: object
                                  nullable: true
                                  description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                  properties:
                                    min_qty:
                                      type: number
                                      nullable: true
                                    unit_cost:
                                      type: number
                                      nullable: true
                                    savings:
                                      type: number
                                      nullable: true
                            notes:
                              type: string
                              nullable: true
                            hold_reason:
                              type: string
                              nullable: true
                            cancel_reason:
                              type: string
                              nullable: true
                            held_at:
                              type: string
                              format: date-time
                              nullable: true
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            held_by:
                              type: integer
                              nullable: true
                            production_batch_id:
                              type: integer
                              nullable: true
                            steps:
                              type: array
                              description: Production steps. Present only when the steps relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  work_order_id:
                                    type: integer
                                  sequence:
                                    type: integer
                                    description: Order of the step within the work order's routing.
                                  status:
                                    type: string
                                    description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                  output_sku_id:
                                    type: integer
                                    nullable: true
                                  output_sku:
                                    type: object
                                    nullable: true
                                    description: Present only when the outputSku relation is loaded.
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  planned_qty:
                                    type: number
                                    description: Quantity planned to be produced by this step.
                                  completed_qty:
                                    type: number
                                    description: Quantity completed so far for this step.
                                  is_outside_processing:
                                    type: boolean
                                    description: Whether this step is performed by an outside (subcontract) vendor.
                                  supply_mode:
                                    type: string
                                    nullable: true
                                  vendor_id:
                                    type: integer
                                    nullable: true
                                  skipped_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  skipped_by:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            custom_fields:
                              type: object
                              nullable: true
                              description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties: true
                            alternate_ids:
                              type: array
                              description: External alternate identifiers. Present only when loaded.
                              items:
                                type: string
                            links:
                              type: object
                              description: HATEOAS links to related sub-resources.
                              properties:
                                self:
                                  type: string
                                steps:
                                  type: string
                                completions:
                                  type: string
                                production_entries:
                                  type: string
                                status_history:
                                  type: string
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                      notes:
                        type: string
                        nullable: true
                      payment_terms:
                        type: string
                        nullable: true
                        description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                        example: Net 30
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          work_orders:
                            type: string
                          summary:
                            type: string
                          po_links:
                            type: string
                          ao_links:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /production-batches/bulk/status:
    post:
      operationId: bulkUpdateProductionBatchStatus
      tags:
        - Production Batches
      summary: Bulk update production batch status
      description: Update the status of multiple production batches at once.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - batch_ids
                - status
              properties:
                batch_ids:
                  type: array
                  minItems: 1
                  description: IDs of the production batches to update.
                  items:
                    type: integer
                status:
                  type: string
                  enum:
                    - draft
                    - planned
                    - in_progress
                  description: New status to apply to the batches.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /production-batches/bulk/work-orders:
    delete:
      operationId: bulkRemoveProductionBatchWorkOrders
      tags:
        - Production Batches
      summary: Bulk remove work orders from batches
      description: Remove work orders from one or more production batches in a single request.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - removals
              properties:
                removals:
                  type: array
                  minItems: 1
                  description: List of batch/work-order removal instructions.
                  items:
                    type: object
                    required:
                      - batch_id
                      - work_order_ids
                    properties:
                      batch_id:
                        type: integer
                        description: Production batch to remove work orders from.
                      work_order_ids:
                        type: array
                        minItems: 1
                        description: Work order IDs to remove from the batch.
                        items:
                          type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /production-batches/available-for-linking:
    get:
      operationId: listProductionBatchesAvailableForLinking
      tags:
        - Production Batches
      summary: List production batches available for linking
      description: Return production batches that are available to be linked to work orders.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        batch_number:
                          type: string
                        name:
                          type: string
                          nullable: true
                        status:
                          type: string
                          description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                        vendor_id:
                          type: integer
                          nullable: true
                        co_manufacturer_id:
                          type: integer
                          nullable: true
                          description: Alias of `vendor_id` (always the same value).
                        vendor:
                          type: object
                          nullable: true
                          description: Present only when the vendor relation is loaded.
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        production_warehouse_id:
                          type: integer
                          nullable: true
                          description: ID of the warehouse where the batch is produced.
                        production_warehouse:
                          type: object
                          nullable: true
                          description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        destination_warehouse_id:
                          type: integer
                          nullable: true
                          description: ID of the warehouse that receives the finished goods.
                        destination_warehouse:
                          type: object
                          nullable: true
                          description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        work_order_count:
                          type: integer
                          description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                        work_orders:
                          type: array
                          description: Work orders in the batch. Present only when the workOrders relation is loaded.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              work_order_number:
                                type: string
                              status:
                                type: string
                                description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                              is_on_hold:
                                type: boolean
                              produced_sku_id:
                                type: integer
                                nullable: true
                                description: ID of the SKU (request_for_quotes record) being produced.
                              produced_sku:
                                type: object
                                nullable: true
                                description: Present only when the producedSku relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  sku:
                                    type: string
                                  description:
                                    type: string
                                    nullable: true
                              planned_qty:
                                type: number
                                description: Quantity planned to be produced.
                              completion_trigger:
                                type: string
                                nullable: true
                                description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                                enum:
                                  - manual
                                  - finish_step
                                  - receipt
                              expected_completion_date:
                                type: string
                                format: date
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                              production_warehouse_id:
                                type: integer
                                nullable: true
                              production_warehouse:
                                type: object
                                nullable: true
                                description: Present only when the productionWarehouse relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              destination_warehouse_id:
                                type: integer
                                nullable: true
                              destination_warehouse:
                                type: object
                                nullable: true
                                description: Present only when the destinationWarehouse relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              vendor_id:
                                type: integer
                                nullable: true
                                description: Co-manufacturer (subcontract) vendor ID.
                              co_manufacturer_id:
                                type: integer
                                nullable: true
                                description: Alias of `vendor_id` (always the same value).
                              vendor:
                                type: object
                                nullable: true
                                description: Present only when the vendor relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              co_manufacturer:
                                type: object
                                nullable: true
                                description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                              bom_id:
                                type: integer
                                nullable: true
                              work_order_kind:
                                type: string
                                enum:
                                  - build
                                  - service
                                description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                              service_unit_price:
                                type: number
                                nullable: true
                                description: Per-unit service fee for subcontract production.
                              cost_rule_resolution:
                                type: object
                                nullable: true
                                description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                                properties:
                                  used_cost_rule:
                                    type: boolean
                                    description: True when a cost rule produced the price; false for a fallback resolution.
                                  cost_rule_id:
                                    type: integer
                                    nullable: true
                                  cost_rule_name:
                                    type: string
                                    nullable: true
                                  resolved_unit_cost:
                                    type: number
                                    nullable: true
                                    description: The per-unit cost the engine resolved to.
                                  fallback_source:
                                    type: string
                                    nullable: true
                                    description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                  tier_min_qty:
                                    type: number
                                    nullable: true
                                    description: Minimum quantity of the matched cost-rule tier.
                                  breakdown:
                                    type: array
                                    description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                    items:
                                      type: object
                                      properties:
                                        effect:
                                          type: string
                                          description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                        description:
                                          type: string
                                          nullable: true
                                        amount:
                                          type: string
                                          description: 'The step''s amount, as a string. Defaults to `0`.'
                                        delta:
                                          type: string
                                          description: 'Change applied at this step, as a string. Defaults to `0`.'
                                        result:
                                          type: string
                                          description: 'Running total after this step, as a string. Defaults to `0`.'
                                        costRuleId:
                                          type: integer
                                          nullable: true
                                          description: Identity of the rule that contributed this step.
                                        costRuleName:
                                          type: string
                                          nullable: true
                                  next_tier_hint:
                                    type: object
                                    nullable: true
                                    description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                    properties:
                                      min_qty:
                                        type: number
                                        nullable: true
                                      unit_cost:
                                        type: number
                                        nullable: true
                                      savings:
                                        type: number
                                        nullable: true
                              notes:
                                type: string
                                nullable: true
                              hold_reason:
                                type: string
                                nullable: true
                              cancel_reason:
                                type: string
                                nullable: true
                              held_at:
                                type: string
                                format: date-time
                                nullable: true
                              created_by:
                                type: integer
                                nullable: true
                              updated_by:
                                type: integer
                                nullable: true
                              held_by:
                                type: integer
                                nullable: true
                              production_batch_id:
                                type: integer
                                nullable: true
                              steps:
                                type: array
                                description: Production steps. Present only when the steps relation is loaded.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    work_order_id:
                                      type: integer
                                    sequence:
                                      type: integer
                                      description: Order of the step within the work order's routing.
                                    status:
                                      type: string
                                      description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                    output_sku_id:
                                      type: integer
                                      nullable: true
                                    output_sku:
                                      type: object
                                      nullable: true
                                      description: Present only when the outputSku relation is loaded.
                                      properties:
                                        id:
                                          type: integer
                                        sku:
                                          type: string
                                        description:
                                          type: string
                                          nullable: true
                                    planned_qty:
                                      type: number
                                      description: Quantity planned to be produced by this step.
                                    completed_qty:
                                      type: number
                                      description: Quantity completed so far for this step.
                                    is_outside_processing:
                                      type: boolean
                                      description: Whether this step is performed by an outside (subcontract) vendor.
                                    supply_mode:
                                      type: string
                                      nullable: true
                                    vendor_id:
                                      type: integer
                                      nullable: true
                                    skipped_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    skipped_by:
                                      type: integer
                                      nullable: true
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                              custom_fields:
                                type: object
                                nullable: true
                                description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties: true
                              alternate_ids:
                                type: array
                                description: External alternate identifiers. Present only when loaded.
                                items:
                                  type: string
                              links:
                                type: object
                                description: HATEOAS links to related sub-resources.
                                properties:
                                  self:
                                    type: string
                                  steps:
                                    type: string
                                  completions:
                                    type: string
                                  production_entries:
                                    type: string
                                  status_history:
                                    type: string
                        expected_completion_date:
                          type: string
                          format: date
                          nullable: true
                          description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                        notes:
                          type: string
                          nullable: true
                        payment_terms:
                          type: string
                          nullable: true
                          description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                          example: Net 30
                        custom_fields:
                          type: object
                          nullable: true
                          description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                          additionalProperties: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
                        created_by:
                          type: integer
                          nullable: true
                        updated_by:
                          type: integer
                          nullable: true
                        links:
                          type: object
                          description: HATEOAS links to related sub-resources.
                          properties:
                            self:
                              type: string
                            work_orders:
                              type: string
                            summary:
                              type: string
                            po_links:
                              type: string
                            ao_links:
                              type: string
                            status_history:
                              type: string
  '/production-batches/{batchId}':
    get:
      operationId: getProductionBatchById
      tags:
        - Production Batches
      summary: Get a production batch
      description: 'Return a single production batch, including its linked work orders, vendor, and production/destination warehouses.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      batch_number:
                        type: string
                      name:
                        type: string
                        nullable: true
                      status:
                        type: string
                        description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                      vendor_id:
                        type: integer
                        nullable: true
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      production_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse where the batch is produced.
                      production_warehouse:
                        type: object
                        nullable: true
                        description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse that receives the finished goods.
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      work_order_count:
                        type: integer
                        description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                      work_orders:
                        type: array
                        description: Work orders in the batch. Present only when the workOrders relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                            is_on_hold:
                              type: boolean
                            produced_sku_id:
                              type: integer
                              nullable: true
                              description: ID of the SKU (request_for_quotes record) being produced.
                            produced_sku:
                              type: object
                              nullable: true
                              description: Present only when the producedSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced.
                            completion_trigger:
                              type: string
                              nullable: true
                              description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                              enum:
                                - manual
                                - finish_step
                                - receipt
                            expected_completion_date:
                              type: string
                              format: date
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            production_warehouse_id:
                              type: integer
                              nullable: true
                            production_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the productionWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            destination_warehouse_id:
                              type: integer
                              nullable: true
                            destination_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the destinationWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            vendor_id:
                              type: integer
                              nullable: true
                              description: Co-manufacturer (subcontract) vendor ID.
                            co_manufacturer_id:
                              type: integer
                              nullable: true
                              description: Alias of `vendor_id` (always the same value).
                            vendor:
                              type: object
                              nullable: true
                              description: Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            co_manufacturer:
                              type: object
                              nullable: true
                              description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            bom_id:
                              type: integer
                              nullable: true
                            work_order_kind:
                              type: string
                              enum:
                                - build
                                - service
                              description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                            service_unit_price:
                              type: number
                              nullable: true
                              description: Per-unit service fee for subcontract production.
                            cost_rule_resolution:
                              type: object
                              nullable: true
                              description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                              properties:
                                used_cost_rule:
                                  type: boolean
                                  description: True when a cost rule produced the price; false for a fallback resolution.
                                cost_rule_id:
                                  type: integer
                                  nullable: true
                                cost_rule_name:
                                  type: string
                                  nullable: true
                                resolved_unit_cost:
                                  type: number
                                  nullable: true
                                  description: The per-unit cost the engine resolved to.
                                fallback_source:
                                  type: string
                                  nullable: true
                                  description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                tier_min_qty:
                                  type: number
                                  nullable: true
                                  description: Minimum quantity of the matched cost-rule tier.
                                breakdown:
                                  type: array
                                  description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                  items:
                                    type: object
                                    properties:
                                      effect:
                                        type: string
                                        description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                      description:
                                        type: string
                                        nullable: true
                                      amount:
                                        type: string
                                        description: 'The step''s amount, as a string. Defaults to `0`.'
                                      delta:
                                        type: string
                                        description: 'Change applied at this step, as a string. Defaults to `0`.'
                                      result:
                                        type: string
                                        description: 'Running total after this step, as a string. Defaults to `0`.'
                                      costRuleId:
                                        type: integer
                                        nullable: true
                                        description: Identity of the rule that contributed this step.
                                      costRuleName:
                                        type: string
                                        nullable: true
                                next_tier_hint:
                                  type: object
                                  nullable: true
                                  description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                  properties:
                                    min_qty:
                                      type: number
                                      nullable: true
                                    unit_cost:
                                      type: number
                                      nullable: true
                                    savings:
                                      type: number
                                      nullable: true
                            notes:
                              type: string
                              nullable: true
                            hold_reason:
                              type: string
                              nullable: true
                            cancel_reason:
                              type: string
                              nullable: true
                            held_at:
                              type: string
                              format: date-time
                              nullable: true
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            held_by:
                              type: integer
                              nullable: true
                            production_batch_id:
                              type: integer
                              nullable: true
                            steps:
                              type: array
                              description: Production steps. Present only when the steps relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  work_order_id:
                                    type: integer
                                  sequence:
                                    type: integer
                                    description: Order of the step within the work order's routing.
                                  status:
                                    type: string
                                    description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                  output_sku_id:
                                    type: integer
                                    nullable: true
                                  output_sku:
                                    type: object
                                    nullable: true
                                    description: Present only when the outputSku relation is loaded.
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  planned_qty:
                                    type: number
                                    description: Quantity planned to be produced by this step.
                                  completed_qty:
                                    type: number
                                    description: Quantity completed so far for this step.
                                  is_outside_processing:
                                    type: boolean
                                    description: Whether this step is performed by an outside (subcontract) vendor.
                                  supply_mode:
                                    type: string
                                    nullable: true
                                  vendor_id:
                                    type: integer
                                    nullable: true
                                  skipped_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  skipped_by:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            custom_fields:
                              type: object
                              nullable: true
                              description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties: true
                            alternate_ids:
                              type: array
                              description: External alternate identifiers. Present only when loaded.
                              items:
                                type: string
                            links:
                              type: object
                              description: HATEOAS links to related sub-resources.
                              properties:
                                self:
                                  type: string
                                steps:
                                  type: string
                                completions:
                                  type: string
                                production_entries:
                                  type: string
                                status_history:
                                  type: string
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                      notes:
                        type: string
                        nullable: true
                      payment_terms:
                        type: string
                        nullable: true
                        description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                        example: Net 30
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          work_orders:
                            type: string
                          summary:
                            type: string
                          po_links:
                            type: string
                          ao_links:
                            type: string
                          status_history:
                            type: string
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    put:
      operationId: updateProductionBatch
      tags:
        - Production Batches
      summary: Update a production batch
      description: 'Update the name, vendor, production/destination warehouses, notes, payment terms, expected completion date, or custom fields of a production batch. Only the fields you send are changed.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: Name of the production batch.
                vendor_id:
                  type: integer
                  nullable: true
                  description: Vendor associated with the batch.
                co_manufacturer_id:
                  type: integer
                  nullable: true
                  description: 'Alias of `vendor_id`. When both are sent, `vendor_id` wins. Sending either key (including an explicit `null` to clear) updates the vendor; omitting both leaves the existing vendor unchanged.'
                production_warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the warehouse where the batch is produced. Omit (or send `null`) to leave it unchanged; it cannot be cleared through the API.
                destination_warehouse_id:
                  type: integer
                  nullable: true
                  description: ID of the warehouse that receives the finished goods. Omit (or send `null`) to leave it unchanged; it cannot be cleared through the API.
                notes:
                  type: string
                  nullable: true
                  description: Free-form notes for the batch.
                payment_terms:
                  type: string
                  maxLength: 255
                  nullable: true
                  description: 'Payment terms for the batch. Must exactly match one of Luminous''s standard payment term names (e.g. `Net 30`, `50/50`, `Due on Receipt`, `100% Down`); matching is case-sensitive and any other value returns `422`. Send `null` to clear the terms.'
                  example: Net 30
                expected_completion_date:
                  type: string
                  format: date
                  nullable: true
                  description: 'The batch''s own expected completion date. Can be set in any status. Omit (or send `null`) to leave it unchanged; it cannot be cleared through the API. This does not change the work orders'' dates; use `PATCH /production-batches/{batchId}/work-orders/fields` for that.'
                  example: '2026-11-20'
                custom_fields:
                  type: object
                  nullable: true
                  description: 'Custom field values for the production batch, keyed by field label.'
                  additionalProperties:
                    oneOf:
                      - type: string
                      - type: number
                      - type: boolean
                  example:
                    Line: Line A
                    Shift: Night
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      batch_number:
                        type: string
                      name:
                        type: string
                        nullable: true
                      status:
                        type: string
                        description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                      vendor_id:
                        type: integer
                        nullable: true
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      production_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse where the batch is produced.
                      production_warehouse:
                        type: object
                        nullable: true
                        description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse that receives the finished goods.
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      work_order_count:
                        type: integer
                        description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                      work_orders:
                        type: array
                        description: Work orders in the batch. Present only when the workOrders relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                            is_on_hold:
                              type: boolean
                            produced_sku_id:
                              type: integer
                              nullable: true
                              description: ID of the SKU (request_for_quotes record) being produced.
                            produced_sku:
                              type: object
                              nullable: true
                              description: Present only when the producedSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced.
                            completion_trigger:
                              type: string
                              nullable: true
                              description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                              enum:
                                - manual
                                - finish_step
                                - receipt
                            expected_completion_date:
                              type: string
                              format: date
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            production_warehouse_id:
                              type: integer
                              nullable: true
                            production_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the productionWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            destination_warehouse_id:
                              type: integer
                              nullable: true
                            destination_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the destinationWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            vendor_id:
                              type: integer
                              nullable: true
                              description: Co-manufacturer (subcontract) vendor ID.
                            co_manufacturer_id:
                              type: integer
                              nullable: true
                              description: Alias of `vendor_id` (always the same value).
                            vendor:
                              type: object
                              nullable: true
                              description: Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            co_manufacturer:
                              type: object
                              nullable: true
                              description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            bom_id:
                              type: integer
                              nullable: true
                            work_order_kind:
                              type: string
                              enum:
                                - build
                                - service
                              description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                            service_unit_price:
                              type: number
                              nullable: true
                              description: Per-unit service fee for subcontract production.
                            cost_rule_resolution:
                              type: object
                              nullable: true
                              description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                              properties:
                                used_cost_rule:
                                  type: boolean
                                  description: True when a cost rule produced the price; false for a fallback resolution.
                                cost_rule_id:
                                  type: integer
                                  nullable: true
                                cost_rule_name:
                                  type: string
                                  nullable: true
                                resolved_unit_cost:
                                  type: number
                                  nullable: true
                                  description: The per-unit cost the engine resolved to.
                                fallback_source:
                                  type: string
                                  nullable: true
                                  description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                tier_min_qty:
                                  type: number
                                  nullable: true
                                  description: Minimum quantity of the matched cost-rule tier.
                                breakdown:
                                  type: array
                                  description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                  items:
                                    type: object
                                    properties:
                                      effect:
                                        type: string
                                        description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                      description:
                                        type: string
                                        nullable: true
                                      amount:
                                        type: string
                                        description: 'The step''s amount, as a string. Defaults to `0`.'
                                      delta:
                                        type: string
                                        description: 'Change applied at this step, as a string. Defaults to `0`.'
                                      result:
                                        type: string
                                        description: 'Running total after this step, as a string. Defaults to `0`.'
                                      costRuleId:
                                        type: integer
                                        nullable: true
                                        description: Identity of the rule that contributed this step.
                                      costRuleName:
                                        type: string
                                        nullable: true
                                next_tier_hint:
                                  type: object
                                  nullable: true
                                  description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                  properties:
                                    min_qty:
                                      type: number
                                      nullable: true
                                    unit_cost:
                                      type: number
                                      nullable: true
                                    savings:
                                      type: number
                                      nullable: true
                            notes:
                              type: string
                              nullable: true
                            hold_reason:
                              type: string
                              nullable: true
                            cancel_reason:
                              type: string
                              nullable: true
                            held_at:
                              type: string
                              format: date-time
                              nullable: true
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            held_by:
                              type: integer
                              nullable: true
                            production_batch_id:
                              type: integer
                              nullable: true
                            steps:
                              type: array
                              description: Production steps. Present only when the steps relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  work_order_id:
                                    type: integer
                                  sequence:
                                    type: integer
                                    description: Order of the step within the work order's routing.
                                  status:
                                    type: string
                                    description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                  output_sku_id:
                                    type: integer
                                    nullable: true
                                  output_sku:
                                    type: object
                                    nullable: true
                                    description: Present only when the outputSku relation is loaded.
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  planned_qty:
                                    type: number
                                    description: Quantity planned to be produced by this step.
                                  completed_qty:
                                    type: number
                                    description: Quantity completed so far for this step.
                                  is_outside_processing:
                                    type: boolean
                                    description: Whether this step is performed by an outside (subcontract) vendor.
                                  supply_mode:
                                    type: string
                                    nullable: true
                                  vendor_id:
                                    type: integer
                                    nullable: true
                                  skipped_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  skipped_by:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            custom_fields:
                              type: object
                              nullable: true
                              description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties: true
                            alternate_ids:
                              type: array
                              description: External alternate identifiers. Present only when loaded.
                              items:
                                type: string
                            links:
                              type: object
                              description: HATEOAS links to related sub-resources.
                              properties:
                                self:
                                  type: string
                                steps:
                                  type: string
                                completions:
                                  type: string
                                production_entries:
                                  type: string
                                status_history:
                                  type: string
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                      notes:
                        type: string
                        nullable: true
                      payment_terms:
                        type: string
                        nullable: true
                        description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                        example: Net 30
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          work_orders:
                            type: string
                          summary:
                            type: string
                          po_links:
                            type: string
                          ao_links:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteProductionBatch
      tags:
        - Production Batches
      summary: Delete a production batch
      description: Delete a production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/work-orders':
    post:
      operationId: addWorkOrdersToProductionBatch
      tags:
        - Production Batches
      summary: Add work orders to a production batch
      description: Link one or more work orders to a production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - work_order_ids
              properties:
                work_order_ids:
                  type: array
                  minItems: 1
                  description: Work order IDs to link to the batch.
                  items:
                    type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      batch_number:
                        type: string
                      name:
                        type: string
                        nullable: true
                      status:
                        type: string
                        description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                      vendor_id:
                        type: integer
                        nullable: true
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      production_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse where the batch is produced.
                      production_warehouse:
                        type: object
                        nullable: true
                        description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse that receives the finished goods.
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      work_order_count:
                        type: integer
                        description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                      work_orders:
                        type: array
                        description: Work orders in the batch. Present only when the workOrders relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                            is_on_hold:
                              type: boolean
                            produced_sku_id:
                              type: integer
                              nullable: true
                              description: ID of the SKU (request_for_quotes record) being produced.
                            produced_sku:
                              type: object
                              nullable: true
                              description: Present only when the producedSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced.
                            completion_trigger:
                              type: string
                              nullable: true
                              description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                              enum:
                                - manual
                                - finish_step
                                - receipt
                            expected_completion_date:
                              type: string
                              format: date
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            production_warehouse_id:
                              type: integer
                              nullable: true
                            production_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the productionWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            destination_warehouse_id:
                              type: integer
                              nullable: true
                            destination_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the destinationWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            vendor_id:
                              type: integer
                              nullable: true
                              description: Co-manufacturer (subcontract) vendor ID.
                            co_manufacturer_id:
                              type: integer
                              nullable: true
                              description: Alias of `vendor_id` (always the same value).
                            vendor:
                              type: object
                              nullable: true
                              description: Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            co_manufacturer:
                              type: object
                              nullable: true
                              description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            bom_id:
                              type: integer
                              nullable: true
                            work_order_kind:
                              type: string
                              enum:
                                - build
                                - service
                              description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                            service_unit_price:
                              type: number
                              nullable: true
                              description: Per-unit service fee for subcontract production.
                            cost_rule_resolution:
                              type: object
                              nullable: true
                              description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                              properties:
                                used_cost_rule:
                                  type: boolean
                                  description: True when a cost rule produced the price; false for a fallback resolution.
                                cost_rule_id:
                                  type: integer
                                  nullable: true
                                cost_rule_name:
                                  type: string
                                  nullable: true
                                resolved_unit_cost:
                                  type: number
                                  nullable: true
                                  description: The per-unit cost the engine resolved to.
                                fallback_source:
                                  type: string
                                  nullable: true
                                  description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                tier_min_qty:
                                  type: number
                                  nullable: true
                                  description: Minimum quantity of the matched cost-rule tier.
                                breakdown:
                                  type: array
                                  description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                  items:
                                    type: object
                                    properties:
                                      effect:
                                        type: string
                                        description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                      description:
                                        type: string
                                        nullable: true
                                      amount:
                                        type: string
                                        description: 'The step''s amount, as a string. Defaults to `0`.'
                                      delta:
                                        type: string
                                        description: 'Change applied at this step, as a string. Defaults to `0`.'
                                      result:
                                        type: string
                                        description: 'Running total after this step, as a string. Defaults to `0`.'
                                      costRuleId:
                                        type: integer
                                        nullable: true
                                        description: Identity of the rule that contributed this step.
                                      costRuleName:
                                        type: string
                                        nullable: true
                                next_tier_hint:
                                  type: object
                                  nullable: true
                                  description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                  properties:
                                    min_qty:
                                      type: number
                                      nullable: true
                                    unit_cost:
                                      type: number
                                      nullable: true
                                    savings:
                                      type: number
                                      nullable: true
                            notes:
                              type: string
                              nullable: true
                            hold_reason:
                              type: string
                              nullable: true
                            cancel_reason:
                              type: string
                              nullable: true
                            held_at:
                              type: string
                              format: date-time
                              nullable: true
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            held_by:
                              type: integer
                              nullable: true
                            production_batch_id:
                              type: integer
                              nullable: true
                            steps:
                              type: array
                              description: Production steps. Present only when the steps relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  work_order_id:
                                    type: integer
                                  sequence:
                                    type: integer
                                    description: Order of the step within the work order's routing.
                                  status:
                                    type: string
                                    description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                  output_sku_id:
                                    type: integer
                                    nullable: true
                                  output_sku:
                                    type: object
                                    nullable: true
                                    description: Present only when the outputSku relation is loaded.
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  planned_qty:
                                    type: number
                                    description: Quantity planned to be produced by this step.
                                  completed_qty:
                                    type: number
                                    description: Quantity completed so far for this step.
                                  is_outside_processing:
                                    type: boolean
                                    description: Whether this step is performed by an outside (subcontract) vendor.
                                  supply_mode:
                                    type: string
                                    nullable: true
                                  vendor_id:
                                    type: integer
                                    nullable: true
                                  skipped_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  skipped_by:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            custom_fields:
                              type: object
                              nullable: true
                              description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties: true
                            alternate_ids:
                              type: array
                              description: External alternate identifiers. Present only when loaded.
                              items:
                                type: string
                            links:
                              type: object
                              description: HATEOAS links to related sub-resources.
                              properties:
                                self:
                                  type: string
                                steps:
                                  type: string
                                completions:
                                  type: string
                                production_entries:
                                  type: string
                                status_history:
                                  type: string
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                      notes:
                        type: string
                        nullable: true
                      payment_terms:
                        type: string
                        nullable: true
                        description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                        example: Net 30
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          work_orders:
                            type: string
                          summary:
                            type: string
                          po_links:
                            type: string
                          ao_links:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/work-orders/fields':
    patch:
      operationId: applyFieldsToProductionBatchWorkOrders
      tags:
        - Production Batches
      summary: Update fields on all work orders in a batch
      description: |-
        Apply the same field edits to every open work order in a production batch. Only the fields you send are changed, and you must send at least one.

        Each work order is updated separately, so if one is refused the others still change. Completed and cancelled work orders are skipped. Each field follows the rules of its single-work-order endpoint: the expected completion date, service fee, notes and destination warehouse can only change on draft, planned or in-progress work orders, so a work order in any other open status comes back as `failed` with the reason in `errors`. The destination warehouse also fails on a work order that already has a planned shipment.

        This does not change the batch's own `expected_completion_date`. Set that with `PUT /production-batches/{batchId}`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                expected_completion_date:
                  type: string
                  format: date
                  nullable: true
                  description: Expected completion date to set on each work order. Send `null` to clear it.
                  example: '2026-11-20'
                service_unit_price:
                  type: number
                  minimum: 0
                  maximum: 99999999.99
                  description: 'Per-unit service fee, up to 6 decimal places. Same limits as `PATCH /work-orders/{workOrderId}/service-fee`.'
                  example: 12.5
                notes:
                  type: string
                  description: Notes to set on each work order (replaces the existing notes).
                custom_fields:
                  type: array
                  minItems: 1
                  description: 'Custom field values to set on each work order. Merged with the existing values by custom field ID, as in `PATCH /work-orders/{workOrderId}/custom-fields`.'
                  items:
                    type: object
                    required:
                      - custom_field
                      - value
                    properties:
                      custom_field:
                        type: integer
                        description: ID of the custom field definition.
                      value:
                        nullable: true
                        description: Value to store. Must be present; an empty value leaves the field unset.
                destination_warehouse_id:
                  type: integer
                  description: 'Destination warehouse to set on each work order (an active top-level warehouse). Same rules as `PATCH /work-orders/{workOrderId}/destination-warehouse`: output reported afterwards is received into the new warehouse; output already received stays put.'
                  example: 12
      responses:
        '200':
          description: 'Successful response, including when some work orders failed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                        example: '3 work order(s) updated, 1 failed, 1 completed or cancelled skipped'
                      updated_count:
                        type: integer
                      failed_count:
                        type: integer
                      skipped_count:
                        type: integer
                      results:
                        type: array
                        description: One entry per work order in the batch.
                        items:
                          type: object
                          properties:
                            work_order_id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              enum:
                                - updated
                                - failed
                                - skipped
                            errors:
                              type: object
                              description: 'Error messages keyed by field (`expectedCompletionDate`, `serviceUnitPrice`, `notes`, `customFieldValues`). Empty unless `status` is `failed`.'
                              additionalProperties:
                                type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or no fields were sent.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/work-orders/{workOrderId}':
    delete:
      operationId: removeWorkOrderFromProductionBatch
      tags:
        - Production Batches
      summary: Remove a work order from a production batch
      description: Unlink a single work order from a production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
        - in: path
          name: workOrderId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      batch_number:
                        type: string
                      name:
                        type: string
                        nullable: true
                      status:
                        type: string
                        description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                      vendor_id:
                        type: integer
                        nullable: true
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      production_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse where the batch is produced.
                      production_warehouse:
                        type: object
                        nullable: true
                        description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse that receives the finished goods.
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      work_order_count:
                        type: integer
                        description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                      work_orders:
                        type: array
                        description: Work orders in the batch. Present only when the workOrders relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                            is_on_hold:
                              type: boolean
                            produced_sku_id:
                              type: integer
                              nullable: true
                              description: ID of the SKU (request_for_quotes record) being produced.
                            produced_sku:
                              type: object
                              nullable: true
                              description: Present only when the producedSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced.
                            completion_trigger:
                              type: string
                              nullable: true
                              description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                              enum:
                                - manual
                                - finish_step
                                - receipt
                            expected_completion_date:
                              type: string
                              format: date
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            production_warehouse_id:
                              type: integer
                              nullable: true
                            production_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the productionWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            destination_warehouse_id:
                              type: integer
                              nullable: true
                            destination_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the destinationWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            vendor_id:
                              type: integer
                              nullable: true
                              description: Co-manufacturer (subcontract) vendor ID.
                            co_manufacturer_id:
                              type: integer
                              nullable: true
                              description: Alias of `vendor_id` (always the same value).
                            vendor:
                              type: object
                              nullable: true
                              description: Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            co_manufacturer:
                              type: object
                              nullable: true
                              description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            bom_id:
                              type: integer
                              nullable: true
                            work_order_kind:
                              type: string
                              enum:
                                - build
                                - service
                              description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                            service_unit_price:
                              type: number
                              nullable: true
                              description: Per-unit service fee for subcontract production.
                            cost_rule_resolution:
                              type: object
                              nullable: true
                              description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                              properties:
                                used_cost_rule:
                                  type: boolean
                                  description: True when a cost rule produced the price; false for a fallback resolution.
                                cost_rule_id:
                                  type: integer
                                  nullable: true
                                cost_rule_name:
                                  type: string
                                  nullable: true
                                resolved_unit_cost:
                                  type: number
                                  nullable: true
                                  description: The per-unit cost the engine resolved to.
                                fallback_source:
                                  type: string
                                  nullable: true
                                  description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                tier_min_qty:
                                  type: number
                                  nullable: true
                                  description: Minimum quantity of the matched cost-rule tier.
                                breakdown:
                                  type: array
                                  description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                  items:
                                    type: object
                                    properties:
                                      effect:
                                        type: string
                                        description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                      description:
                                        type: string
                                        nullable: true
                                      amount:
                                        type: string
                                        description: 'The step''s amount, as a string. Defaults to `0`.'
                                      delta:
                                        type: string
                                        description: 'Change applied at this step, as a string. Defaults to `0`.'
                                      result:
                                        type: string
                                        description: 'Running total after this step, as a string. Defaults to `0`.'
                                      costRuleId:
                                        type: integer
                                        nullable: true
                                        description: Identity of the rule that contributed this step.
                                      costRuleName:
                                        type: string
                                        nullable: true
                                next_tier_hint:
                                  type: object
                                  nullable: true
                                  description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                  properties:
                                    min_qty:
                                      type: number
                                      nullable: true
                                    unit_cost:
                                      type: number
                                      nullable: true
                                    savings:
                                      type: number
                                      nullable: true
                            notes:
                              type: string
                              nullable: true
                            hold_reason:
                              type: string
                              nullable: true
                            cancel_reason:
                              type: string
                              nullable: true
                            held_at:
                              type: string
                              format: date-time
                              nullable: true
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            held_by:
                              type: integer
                              nullable: true
                            production_batch_id:
                              type: integer
                              nullable: true
                            steps:
                              type: array
                              description: Production steps. Present only when the steps relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  work_order_id:
                                    type: integer
                                  sequence:
                                    type: integer
                                    description: Order of the step within the work order's routing.
                                  status:
                                    type: string
                                    description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                  output_sku_id:
                                    type: integer
                                    nullable: true
                                  output_sku:
                                    type: object
                                    nullable: true
                                    description: Present only when the outputSku relation is loaded.
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  planned_qty:
                                    type: number
                                    description: Quantity planned to be produced by this step.
                                  completed_qty:
                                    type: number
                                    description: Quantity completed so far for this step.
                                  is_outside_processing:
                                    type: boolean
                                    description: Whether this step is performed by an outside (subcontract) vendor.
                                  supply_mode:
                                    type: string
                                    nullable: true
                                  vendor_id:
                                    type: integer
                                    nullable: true
                                  skipped_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  skipped_by:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            custom_fields:
                              type: object
                              nullable: true
                              description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties: true
                            alternate_ids:
                              type: array
                              description: External alternate identifiers. Present only when loaded.
                              items:
                                type: string
                            links:
                              type: object
                              description: HATEOAS links to related sub-resources.
                              properties:
                                self:
                                  type: string
                                steps:
                                  type: string
                                completions:
                                  type: string
                                production_entries:
                                  type: string
                                status_history:
                                  type: string
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                      notes:
                        type: string
                        nullable: true
                      payment_terms:
                        type: string
                        nullable: true
                        description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                        example: Net 30
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          work_orders:
                            type: string
                          summary:
                            type: string
                          po_links:
                            type: string
                          ao_links:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/summary':
    get:
      operationId: getProductionBatchSummary
      tags:
        - Production Batches
      summary: Get production batch summary
      description: Return summary statistics for a production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    nullable: true
                    description: Summary statistics for the production batch.
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/sync-status':
    post:
      operationId: syncProductionBatchStatus
      tags:
        - Production Batches
      summary: Sync production batch status
      description: Recalculate and sync the status of a production batch based on its work orders.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      batch_number:
                        type: string
                      name:
                        type: string
                        nullable: true
                      status:
                        type: string
                        description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                      vendor_id:
                        type: integer
                        nullable: true
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      production_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse where the batch is produced.
                      production_warehouse:
                        type: object
                        nullable: true
                        description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse that receives the finished goods.
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      work_order_count:
                        type: integer
                        description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                      work_orders:
                        type: array
                        description: Work orders in the batch. Present only when the workOrders relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                            is_on_hold:
                              type: boolean
                            produced_sku_id:
                              type: integer
                              nullable: true
                              description: ID of the SKU (request_for_quotes record) being produced.
                            produced_sku:
                              type: object
                              nullable: true
                              description: Present only when the producedSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced.
                            completion_trigger:
                              type: string
                              nullable: true
                              description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                              enum:
                                - manual
                                - finish_step
                                - receipt
                            expected_completion_date:
                              type: string
                              format: date
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            production_warehouse_id:
                              type: integer
                              nullable: true
                            production_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the productionWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            destination_warehouse_id:
                              type: integer
                              nullable: true
                            destination_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the destinationWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            vendor_id:
                              type: integer
                              nullable: true
                              description: Co-manufacturer (subcontract) vendor ID.
                            co_manufacturer_id:
                              type: integer
                              nullable: true
                              description: Alias of `vendor_id` (always the same value).
                            vendor:
                              type: object
                              nullable: true
                              description: Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            co_manufacturer:
                              type: object
                              nullable: true
                              description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            bom_id:
                              type: integer
                              nullable: true
                            work_order_kind:
                              type: string
                              enum:
                                - build
                                - service
                              description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                            service_unit_price:
                              type: number
                              nullable: true
                              description: Per-unit service fee for subcontract production.
                            cost_rule_resolution:
                              type: object
                              nullable: true
                              description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                              properties:
                                used_cost_rule:
                                  type: boolean
                                  description: True when a cost rule produced the price; false for a fallback resolution.
                                cost_rule_id:
                                  type: integer
                                  nullable: true
                                cost_rule_name:
                                  type: string
                                  nullable: true
                                resolved_unit_cost:
                                  type: number
                                  nullable: true
                                  description: The per-unit cost the engine resolved to.
                                fallback_source:
                                  type: string
                                  nullable: true
                                  description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                tier_min_qty:
                                  type: number
                                  nullable: true
                                  description: Minimum quantity of the matched cost-rule tier.
                                breakdown:
                                  type: array
                                  description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                  items:
                                    type: object
                                    properties:
                                      effect:
                                        type: string
                                        description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                      description:
                                        type: string
                                        nullable: true
                                      amount:
                                        type: string
                                        description: 'The step''s amount, as a string. Defaults to `0`.'
                                      delta:
                                        type: string
                                        description: 'Change applied at this step, as a string. Defaults to `0`.'
                                      result:
                                        type: string
                                        description: 'Running total after this step, as a string. Defaults to `0`.'
                                      costRuleId:
                                        type: integer
                                        nullable: true
                                        description: Identity of the rule that contributed this step.
                                      costRuleName:
                                        type: string
                                        nullable: true
                                next_tier_hint:
                                  type: object
                                  nullable: true
                                  description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                  properties:
                                    min_qty:
                                      type: number
                                      nullable: true
                                    unit_cost:
                                      type: number
                                      nullable: true
                                    savings:
                                      type: number
                                      nullable: true
                            notes:
                              type: string
                              nullable: true
                            hold_reason:
                              type: string
                              nullable: true
                            cancel_reason:
                              type: string
                              nullable: true
                            held_at:
                              type: string
                              format: date-time
                              nullable: true
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            held_by:
                              type: integer
                              nullable: true
                            production_batch_id:
                              type: integer
                              nullable: true
                            steps:
                              type: array
                              description: Production steps. Present only when the steps relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  work_order_id:
                                    type: integer
                                  sequence:
                                    type: integer
                                    description: Order of the step within the work order's routing.
                                  status:
                                    type: string
                                    description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                  output_sku_id:
                                    type: integer
                                    nullable: true
                                  output_sku:
                                    type: object
                                    nullable: true
                                    description: Present only when the outputSku relation is loaded.
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  planned_qty:
                                    type: number
                                    description: Quantity planned to be produced by this step.
                                  completed_qty:
                                    type: number
                                    description: Quantity completed so far for this step.
                                  is_outside_processing:
                                    type: boolean
                                    description: Whether this step is performed by an outside (subcontract) vendor.
                                  supply_mode:
                                    type: string
                                    nullable: true
                                  vendor_id:
                                    type: integer
                                    nullable: true
                                  skipped_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  skipped_by:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            custom_fields:
                              type: object
                              nullable: true
                              description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties: true
                            alternate_ids:
                              type: array
                              description: External alternate identifiers. Present only when loaded.
                              items:
                                type: string
                            links:
                              type: object
                              description: HATEOAS links to related sub-resources.
                              properties:
                                self:
                                  type: string
                                steps:
                                  type: string
                                completions:
                                  type: string
                                production_entries:
                                  type: string
                                status_history:
                                  type: string
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                      notes:
                        type: string
                        nullable: true
                      payment_terms:
                        type: string
                        nullable: true
                        description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                        example: Net 30
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          work_orders:
                            type: string
                          summary:
                            type: string
                          po_links:
                            type: string
                          ao_links:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/status':
    patch:
      operationId: updateProductionBatchStatus
      tags:
        - Production Batches
      summary: Update production batch status
      description: Set the status of a production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - status
              properties:
                status:
                  type: string
                  enum:
                    - draft
                    - planned
                    - in_progress
                    - completed
                    - cancelled
                  description: New status for the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      batch_number:
                        type: string
                      name:
                        type: string
                        nullable: true
                      status:
                        type: string
                        description: 'Batch status (e.g. draft, planned, in_progress, completed, cancelled).'
                      vendor_id:
                        type: integer
                        nullable: true
                      co_manufacturer_id:
                        type: integer
                        nullable: true
                        description: Alias of `vendor_id` (always the same value).
                      vendor:
                        type: object
                        nullable: true
                        description: Present only when the vendor relation is loaded.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      production_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse where the batch is produced.
                      production_warehouse:
                        type: object
                        nullable: true
                        description: 'Production warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      destination_warehouse_id:
                        type: integer
                        nullable: true
                        description: ID of the warehouse that receives the finished goods.
                      destination_warehouse:
                        type: object
                        nullable: true
                        description: 'Destination warehouse. Present only when the relation is loaded (e.g. on GET /production-batches/{batchId}) and a warehouse is set.'
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      work_order_count:
                        type: integer
                        description: Number of work orders in the batch. Present only when the workOrders relation is loaded.
                      work_orders:
                        type: array
                        description: Work orders in the batch. Present only when the workOrders relation is loaded.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            work_order_number:
                              type: string
                            status:
                              type: string
                              description: 'Work order status (e.g. draft, planned, in_progress, completed, cancelled).'
                            is_on_hold:
                              type: boolean
                            produced_sku_id:
                              type: integer
                              nullable: true
                              description: ID of the SKU (request_for_quotes record) being produced.
                            produced_sku:
                              type: object
                              nullable: true
                              description: Present only when the producedSku relation is loaded.
                              properties:
                                id:
                                  type: integer
                                sku:
                                  type: string
                                description:
                                  type: string
                                  nullable: true
                            planned_qty:
                              type: number
                              description: Quantity planned to be produced.
                            completion_trigger:
                              type: string
                              nullable: true
                              description: 'How the work order is completed. `manual` closes only when someone completes the work order, `finish_step` closes once every step is finished, and `receipt` closes when its finished goods are received. A work order created without one gets the organization''s default completion trigger, which is `manual` unless changed in Settings → Inventory.'
                              enum:
                                - manual
                                - finish_step
                                - receipt
                            expected_completion_date:
                              type: string
                              format: date
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                            updated_at:
                              type: string
                              format: date-time
                            production_warehouse_id:
                              type: integer
                              nullable: true
                            production_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the productionWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            destination_warehouse_id:
                              type: integer
                              nullable: true
                            destination_warehouse:
                              type: object
                              nullable: true
                              description: Present only when the destinationWarehouse relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            vendor_id:
                              type: integer
                              nullable: true
                              description: Co-manufacturer (subcontract) vendor ID.
                            co_manufacturer_id:
                              type: integer
                              nullable: true
                              description: Alias of `vendor_id` (always the same value).
                            vendor:
                              type: object
                              nullable: true
                              description: Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            co_manufacturer:
                              type: object
                              nullable: true
                              description: Alias of `vendor` (same `id` and `name`). Present only when the vendor relation is loaded.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                            bom_id:
                              type: integer
                              nullable: true
                            work_order_kind:
                              type: string
                              enum:
                                - build
                                - service
                              description: What the work order does to its SKU. `build` (the default for every existing work order) builds the SKU from its BOM components. `service` sends an existing piece of the SKU to a vendor and takes the same SKU back with the labor added. Fixed at creation.
                            service_unit_price:
                              type: number
                              nullable: true
                              description: Per-unit service fee for subcontract production.
                            cost_rule_resolution:
                              type: object
                              nullable: true
                              description: 'How the `service_unit_price` was priced by the landed-cost / cost-rule engine. Returned on the list (`GET /work-orders`) and single (`GET /work-orders/{workOrderId}`) endpoints. The key is omitted entirely when no resolution has been computed for the work order — an absent key means "not applicable", never "no rule applied".'
                              properties:
                                used_cost_rule:
                                  type: boolean
                                  description: True when a cost rule produced the price; false for a fallback resolution.
                                cost_rule_id:
                                  type: integer
                                  nullable: true
                                cost_rule_name:
                                  type: string
                                  nullable: true
                                resolved_unit_cost:
                                  type: number
                                  nullable: true
                                  description: The per-unit cost the engine resolved to.
                                fallback_source:
                                  type: string
                                  nullable: true
                                  description: Set when the price came from a fallback rather than a cost rule (e.g. `MANUAL` for a manual override). Null when a cost rule was used.
                                tier_min_qty:
                                  type: number
                                  nullable: true
                                  description: Minimum quantity of the matched cost-rule tier.
                                breakdown:
                                  type: array
                                  description: 'Ordered pricing steps, so a stacked fee (multiple additive cost rules) can be taken apart. Empty when there is no stored breakdown.'
                                  items:
                                    type: object
                                    properties:
                                      effect:
                                        type: string
                                        description: The step's effect (e.g. how it altered the running cost). Defaults to `Unknown`.
                                      description:
                                        type: string
                                        nullable: true
                                      amount:
                                        type: string
                                        description: 'The step''s amount, as a string. Defaults to `0`.'
                                      delta:
                                        type: string
                                        description: 'Change applied at this step, as a string. Defaults to `0`.'
                                      result:
                                        type: string
                                        description: 'Running total after this step, as a string. Defaults to `0`.'
                                      costRuleId:
                                        type: integer
                                        nullable: true
                                        description: Identity of the rule that contributed this step.
                                      costRuleName:
                                        type: string
                                        nullable: true
                                next_tier_hint:
                                  type: object
                                  nullable: true
                                  description: Present only when a better-priced next tier exists. Shows the quantity needed and the savings available at that tier.
                                  properties:
                                    min_qty:
                                      type: number
                                      nullable: true
                                    unit_cost:
                                      type: number
                                      nullable: true
                                    savings:
                                      type: number
                                      nullable: true
                            notes:
                              type: string
                              nullable: true
                            hold_reason:
                              type: string
                              nullable: true
                            cancel_reason:
                              type: string
                              nullable: true
                            held_at:
                              type: string
                              format: date-time
                              nullable: true
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            held_by:
                              type: integer
                              nullable: true
                            production_batch_id:
                              type: integer
                              nullable: true
                            steps:
                              type: array
                              description: Production steps. Present only when the steps relation is loaded.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  work_order_id:
                                    type: integer
                                  sequence:
                                    type: integer
                                    description: Order of the step within the work order's routing.
                                  status:
                                    type: string
                                    description: 'Step status (e.g. pending, in_progress, completed, skipped).'
                                  output_sku_id:
                                    type: integer
                                    nullable: true
                                  output_sku:
                                    type: object
                                    nullable: true
                                    description: Present only when the outputSku relation is loaded.
                                    properties:
                                      id:
                                        type: integer
                                      sku:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                  planned_qty:
                                    type: number
                                    description: Quantity planned to be produced by this step.
                                  completed_qty:
                                    type: number
                                    description: Quantity completed so far for this step.
                                  is_outside_processing:
                                    type: boolean
                                    description: Whether this step is performed by an outside (subcontract) vendor.
                                  supply_mode:
                                    type: string
                                    nullable: true
                                  vendor_id:
                                    type: integer
                                    nullable: true
                                  skipped_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  skipped_by:
                                    type: integer
                                    nullable: true
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                            custom_fields:
                              type: object
                              nullable: true
                              description: 'Custom field key/value pairs. Present only when loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties: true
                            alternate_ids:
                              type: array
                              description: External alternate identifiers. Present only when loaded.
                              items:
                                type: string
                            links:
                              type: object
                              description: HATEOAS links to related sub-resources.
                              properties:
                                self:
                                  type: string
                                steps:
                                  type: string
                                completions:
                                  type: string
                                production_entries:
                                  type: string
                                status_history:
                                  type: string
                      expected_completion_date:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expected completion date stored on the batch (`YYYY-MM-DD`). Set it with `PUT /production-batches/{batchId}`; create does not accept it.'
                      notes:
                        type: string
                        nullable: true
                      payment_terms:
                        type: string
                        nullable: true
                        description: 'Payment terms for the batch (e.g. `Net 30`), or null when none are set.'
                        example: Net 30
                      custom_fields:
                        type: object
                        nullable: true
                        description: 'Custom field key/value pairs. Present only when the customFieldValues relation is loaded. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                        additionalProperties: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      links:
                        type: object
                        description: HATEOAS links to related sub-resources.
                        properties:
                          self:
                            type: string
                          work_orders:
                            type: string
                          summary:
                            type: string
                          po_links:
                            type: string
                          ao_links:
                            type: string
                          status_history:
                            type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/po-links':
    get:
      operationId: getProductionBatchPoLinks
      tags:
        - Production Batches
      summary: List purchase order links for a production batch
      description: Return the purchase order (PO) links associated with the given production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/ao-links':
    get:
      operationId: getProductionBatchAoLinks
      tags:
        - Production Batches
      summary: List assembly order links for a production batch
      description: Return the assembly order (AO) links associated with the given production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/receiving-reports':
    get:
      operationId: getProductionBatchReceivingReports
      tags:
        - Production Batches
      summary: List receiving reports for a production batch
      description: Return the receiving reports associated with the given production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/status-history':
    get:
      operationId: getProductionBatchStatusHistory
      tags:
        - Production Batches
      summary: List status history for a production batch
      description: Return the status change history for the given production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/events':
    get:
      operationId: getProductionBatchEvents
      tags:
        - Production Batches
      summary: List events for a production batch
      description: Return the events recorded for the given production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/generate-transfer-orders':
    post:
      operationId: generateProductionBatchTransferOrders
      tags:
        - Production Batches
      summary: Generate transfer orders for a production batch
      description: 'Generate transfer orders for the brand-supplied BOM items of each work order in the given production batch that does not already have transfer orders. Completed and cancelled work orders are left out entirely (they are not attempted and are not counted as skipped), matching the batch''s BOM view. Returns 422 if the batch has no work orders, or if every work order in it is completed or cancelled ("Production batch has no open work orders").'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'The batch has no work orders, has no open (non-completed, non-cancelled) work orders, or generation failed'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/sub-assemblies':
    get:
      operationId: getProductionBatchSubAssemblies
      tags:
        - Production Batches
      summary: List sub-assemblies for a production batch
      description: Return the sub-assemblies associated with the given production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '404':
          description: Production batch not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/sub-assemblies/export':
    post:
      operationId: exportProductionBatchSubAssemblies
      tags:
        - Production Batches
      summary: Export production batch sub-assemblies
      description: Export the selected sub-assemblies for the given production batch as a binary PDF document.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sub_assembly_ids
              properties:
                sub_assembly_ids:
                  type: array
                  minItems: 1
                  description: IDs of the sub-assemblies to export.
                  items:
                    type: integer
                export_type:
                  type: string
                  nullable: true
                  enum:
                    - pdf
                  description: Export format.
                page_size:
                  type: string
                  nullable: true
                  enum:
                    - A4
                    - letter
                  description: Page size for the exported document.
                page_orientation:
                  type: string
                  nullable: true
                  enum:
                    - portrait
                    - landscape
                  description: Page orientation for the exported document.
      responses:
        '200':
          description: Binary PDF document
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/sub-assemblies/create-assembly-orders':
    post:
      operationId: bulkCreateProductionBatchAssemblyOrders
      tags:
        - Production Batches
      summary: Bulk create assembly orders for sub-assemblies
      description: Create assembly orders in bulk for the sub-assemblies of the given production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  minItems: 1
                  description: Assembly orders to create.
                  items:
                    type: object
                    required:
                      - work_order_id
                      - rfq_id
                      - quantity
                    properties:
                      work_order_id:
                        type: integer
                        description: ID of the work order.
                      rfq_id:
                        type: integer
                        description: ID of the RFQ.
                      quantity:
                        type: number
                        minimum: 0.01
                        description: Quantity to assemble.
                      step_id:
                        type: integer
                        nullable: true
                        description: ID of the associated work order step.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/refresh':
    post:
      operationId: refreshProductionBatch
      tags:
        - Production Batches
      summary: Refresh a production batch
      description: Recalculate and refresh the given production batch.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: ID of the production batch.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                      result:
                        type: object
                        additionalProperties: true
                        nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/production-batches/{batchId}/export':
    get:
      operationId: exportProductionBatch
      tags:
        - Production Batches
      summary: Export a production batch
      description: |-
        Export a production batch (production run) as a file download: the run document as a PDF, or the flat data export as CSV or XLSX shaped by a Production Run data template (CS-10167).

        `export_template_id` selects a saved template of the matching type; without it the tenant default applies, and a data export with no template carries every column.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: batchId
          required: true
          schema:
            type: integer
          description: The production batch ID.
        - in: query
          name: export_type
          required: false
          schema:
            type: string
            enum:
              - PDF
              - CSV
              - XLSX
            default: PDF
          description: Output format. Defaults to `PDF` (the run document); `CSV`/`XLSX` produce the flat data export.
        - in: query
          name: export_template_id
          required: false
          schema:
            type: integer
          description: A saved Production Run data template of the matching type. Without it the tenant default applies; a data export with no template carries every column.
      responses:
        '200':
          description: 'The exported file (`Content-Disposition: attachment`).'
          content:
            application/pdf:
              schema:
                type: string
                format: binary
            text/csv:
              schema:
                type: string
                format: binary
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '422':
          description: The export could not be produced (e.g. an invalid template or export type).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /pickflow/shipping/carriers:
    get:
      operationId: getPickflowShippingCarriers
      tags:
        - PickFlow Shipping
      summary: List shipping carriers
      description: Return the provider-agnostic list of shipping carriers available to PickFlow's packing flow. Success bodies are wrapped in a top-level "data" key.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /pickflow/shipping/services:
    get:
      operationId: getPickflowShippingServices
      tags:
        - PickFlow Shipping
      summary: List shipping services for a carrier
      description: 'Return the provider-agnostic list of shipping services offered by the given carrier. Success bodies are wrapped in a top-level "data" key; errors return { "error": "<reason>" }.'
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: carrier_code
          required: true
          description: Carrier code to list services for.
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /pickflow/shipping/packages:
    get:
      operationId: getPickflowShippingPackages
      tags:
        - PickFlow Shipping
      summary: List package types for a carrier
      description: 'Return the provider-agnostic list of package types supported by the given carrier. Success bodies are wrapped in a top-level "data" key; errors return { "error": "<reason>" }.'
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: carrier_code
          required: true
          description: Carrier code to list package types for.
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  '/pickflow/fulfillment-orders/{fulfillmentOrderId}/label':
    post:
      operationId: buyPickflowFulfillmentOrderLabel
      tags:
        - PickFlow Shipping
      summary: Buy a shipping label for a fulfillment order
      description: |-
        Buy a shipping label for the given fulfillment order, register the shipment in Luminous, and return the base64 label bytes plus tracking. This operation is idempotent per fulfillment order — retries return the already-purchased label instead of buying postage twice. Success bodies are wrapped in a top-level "data" key; errors return { "error": "<reason>" }.
        Optionally route the label to a printer: pass print_station_id (a Luminous print station from GET /pickflow/print-stations) to enqueue the purchased label into that station's print queue. The response then carries print_job_id.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: fulfillmentOrderId
          required: true
          description: The fulfillment order to buy a label for.
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - carrier_code
                - service_code
                - weight
              properties:
                carrier_code:
                  type: string
                  description: 'Carrier code to ship with. For a rate aggregator such as EasyPost, pass the aggregator''s code here; the shipment is registered under the carrier of the purchased rate (e.g. `UPS`), not the aggregator.'
                service_code:
                  type: string
                  description: Shipping service code to use.
                package_code:
                  type: string
                  nullable: true
                  description: Package type code.
                confirmation:
                  type: string
                  nullable: true
                  description: Delivery confirmation option.
                ship_date:
                  type: string
                  format: date
                  nullable: true
                  description: Date the shipment will be tendered to the carrier.
                weight:
                  type: object
                  required:
                    - value
                  properties:
                    value:
                      type: number
                      minimum: 0.01
                      description: Package weight value.
                    units:
                      type: string
                      nullable: true
                      description: 'Weight units (e.g. ounces, pounds).'
                dimensions:
                  type: object
                  nullable: true
                  properties:
                    length:
                      type: number
                    width:
                      type: number
                    height:
                      type: number
                    units:
                      type: string
                ship_to:
                  type: object
                  nullable: true
                  description: Optional override of the ship-to address. Only used when `street1` is present; otherwise the fulfillment order's own ship-to address is used.
                  properties:
                    name:
                      type: string
                    company:
                      type: string
                    street1:
                      type: string
                    street2:
                      type: string
                      nullable: true
                    street3:
                      type: string
                      nullable: true
                    city:
                      type: string
                    state:
                      type: string
                    postal_code:
                      type: string
                    country:
                      type: string
                      description: Country code. Defaults to `US`.
                    phone:
                      type: string
                      nullable: true
                    email:
                      type: string
                      nullable: true
                      description: 'Recipient email, passed to the carrier so it can send delivery notifications. Ignored if it is not a valid email address.'
                    residential:
                      type: boolean
                      description: Whether the address is residential. Defaults to `false`.
                label_format:
                  type: string
                  nullable: true
                  enum:
                    - pdf
                    - png
                    - zpl
                    - PDF
                    - PNG
                    - ZPL
                  description: Format of the returned label.
                test_label:
                  type: boolean
                  nullable: true
                  description: 'When true, request a test (non-billable) label.'
                print_station_id:
                  type: string
                  format: uuid
                  nullable: true
                  description: Optional print routing. ID of a Luminous print station (from GET /pickflow/print-stations) to enqueue the purchased label into that station's print queue. Enqueue failures are non-fatal — the label is always returned.
                packing_session_id:
                  type: string
                  nullable: true
                  description: Optional packing session identifier to associate with the print job.
                items:
                  type: array
                  nullable: true
                  description: 'WIP lot allocations (CS-10083). Required when the fulfillment order has lot-tracked lines; omit entirely for a non-lot FO so existing PickFlow clients keep working. Buy-label ships the whole FO, so lot-tracked lines must total the FO line quantity. Duplicate lines for the same product + lot are summed before the on-hand check. Validation runs before postage is purchased; lot problems return `422` keyed `items.N.lot_id`.'
                  items:
                    type: object
                    required:
                      - order_item_id
                      - product_id
                      - quantity
                    properties:
                      order_item_id:
                        type: integer
                        description: Sales order line-item ID; must belong to this fulfillment order.
                      product_id:
                        type: integer
                        description: Product (RFQ) ID; must be the product on that FO line.
                      quantity:
                        type: number
                        minimum: 0.01
                        description: Quantity allocated from the named lot.
                      lot_id:
                        type: integer
                        nullable: true
                        description: 'Lot to deduct from. Required when the product is lot-tracked; must be staged in the FO''s picklist WIP bin (or, when the FO has no picklist, the WIP bin of a sales-order picklist holding the quantity) with enough quantity. No FEFO/FIFO inference when a lot is named.'
      responses:
        '200':
          description: Label purchased (or already-purchased label returned)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    additionalProperties: true
                    description: Base64 label bytes and tracking details.
                    properties:
                      carrier_code:
                        type: string
                        description: 'Carrier the shipment was registered under. For an aggregator label (e.g. EasyPost) this is the carrier of the purchased rate (e.g. `UPS`), so it can differ from the requested `carrier_code`. A retry returns the stored shipment''s carrier.'
                      print_job_id:
                        type: string
                        nullable: true
                        description: ID of the print job enqueued to the requested print station. Null when print_station_id was not sent or the enqueue failed (non-fatal — the label is still returned).
                      items:
                        type: array
                        description: 'The lots stored on the shipment (CS-10083). On a retry the stored allocations are returned and any different `items` in the retry body are ignored (a warning says so). If postage succeeded but registration failed, this is `[]` (or whatever is already on the shipment) and inventory is not deducted.'
                        items:
                          type: object
                          properties:
                            order_item_id:
                              type: integer
                            product_id:
                              type: integer
                            quantity:
                              type: number
                              format: float
                            lot_id:
                              type: integer
                              nullable: true
                            lot_number:
                              type: string
                              nullable: true
                            expiry_date:
                              type: string
                              format: date
                              nullable: true
                              description: '`YYYY-MM-DD`.'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '404':
          description: Fulfillment order not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /pickflow/print-stations:
    get:
      operationId: listPickflowPrintStations
      tags:
        - Print Stations
      summary: List print stations (PickFlow alias)
      description: 'PickFlow-specific alias of `GET /print-stations`. Returns the tenant''s paired print stations, most recently paired first. Behaves identically to the canonical endpoint; provided so PickFlow can use the same `/pickflow/*` credential and base path it uses for every other PickFlow call.'
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Print station ID.
                        name:
                          type: string
                          nullable: true
                          description: Station display name.
                        hostname:
                          type: string
                          nullable: true
                          description: Hostname of the machine running the station agent.
                        platform:
                          type: string
                          nullable: true
                          description: Operating system / platform of the station.
                        status:
                          type: string
                          description: 'Derived station status (e.g. online, offline) based on the last heartbeat.'
                        default_printer_name:
                          type: string
                          nullable: true
                          description: Name of the station's default printer.
                        printers:
                          type: array
                          description: Printers available on the station.
                          items:
                            type: object
                            additionalProperties: true
                            properties:
                              name:
                                type: string
                                description: Printer name (use this value as printer_name when enqueuing a job).
                        last_heartbeat_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: Timestamp of the station's most recent heartbeat (ISO 8601).
                        paired_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: When the station was paired (ISO 8601).
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
  /pickflow/print-stations/pairing-codes:
    post:
      operationId: createPickflowPrintStationPairingCode
      tags:
        - Print Stations
      summary: Mint a print station pairing code (PickFlow)
      description: 'Mint a single-use pairing code, valid for 5 minutes, that a new print station agent enters to pair with this tenant. The code is attributed to the API token''s user.'
      security:
        - BearerAuth: []
      responses:
        '201':
          description: Pairing code created
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  code:
                    type: string
                  expiresAt:
                    type: string
                    format: date-time
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '503':
          description: Could not allocate a pairing code; retry.
  /pickflow/print-stations/jobs/recent:
    get:
      operationId: listPickflowRecentPrintJobs
      tags:
        - Print Stations
      summary: List recent print jobs (PickFlow)
      description: 'Tenant-wide, payload-free summaries of the most recent print jobs across all stations, newest first. Note the response is a bare array with camelCase keys.'
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
          description: Number of jobs to return (clamped to 1–200).
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  description: Payload-free print job summary (camelCase keys).
                  properties:
                    id:
                      type: string
                      description: Print job ID.
                    stationId:
                      type: string
                      description: ID of the station the job was sent to.
                    kind:
                      type: string
                      description: 'Job kind (shipping_label, packing_slip, or raw).'
                    format:
                      type: string
                      description: Payload format (zpl or pdf).
                    status:
                      type: string
                      description: 'Job status (e.g. queued, assigned, printed, failed).'
                    printerName:
                      type: string
                      nullable: true
                    copies:
                      type: integer
                    metadata:
                      type: object
                      nullable: true
                      additionalProperties: true
                    attemptCount:
                      type: integer
                    error:
                      type: string
                      nullable: true
                      description: 'Last error reported by the station, if any.'
                    createdBy:
                      type: string
                      nullable: true
                    createdAt:
                      type: string
                      format: date-time
                    assignedAt:
                      type: string
                      format: date-time
                      nullable: true
                    printedAt:
                      type: string
                      format: date-time
                      nullable: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
  '/pickflow/print-stations/{id}/revoke':
    post:
      operationId: revokePickflowPrintStation
      tags:
        - Print Stations
      summary: Revoke a print station (PickFlow)
      description: 'Revoke a station''s credentials. The station record is kept, but its next agent call is rejected with 401. Use `DELETE /pickflow/print-stations/{id}` to remove it entirely.'
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Print station ID.
      responses:
        '200':
          description: Station revoked
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    example: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: Print station not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  '/pickflow/print-stations/{id}/test-print':
    post:
      operationId: testPrintPickflowPrintStation
      tags:
        - Print Stations
      summary: Send a test print (PickFlow)
      description: 'Queue a test page to a station. Target printer: the `printer` parameter (must exist on the station), else the station''s default printer, else the first printer flagged default, else the first printer. A ZPL test label is sent when the chosen printer''s driver is ZPL; otherwise a one-page PDF.'
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Print station ID.
        - name: printer
          in: query
          required: false
          schema:
            type: string
          description: Printer name on the station. May also be sent in the JSON body.
      responses:
        '201':
          description: Test print job queued
          content:
            application/json:
              schema:
                type: object
                description: Payload-free print job summary (camelCase keys).
                properties:
                  id:
                    type: string
                    description: Print job ID.
                  stationId:
                    type: string
                    description: ID of the station the job was sent to.
                  kind:
                    type: string
                    description: 'Job kind (shipping_label, packing_slip, or raw).'
                  format:
                    type: string
                    description: Payload format (zpl or pdf).
                  status:
                    type: string
                    description: 'Job status (e.g. queued, assigned, printed, failed).'
                  printerName:
                    type: string
                    nullable: true
                  copies:
                    type: integer
                  metadata:
                    type: object
                    nullable: true
                    additionalProperties: true
                  attemptCount:
                    type: integer
                  error:
                    type: string
                    nullable: true
                    description: 'Last error reported by the station, if any.'
                  createdBy:
                    type: string
                    nullable: true
                  createdAt:
                    type: string
                    format: date-time
                  assignedAt:
                    type: string
                    format: date-time
                    nullable: true
                  printedAt:
                    type: string
                    format: date-time
                    nullable: true
        '400':
          description: The requested printer is not available on this station.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  availablePrinters:
                    type: array
                    items:
                      type: string
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: Print station not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  '/pickflow/print-stations/{id}':
    delete:
      operationId: deletePickflowPrintStation
      tags:
        - Print Stations
      summary: Delete a print station (PickFlow)
      description: Permanently delete a print station. Its print jobs are deleted with it.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Print station ID.
      responses:
        '200':
          description: Station deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    example: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: Print station not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /pickflow/inventory/transfers:
    post:
      operationId: createPickflowInventoryTransfer
      tags:
        - Inventory
      summary: Transfer inventory between locations (PickFlow)
      description: |-
        Move on-hand stock from one location to another. Each item identifies a product by `sku` or `product_id` (or a specific `rfq_stock_location_id`) and a `quantity`. Lot-tracked products require a `lot_id`, `lot_number`, or `rfq_stock_location_id`. The source and destination locations must differ.

        Supports the optional `Idempotency-Key` header: a retry with the same key replays the original response (with `Idempotent-Replay: true`) instead of moving stock twice.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: Optional opt-in idempotency token. A retry carrying the same key replays the stored response; reusing a key for a different request returns `409`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - source_location_id
                - destination_location_id
                - items
              properties:
                source_location_id:
                  type: integer
                  description: ID of the location to move stock out of.
                destination_location_id:
                  type: integer
                  description: ID of the location to move stock into. Must be different from `source_location_id`.
                items:
                  type: array
                  minItems: 1
                  description: One or more SKUs (and quantities) to transfer between the two locations.
                  items:
                    type: object
                    required:
                      - quantity
                    properties:
                      sku:
                        type: string
                        description: SKU of the product to transfer. Required unless `product_id` or `rfq_stock_location_id` is provided.
                      product_id:
                        type: integer
                        description: ID of the product to transfer. Required unless `sku` or `rfq_stock_location_id` is provided.
                      quantity:
                        type: number
                        description: Quantity to transfer. Must be greater than 0.
                      lot_id:
                        type: integer
                        nullable: true
                        description: 'ID of the product lot to transfer. Provide either `lot_id` or `lot_number`. Required when the product has lot tracking enabled, unless `rfq_stock_location_id` is supplied.'
                      lot_number:
                        type: string
                        nullable: true
                        description: Lot number to transfer (resolved to a lot for the product). Use instead of `lot_id`. The lot must already exist — it is not created.
                      lot_name:
                        type: string
                        nullable: true
                        description: Alias for `lot_number`.
                      rfq_stock_location_id:
                        type: integer
                        nullable: true
                        description: 'ID of a specific stock-location record to transfer from. When provided, the SKU/lot is resolved from this record and `sku`/ `product_id`/`lot_id` are not required.'
      responses:
        '200':
          description: Inventory transferred successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Inventory transferred successfully.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /pickflow/inventory/recount:
    post:
      operationId: recountPickflowInventory
      tags:
        - Inventory
      summary: Recount a bin/lot row (PickFlow)
      description: |-
        Set one stock row's on-hand to an absolute counted quantity (recorded as a manual recount adjustment). Send `expected_quantity` — the on-hand the operator was shown — and the recount is refused with `409` if stock moved in the meantime (a pick or receipt), rather than overwriting a quantity nobody looked at.

        Supports the optional `Idempotency-Key` header: a retry with the same key replays the original response (with `Idempotent-Replay: true`) instead of posting a second adjustment.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: Optional opt-in idempotency token. A retry carrying the same key replays the stored response; reusing a key for a different request returns `409`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - rfq_stock_location_id
                - quantity
              properties:
                rfq_stock_location_id:
                  type: integer
                  description: Stock row to recount (from the bin/product stock endpoints).
                quantity:
                  type: number
                  minimum: 0
                  description: The counted on-hand quantity.
                expected_quantity:
                  type: number
                  nullable: true
                  description: On-hand the operator saw before counting. Enables the stale-count check.
                remarks:
                  type: string
                  nullable: true
                  maxLength: 1000
      responses:
        '200':
          description: Recount applied
          content:
            application/json:
              schema:
                type: object
                properties:
                  previous_quantity:
                    type: number
                  quantity:
                    type: number
                    description: New on-hand.
                  delta:
                    type: number
                    description: quantity − previous_quantity.
                  item:
                    type: object
                    description: 'One on-hand row — a product in a specific bin (and lot, for lot-tracked products). `rfq_stock_location_id` is the id that `POST /pickflow/inventory/transfers` and `POST /pickflow/inventory/recount` target.'
                    properties:
                      rfq_stock_location_id:
                        type: integer
                        description: Stock-row ID (product × warehouse × bin × lot).
                      product_id:
                        type: integer
                      sku:
                        type: string
                      name:
                        type: string
                        description: Product name.
                      image_url:
                        type: string
                        nullable: true
                      lot_tracked:
                        type: boolean
                      lot_id:
                        type: integer
                        nullable: true
                      lot_number:
                        type: string
                        nullable: true
                      expiry_date:
                        type: string
                        format: date
                        nullable: true
                      expired:
                        type: boolean
                        description: True when the row's lot has an expiry date in the past. Always false for rows with no lot or the `unspecified-lot` placeholder.
                      suggested_pick:
                        type: boolean
                        description: 'True on the one row `GET /pickflow/products/{productId}/stock` suggests picking from. Always false in other responses.'
                      location:
                        allOf:
                          - type: object
                            description: A bin (child location) inside a warehouse.
                            properties:
                              id:
                                type: integer
                                description: Bin location ID.
                              name:
                                type: string
                                description: Bin name. Only unique within its warehouse.
                              warehouse_id:
                                type: integer
                                description: ID of the warehouse the bin belongs to.
                              warehouse_name:
                                type: string
                                nullable: true
                                description: Name of the warehouse the bin belongs to.
                        nullable: true
                      onhand_quantity:
                        type: number
                      reserved_quantity:
                        type: number
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Stock location not found.
        '409':
          description: 'On-hand changed since it was displayed (`expected_quantity` no longer matches), or an idempotency-key conflict.'
        '422':
          description: 'Validation error, or the adjustment could not be applied'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /pickflow/scan/resolve:
    get:
      operationId: resolvePickflowScan
      tags:
        - PickFlow Warehouse
      summary: Resolve a scanned barcode
      description: |-
        Returns **every** record a scanned code could refer to, rather than the first match, so the client can choose based on what the operator is doing (a code that is both a SKU and a bin name is the destination when moving stock, and the product when looking it up).

        Match types (up to 10 per type): active products by SKU, UPC, or alternate SKU (alternate SKUs report the unit-conversion factor as `units_per_scan`); bins by exact name (scoped to `warehouse_id` when given, since bin names are only unique per warehouse); lots by lot number; purchase orders by alternate order number or `PO-{id}`; transfer orders by order number or `TO-{id}`; return orders and sales orders by order number; picklists by `PL-{id}`; pallets by the pallet ID printed on a Pallet ID label run (looked up only when the code is an 18-digit SSCC, a 20-digit GS1-128 read with the leading `00` application identifier, or `RR{receiving report id}-P{nn}`). An empty `matches` array means nothing matched.
      security:
        - BearerAuth: []
      parameters:
        - name: code
          in: query
          required: true
          schema:
            type: string
            maxLength: 255
          description: The scanned value.
        - name: 'product_codes[]'
          in: query
          required: false
          schema:
            type: array
            maxItems: 5
            items:
              type: string
              maxLength: 255
          description: Extra product-code candidates to try for product matches only (e.g. the 12/13/14-digit forms of a GS1 GTIN). `code` is always included.
        - name: warehouse_id
          in: query
          required: false
          schema:
            type: integer
          description: Scope bin matches to this warehouse.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: The trimmed scanned code.
                  matches:
                    type: array
                    items:
                      type: object
                      description: 'A typed match. Fields present depend on `type`: `product` — product_id, sku, name, matched_by (sku|upc|alternate_sku), units_per_scan, lot_tracked, image_url; `bin` — location_id, name, warehouse_id, warehouse_name; `lot` — lot_id, lot_number, product_id, sku, expiry_date; `purchase_order` / `transfer_order` / `return_order` — id, order_number, status; `sales_order` — id, order_number, status, picking_status, picklist_id; `picklist` — id, status; `pallet` — pallet_id, run_id, receiving_report_id, reference, sequence, total, contents.'
                      properties:
                        type:
                          type: string
                          enum:
                            - product
                            - bin
                            - lot
                            - purchase_order
                            - transfer_order
                            - return_order
                            - sales_order
                            - picklist
                            - pallet
                        id:
                          type: integer
                        product_id:
                          type: integer
                        sku:
                          type: string
                        name:
                          type: string
                        matched_by:
                          type: string
                          enum:
                            - sku
                            - upc
                            - alternate_sku
                        units_per_scan:
                          type: number
                          description: Units one scan represents (the alternate SKU's case factor; 1 otherwise).
                        lot_tracked:
                          type: boolean
                        image_url:
                          type: string
                          nullable: true
                        location_id:
                          type: integer
                        warehouse_id:
                          type: integer
                        warehouse_name:
                          type: string
                          nullable: true
                        lot_id:
                          type: integer
                        lot_number:
                          type: string
                        expiry_date:
                          type: string
                          format: date
                          nullable: true
                        order_number:
                          type: string
                        status:
                          nullable: true
                          description: 'Record status (string token or code, depending on type).'
                        picking_status:
                          nullable: true
                        picklist_id:
                          type: integer
                          nullable: true
                        pallet_id:
                          type: string
                          description: 'The pallet ID barcode value (bare 18-digit SSCC, or `RR{id}-P{nn}`).'
                        run_id:
                          type: integer
                          description: The pallet label run that printed this pallet ID.
                        receiving_report_id:
                          type: integer
                          description: The receiving report the pallet belongs to.
                        reference:
                          type: string
                          description: 'Receiving report reference, `RR-{receiving_report_id}`.'
                        sequence:
                          type: integer
                          description: Which pallet of the run this is (1-based).
                        total:
                          type: integer
                          description: Number of pallets in the run.
                        contents:
                          type: array
                          description: 'What is on the pallet: the receiving report''s lines (or the single line, when the run was printed for one receiving report line).'
                          items:
                            type: object
                            properties:
                              product_id:
                                type: integer
                                nullable: true
                              sku:
                                type: string
                                nullable: true
                              name:
                                type: string
                                nullable: true
                              quantity:
                                type: number
                                description: Received quantity (falls back to the line quantity).
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/locations/{locationId}/stock':
    get:
      operationId: getPickflowBinStock
      tags:
        - PickFlow Warehouse
      summary: Get bin contents
      description: 'Everything in one bin, as bin × lot rows. Rows with zero on-hand **and** zero reserved quantity are omitted.'
      security:
        - BearerAuth: []
      parameters:
        - name: locationId
          in: path
          required: true
          schema:
            type: integer
          description: Bin location ID.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  location:
                    type: object
                    description: A bin (child location) inside a warehouse.
                    properties:
                      id:
                        type: integer
                        description: Bin location ID.
                      name:
                        type: string
                        description: Bin name. Only unique within its warehouse.
                      warehouse_id:
                        type: integer
                        description: ID of the warehouse the bin belongs to.
                      warehouse_name:
                        type: string
                        nullable: true
                        description: Name of the warehouse the bin belongs to.
                  items:
                    type: array
                    items:
                      type: object
                      description: 'One on-hand row — a product in a specific bin (and lot, for lot-tracked products). `rfq_stock_location_id` is the id that `POST /pickflow/inventory/transfers` and `POST /pickflow/inventory/recount` target.'
                      properties:
                        rfq_stock_location_id:
                          type: integer
                          description: Stock-row ID (product × warehouse × bin × lot).
                        product_id:
                          type: integer
                        sku:
                          type: string
                        name:
                          type: string
                          description: Product name.
                        image_url:
                          type: string
                          nullable: true
                        lot_tracked:
                          type: boolean
                        lot_id:
                          type: integer
                          nullable: true
                        lot_number:
                          type: string
                          nullable: true
                        expiry_date:
                          type: string
                          format: date
                          nullable: true
                        expired:
                          type: boolean
                          description: True when the row's lot has an expiry date in the past. Always false for rows with no lot or the `unspecified-lot` placeholder.
                        suggested_pick:
                          type: boolean
                          description: 'True on the one row `GET /pickflow/products/{productId}/stock` suggests picking from. Always false in other responses.'
                        location:
                          allOf:
                            - type: object
                              description: A bin (child location) inside a warehouse.
                              properties:
                                id:
                                  type: integer
                                  description: Bin location ID.
                                name:
                                  type: string
                                  description: Bin name. Only unique within its warehouse.
                                warehouse_id:
                                  type: integer
                                  description: ID of the warehouse the bin belongs to.
                                warehouse_name:
                                  type: string
                                  nullable: true
                                  description: Name of the warehouse the bin belongs to.
                          nullable: true
                        onhand_quantity:
                          type: number
                        reserved_quantity:
                          type: number
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: 'Bin not found (or the id is a warehouse, not a bin).'
  '/pickflow/products/{productId}/stock':
    get:
      operationId: getPickflowProductStock
      tags:
        - PickFlow Warehouse
      summary: Get product stock by bin
      description: |
        Every bin × lot row holding a product, optionally limited to one warehouse.
        Rows with zero on-hand **and** zero reserved quantity are omitted; an
        unknown product returns an empty `items` array.

        Row order follows the product's lot deduction strategy (`lot_strategy`),
        resolved from the product, then the warehouse's group (only when
        `warehouse_id` is sent), then the tenant setting:

        - `fefo`: lots with the earliest expiry date first (lots without an expiry
          date after dated ones).
        - `fifo`: oldest lots first.
        - `null` (no strategy configured): by bin, then row.

        Under `fefo` and `fifo`, rows with no lot or the `unspecified-lot`
        placeholder sort last, and rows with no on-hand stock sort after rows with
        stock.

        At most one row has `suggested_pick: true`: the first row in that order
        with on-hand stock in a pickable bin (not a WIP bin) and an unexpired lot.
        For a lot-tracked product, rows with no lot or the `unspecified-lot`
        placeholder are never suggested.
      security:
        - BearerAuth: []
      parameters:
        - name: productId
          in: path
          required: true
          schema:
            type: integer
        - name: warehouse_id
          in: query
          required: false
          schema:
            type: integer
          description: Only return rows in this warehouse.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  product_id:
                    type: integer
                  lot_strategy:
                    type: string
                    nullable: true
                    enum:
                      - fefo
                      - fifo
                      - null
                    description: Lot deduction strategy used to order `items`; `null` when no strategy is configured.
                  items:
                    type: array
                    items:
                      type: object
                      description: 'One on-hand row — a product in a specific bin (and lot, for lot-tracked products). `rfq_stock_location_id` is the id that `POST /pickflow/inventory/transfers` and `POST /pickflow/inventory/recount` target.'
                      properties:
                        rfq_stock_location_id:
                          type: integer
                          description: Stock-row ID (product × warehouse × bin × lot).
                        product_id:
                          type: integer
                        sku:
                          type: string
                        name:
                          type: string
                          description: Product name.
                        image_url:
                          type: string
                          nullable: true
                        lot_tracked:
                          type: boolean
                        lot_id:
                          type: integer
                          nullable: true
                        lot_number:
                          type: string
                          nullable: true
                        expiry_date:
                          type: string
                          format: date
                          nullable: true
                        expired:
                          type: boolean
                          description: True when the row's lot has an expiry date in the past. Always false for rows with no lot or the `unspecified-lot` placeholder.
                        suggested_pick:
                          type: boolean
                          description: 'True on the one row `GET /pickflow/products/{productId}/stock` suggests picking from. Always false in other responses.'
                        location:
                          allOf:
                            - type: object
                              description: A bin (child location) inside a warehouse.
                              properties:
                                id:
                                  type: integer
                                  description: Bin location ID.
                                name:
                                  type: string
                                  description: Bin name. Only unique within its warehouse.
                                warehouse_id:
                                  type: integer
                                  description: ID of the warehouse the bin belongs to.
                                warehouse_name:
                                  type: string
                                  nullable: true
                                  description: Name of the warehouse the bin belongs to.
                          nullable: true
                        onhand_quantity:
                          type: number
                        reserved_quantity:
                          type: number
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/warehouses/{warehouseId}/bins':
    get:
      operationId: searchPickflowWarehouseBins
      tags:
        - PickFlow Warehouse
      summary: Search bins in a warehouse
      description: 'Look up non-inactive bins within one warehouse, ordered by name. Use `name` for an exact match or `search` for a substring match (`name` wins if both are sent). With neither, returns the first `limit` bins.'
      security:
        - BearerAuth: []
      parameters:
        - name: warehouseId
          in: path
          required: true
          schema:
            type: integer
        - name: name
          in: query
          required: false
          schema:
            type: string
            maxLength: 255
          description: Exact bin name.
        - name: search
          in: query
          required: false
          schema:
            type: string
            maxLength: 255
          description: Substring to match against bin names.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A bin (child location) inside a warehouse.
                      properties:
                        id:
                          type: integer
                          description: Bin location ID.
                        name:
                          type: string
                          description: Bin name. Only unique within its warehouse.
                        warehouse_id:
                          type: integer
                          description: ID of the warehouse the bin belongs to.
                        warehouse_name:
                          type: string
                          nullable: true
                          description: Name of the warehouse the bin belongs to.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /pickflow/receivables:
    get:
      operationId: listPickflowReceivables
      tags:
        - PickFlow Warehouse
      summary: List open PO lines to receive a product against
      description: 'Open purchase-order lines for one product that still have quantity left to receive, oldest expected arrival first (up to 25). When `warehouse_id` is given, POs for that warehouse **and** POs with no warehouse set are included. Receive against a line with `POST /receiving-reports`. If the API user is assigned to specific warehouses, POs bound for other warehouses are left out, and a `warehouse_id` outside the assignment returns `403`.'
      security:
        - BearerAuth: []
      parameters:
        - name: product_id
          in: query
          required: true
          schema:
            type: integer
        - name: warehouse_id
          in: query
          required: false
          schema:
            type: integer
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        purchase_order_id:
                          type: integer
                        order_number:
                          type: string
                          description: 'Alternate order number, or `PO-{id}`.'
                        status:
                          type: string
                          nullable: true
                          description: Purchase order status token.
                        supplier_name:
                          type: string
                          nullable: true
                        warehouse_id:
                          type: integer
                          nullable: true
                        expected_arrival_date:
                          type: string
                          nullable: true
                          description: 'Line expected arrival, falling back to the PO''s arrival due date.'
                        purchase_order_item_id:
                          type: integer
                        ordered_quantity:
                          type: number
                        remaining_quantity:
                          type: number
                        ordered_unit_of_measure:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /pickflow/picklists:
    get:
      operationId: listPicklists
      tags:
        - Picklists
      summary: List picklists
      description: |-
        Get a paginated list of picklists with optional filtering. A picklist matches a filter if **any** linked fulfillment order or sales order matches.

        Filters accept the same operators as other External V1 list endpoints (e.g. `eq`, `contains`, `in`). For details, see the [Filter System Documentation](/filters).

        ## Available Filters

        ### Integer Filters
        - `id`: Picklist ID
        - `channel_id`: Sales channel ID of the linked order

        ### String Filters
        - `status`: Picklist status (`created`, `picking`, `picked`, `packed`,
          `deleted`)

        - `order_number`: Order number of the linked order. Matches the linked
          sales order number, the linked fulfillment order's order number or order
          key, or the fulfillment order's parent sales order number (a split
          fulfillment order's number often differs from its parent sales order)

        - `requested_shipping_service`: Requested shipping service on the linked
          fulfillment order or sales order

        - `channel_name`: Sales channel label of the linked order
        - `tag`: Sales order tag
        - `search`: Single search box. Matches a picklist ID (`PL-618` or `618`),
          or a partial order number or ship-to name on the linked sales order, the
          linked fulfillment order (order number only), or the fulfillment order's
          parent sales order. Always a contains match; operators are ignored


        ### DateTime Filters
        - `created_at`: When the picklist was created
        - `updated_at`: When the picklist was last updated

        ## Queue View
        Pass `view=queue` for a lighter payload suited to a picking queue. Each picklist still includes its `sales_orders` and `fulfillment_orders`, but `items` is always an empty array and fulfillment orders omit their line detail. Fetch `GET /pickflow/picklists/{id}` for a picklist's full item, lot, and kit detail.

        ## Kit lines on sales-order picklists
        In the full view, each `sales_orders[].items[].product` with `type = KIT` includes its `kit_items` (components with their `product`). A picklist attached through sales orders has no fulfillment-order breakdown, so the picking app uses this bill of materials to pick the components behind a kit line instead of only the standalone quantity (CS-11261). Queue view omits sales-order line detail.

        ## Examples
        ```
        # Picklists on a specific channel
        ?channel_id[eq]=9

        # Picklists for orders tagged "priority"
        ?tag[eq]=priority

        # Picklists whose order requests overnight shipping
        ?requested_shipping_service[contains]=Overnight

        # Picklists for a channel by name
        ?channel_name[eq]=FBM Hold Up

        # Picklists for a split fulfillment order number, queue payload
        ?order_number[eq]=1001-F2&view=queue

        # Find a picklist by its number, an order number, or a customer name
        ?search=PL-618
        ```
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number for pagination
        - in: query
          name: per_page
          schema:
            type: integer
            default: 10
            maximum: 100
          description: Number of items per page (max 100)
        - in: query
          name: id
          schema:
            type: integer
          description: Filter by picklist ID
        - in: query
          name: status
          schema:
            type: string
            enum:
              - created
              - picking
              - picked
              - packed
              - deleted
          description: Filter by picklist status
        - in: query
          name: order_number
          schema:
            type: string
          description: 'Filter by order number. Matches the linked sales order number, the linked fulfillment order''s order number or order key, or the fulfillment order''s parent sales order number.'
        - in: query
          name: search
          schema:
            type: string
          description: 'Search by picklist ID (`PL-618` or `618`), or by partial order number or ship-to name on the linked sales order, the linked fulfillment order (order number only), or the fulfillment order''s parent sales order.'
        - in: query
          name: view
          schema:
            type: string
            enum:
              - queue
          description: 'Set to `queue` for a lighter list payload: `items` is returned empty and fulfillment orders omit line detail. Open a picklist with `GET /pickflow/picklists/{id}` for full detail.'
        - in: query
          name: requested_shipping_service
          schema:
            type: string
          description: Filter by requested shipping service on the linked fulfillment order or sales order
        - in: query
          name: channel_name
          schema:
            type: string
          description: Filter by sales channel label of the linked order
        - in: query
          name: channel_id
          schema:
            type: integer
          description: Filter by sales channel ID of the linked order
        - in: query
          name: tag
          schema:
            type: string
          description: Filter by sales order tag
        - in: query
          name: created_at
          schema:
            type: string
            format: date-time
          description: Filter by creation date
        - in: query
          name: updated_at
          schema:
            type: string
            format: date-time
          description: Filter by last update date
      responses:
        '200':
          description: A paginated list of picklists.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: 'A picklist groups the items to be picked for one or more fulfillment orders or sales orders, and tracks the picking/packing lifecycle.'
                      properties:
                        id:
                          type: integer
                          description: Picklist ID
                          example: 12
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                          example: '2026-09-01T14:20:00.000000Z'
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                          example: '2026-09-01T15:03:11.000000Z'
                        status:
                          type: string
                          description: External picklist status.
                          enum:
                            - created
                            - picking
                            - picked
                            - packed
                            - deleted
                          example: picking
                        picking_started_at:
                          type: string
                          format: date-time
                          nullable: true
                          example: '2026-09-01T14:25:00.000000Z'
                        picking_ended_at:
                          type: string
                          format: date-time
                          nullable: true
                          example: null
                        packing_started_at:
                          type: string
                          format: date-time
                          nullable: true
                          example: null
                        packing_ended_at:
                          type: string
                          format: date-time
                          nullable: true
                          example: null
                        picked_by_user:
                          description: 'User who picked the picklist, or `null` when not recorded.'
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                        packed_by_user:
                          description: 'User who packed the picklist, or `null` when not recorded.'
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                        shipped_by_user:
                          description: 'User who shipped the picklist, or `null` when not recorded.'
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              nullable: true
                        items:
                          type: array
                          description: The line items on this picklist.
                          items:
                            type: object
                            description: 'A single line on a picklist — the product/RFQ to pick, from where, and how much.'
                            properties:
                              id:
                                type: integer
                                description: Picklist item ID
                                example: 4501
                              picklist_id:
                                type: integer
                                description: ID of the parent picklist
                                example: 12
                              location_id:
                                type: integer
                                nullable: true
                                description: ID of the inventory location the item is picked from
                                example: 88
                              rfq_id:
                                type: integer
                                nullable: true
                                description: ID of the product (RFQ) being picked
                                example: 1023
                              available_quantity:
                                type: number
                                format: float
                                nullable: true
                                description: Quantity available to pick at the location
                                example: 25
                              picked_quantity:
                                type: number
                                format: float
                                nullable: true
                                description: Quantity that has been picked so far
                                example: 10
                              lot_id:
                                type: integer
                                nullable: true
                                description: 'ID of the lot the item is picked from, when lot tracking applies'
                                example: 305
                              lot_number:
                                type: string
                                nullable: true
                                description: Human-readable lot number the item is assigned to — the number printed on the carton. `null` for non-lot stock. Only reflects the eager-loaded lot.
                                example: L-546
                              production_date:
                                type: string
                                format: date
                                nullable: true
                                description: Production date of the assigned lot (`YYYY-MM-DD`). `null` for non-lot stock.
                                example: '2026-01-15'
                              expiry_date:
                                type: string
                                format: date
                                nullable: true
                                description: Expiry date of the assigned lot (`YYYY-MM-DD`). `null` for non-lot stock.
                                example: '2027-01-15'
                              lot_deduction_strategy:
                                type: string
                                nullable: true
                                description: 'Which lot Luminous would pick when a caller omits `lot_id`. `null` means no per-product override (the warehouse group setting, or newest-lot fallback, applies). PickFlow can suggest this to the picker.'
                                example: null
                              uom_id:
                                type: integer
                                nullable: true
                                description: ID of the unit of measure for the picked quantities
                                example: 7
                              uom:
                                description: Unit of measure for the picked quantities. Only present when loaded.
                                nullable: true
                                allOf:
                                  - type: object
                                    description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                                    properties:
                                      id:
                                        type: integer
                                      created_at:
                                        type: string
                                        format: date-time
                                      updated_at:
                                        type: string
                                        format: date-time
                                      status:
                                        type: string
                                        nullable: true
                                      unit_class_id:
                                        type: integer
                                      unit_class:
                                        type: object
                                        description: Present when the relation is loaded.
                                        nullable: true
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          base_class:
                                            type: boolean
                                      name:
                                        type: string
                                      description:
                                        type: string
                                        nullable: true
                                      base_unit:
                                        type: boolean
                                        description: True if this UOM is the base unit for its class.
                                      unit_conversion_rules:
                                        type: array
                                        description: Present when the relation is loaded.
                                        items:
                                          type: object
                                          description: |
                                            A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                            1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                          properties:
                                            id:
                                              type: integer
                                            created_at:
                                              type: string
                                              format: date-time
                                            updated_at:
                                              type: string
                                              format: date-time
                                            status:
                                              type: string
                                              nullable: true
                                            base_unit_of_measure_id:
                                              type: integer
                                            base_unit_of_measure:
                                              type: object
                                              description: Present when the relation is loaded.
                                              nullable: true
                                              properties:
                                                id:
                                                  type: integer
                                                name:
                                                  type: string
                                                unit_class_id:
                                                  type: integer
                                                base_unit:
                                                  type: boolean
                                            converted_unit_of_measure_id:
                                              type: integer
                                            converted_unit_of_measure:
                                              type: object
                                              description: Present when the relation is loaded.
                                              nullable: true
                                              properties:
                                                id:
                                                  type: integer
                                                name:
                                                  type: string
                                                unit_class_id:
                                                  type: integer
                                                base_unit:
                                                  type: boolean
                                            conversion_factor:
                                              type: number
                                              description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                            type:
                                              type: string
                                              enum:
                                                - SYSTEM
                                                - SKU
                                            product_id:
                                              type: integer
                                              nullable: true
                                              description: Required when `type=SKU`; null when `type=SYSTEM`.
                                            product:
                                              type: object
                                              nullable: true
                                              description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                              additionalProperties: true
                                            product_alternate_skus:
                                              type: array
                                              description: Present when the relation is loaded.
                                              items:
                                                type: object
                                                additionalProperties: true
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                                example: '2026-09-01T14:22:00.000000Z'
                              updated_at:
                                type: string
                                format: date-time
                                nullable: true
                                example: '2026-09-01T15:03:11.000000Z'
                              quantity_per_fulfillment_order:
                                type: array
                                description: Breakdown showing how this item's aggregated quantity is distributed across the fulfillment orders on the picklist.
                                items:
                                  type: object
                                  properties:
                                    fulfillment_order_id:
                                      type: integer
                                      example: 9001
                                    order_key:
                                      type: string
                                      nullable: true
                                      description: 'External order key of the fulfillment order, when available'
                                      example: 114-2938471-0011
                                    quantity:
                                      type: number
                                      format: float
                                      example: 6
                                    sales_items:
                                      type: array
                                      description: The underlying sales items that make up this quantity.
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            example: 77012
                                          sku:
                                            type: string
                                            nullable: true
                                            example: WIDGET-BLUE
                                          name:
                                            type: string
                                            nullable: true
                                            example: Blue Widget
                                          quantity:
                                            type: number
                                            format: float
                                            example: 6
                                          rfq_id:
                                            type: integer
                                            nullable: true
                                            example: 1023
                                          kit_id:
                                            type: integer
                                            nullable: true
                                            description: Set when the sales item is a component of a kit
                                            example: null
                                          order_item_id:
                                            type: string
                                            nullable: true
                                            example: oi_88213
                              location:
                                description: The inventory location the item is picked from. Only present when loaded.
                                nullable: true
                                allOf:
                                  - type: object
                                    properties:
                                      id:
                                        type: integer
                                      status:
                                        type: string
                                      name:
                                        type: string
                                      parent_id:
                                        type: integer
                                        nullable: true
                                      created_at:
                                        type: string
                                        format: date-time
                                      updated_at:
                                        type: string
                                        format: date-time
                              product:
                                description: The product (RFQ) being picked. Only present when loaded.
                                nullable: true
                                allOf:
                                  - type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the product
                                      name:
                                        type: string
                                        description: Product name
                                      description:
                                        type: string
                                        nullable: true
                                        description: Product description
                                      retail_price:
                                        type: number
                                        format: float
                                        description: Retail price
                                      wholesale_price:
                                        type: number
                                        format: float
                                        description: Wholesale price
                                      unit_cost:
                                        type: number
                                        format: float
                                        description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                                      purchase_unit_cost:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: |
                                          Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                                      purchase_currency:
                                        type: string
                                        nullable: true
                                        description: |
                                          ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                                      landed_cost:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Landed cost per unit
                                      estimated_landed_cost:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                                      design_link:
                                        type: string
                                        nullable: true
                                        description: Product design URL or link. `null` when unset or empty.
                                      manufacturing_fee:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Manufacturing fee per unit
                                      product_weight:
                                        type: array
                                        nullable: true
                                        items:
                                          type: object
                                          required:
                                            - unit
                                            - value
                                          properties:
                                            unit:
                                              type: string
                                              enum:
                                                - lb
                                                - oz
                                              description: Weight unit
                                            value:
                                              type: number
                                              format: float
                                              minimum: 0
                                              description: Weight value
                                      product_weight_oz:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total product weight in ounces (computed from product_weight)
                                      product_weight_lb:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total product weight in pounds (computed from product_weight)
                                      dimensional_weight:
                                        type: array
                                        nullable: true
                                        items:
                                          type: object
                                          required:
                                            - unit
                                            - value
                                          properties:
                                            unit:
                                              type: string
                                              enum:
                                                - lb
                                                - oz
                                              description: Weight unit
                                            value:
                                              type: number
                                              format: float
                                              minimum: 0
                                              description: Weight value
                                      dimensional_weight_oz:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total dimensional weight in ounces (computed from dimensional_weight)
                                      dimensional_weight_lb:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total dimensional weight in pounds (computed from dimensional_weight)
                                      product_length:
                                        type: number
                                        format: float
                                        description: Length of the product (in inches)
                                      product_width:
                                        type: number
                                        format: float
                                        description: Width of the product (in inches)
                                      product_height:
                                        type: number
                                        format: float
                                        description: Height of the product (in inches)
                                      box_weight:
                                        type: array
                                        nullable: true
                                        items:
                                          type: object
                                          required:
                                            - unit
                                            - value
                                          properties:
                                            unit:
                                              type: string
                                              enum:
                                                - lb
                                                - oz
                                              description: Weight unit
                                            value:
                                              type: number
                                              format: float
                                              minimum: 0
                                              description: Weight value
                                      box_weight_oz:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total box weight in ounces (computed from box_weight)
                                      box_weight_lb:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total box weight in pounds (computed from box_weight)
                                      box_length:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Length of the box (in inches)
                                      box_width:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Width of the box (in inches)
                                      box_height:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Height of the box (in inches)
                                      carton_weight:
                                        type: array
                                        nullable: true
                                        items:
                                          type: object
                                          required:
                                            - unit
                                            - value
                                          properties:
                                            unit:
                                              type: string
                                              enum:
                                                - lb
                                                - oz
                                              description: Weight unit
                                            value:
                                              type: number
                                              format: float
                                              minimum: 0
                                              description: Weight value
                                      carton_weight_oz:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total carton weight in ounces (computed from carton_weight)
                                      carton_weight_lb:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total carton weight in pounds (computed from carton_weight)
                                      carton_length:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Length of the carton (in inches)
                                      carton_width:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Width of the carton (in inches)
                                      carton_height:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Height of the carton (in inches)
                                      units_per_carton:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Number of units per carton (Shipping & Packing). `null` when not set.
                                      shipping_weight:
                                        type: array
                                        nullable: true
                                        items:
                                          type: object
                                          required:
                                            - unit
                                            - value
                                          properties:
                                            unit:
                                              type: string
                                              enum:
                                                - lb
                                                - oz
                                              description: Weight unit
                                            value:
                                              type: number
                                              format: float
                                              minimum: 0
                                              description: Weight value
                                      shipping_weight_oz:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total shipping weight in ounces (computed from shipping_weight)
                                      shipping_weight_lb:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total shipping weight in pounds (computed from shipping_weight)
                                      shipping_length:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Shipping length (in inches)
                                      shipping_width:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Shipping width (in inches)
                                      shipping_height:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Shipping height (in inches)
                                      pallet_weight:
                                        type: array
                                        nullable: true
                                        items:
                                          type: object
                                          required:
                                            - unit
                                            - value
                                          properties:
                                            unit:
                                              type: string
                                              enum:
                                                - lb
                                                - oz
                                              description: Weight unit
                                            value:
                                              type: number
                                              format: float
                                              minimum: 0
                                              description: Weight value
                                      pallet_weight_oz:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total pallet weight in ounces (computed from pallet_weight)
                                      pallet_weight_lb:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Total pallet weight in pounds (computed from pallet_weight)
                                      pallet_length:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Length of the pallet (in inches)
                                      pallet_width:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Width of the pallet (in inches)
                                      pallet_height:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Height of the pallet (in inches)
                                      cartons_per_pallet:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                                      units_per_pallet:
                                        type: number
                                        format: float
                                        nullable: true
                                        description: Number of units per pallet (Shipping & Packing). `null` when not set.
                                      default_receiving_location_id:
                                        type: integer
                                        nullable: true
                                        description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                                      default_assembly_location_id:
                                        type: integer
                                        nullable: true
                                        description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                                      lead_time_days:
                                        type: integer
                                        nullable: true
                                        description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                                      sellable:
                                        type: boolean
                                        description: Whether the product can be sold
                                      discontinued:
                                        type: boolean
                                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                      is_drop_ship_item:
                                        type: boolean
                                        description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                      taxable:
                                        type: boolean
                                        description: Whether the product is subject to sales tax. Defaults to true when not set.
                                      lot_tracking:
                                        type: boolean
                                        description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                                      lot_deduction_strategy:
                                        type: string
                                        nullable: true
                                        description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                                      round_up_as_component:
                                        type: boolean
                                        description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                      default_supply_method:
                                        type: string
                                        nullable: true
                                        enum:
                                          - purchase
                                          - vendor_supplied
                                          - assemble
                                          - on_hand
                                          - assembly_order
                                          - buy_and_ship
                                          - brand_supplied
                                        description: Default supply mode used when planning replenishment for this product
                                      image_url:
                                        type: string
                                        nullable: true
                                        description: URL to the product's main image
                                      images:
                                        type: array
                                        description: |
                                          The product's image gallery, in order. Position 1 is the hero image channels receive first.
                                          Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                                          by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                                          them again rather than storing them.
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                              description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                                            url:
                                              type: string
                                              description: Presigned URL of the full-size image.
                                            thumbnail_url:
                                              type: string
                                              nullable: true
                                              description: Presigned URL of the thumbnail.
                                            position:
                                              type: integer
                                              description: 1-based position in the gallery.
                                      category:
                                        type: object
                                        nullable: true
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                        description: Product category information
                                      subcategory:
                                        type: object
                                        nullable: true
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                        description: Product subcategory information
                                      custom_fields:
                                        type: object
                                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                        additionalProperties:
                                          type: string
                                      attachments:
                                        type: array
                                        description: Product attachments
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                              description: Unique identifier for the attachment
                                            name:
                                              type: string
                                              description: Filename of the attachment
                                            type:
                                              type: string
                                              description: MIME type of the attachment
                                            size:
                                              type: integer
                                              description: File size in bytes
                                            full_url:
                                              type: string
                                              description: Full resolution URL of the attachment
                                            thumb_url:
                                              type: string
                                              description: Thumbnail URL of the attachment (if applicable)
                                          required:
                                            - id
                                            - name
                                            - type
                                            - size
                                            - full_url
                                      variants:
                                        type: array
                                        description: Product variants
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                            description:
                                              type: string
                                              nullable: true
                                            product_weight:
                                              type: array
                                              nullable: true
                                              items:
                                                type: object
                                                required:
                                                  - unit
                                                  - value
                                                properties:
                                                  unit:
                                                    type: string
                                                    enum:
                                                      - lb
                                                      - oz
                                                    description: Weight unit
                                                  value:
                                                    type: number
                                                    format: float
                                                    minimum: 0
                                                    description: Weight value
                                            product_weight_oz:
                                              type: number
                                              format: float
                                              nullable: true
                                            product_weight_lb:
                                              type: number
                                              format: float
                                              nullable: true
                                            dimensional_weight:
                                              type: array
                                              nullable: true
                                              items:
                                                type: object
                                                required:
                                                  - unit
                                                  - value
                                                properties:
                                                  unit:
                                                    type: string
                                                    enum:
                                                      - lb
                                                      - oz
                                                    description: Weight unit
                                                  value:
                                                    type: number
                                                    format: float
                                                    minimum: 0
                                                    description: Weight value
                                            dimensional_weight_oz:
                                              type: number
                                              format: float
                                              nullable: true
                                            dimensional_weight_lb:
                                              type: number
                                              format: float
                                              nullable: true
                                            box_weight:
                                              type: array
                                              nullable: true
                                              items:
                                                type: object
                                                required:
                                                  - unit
                                                  - value
                                                properties:
                                                  unit:
                                                    type: string
                                                    enum:
                                                      - lb
                                                      - oz
                                                    description: Weight unit
                                                  value:
                                                    type: number
                                                    format: float
                                                    minimum: 0
                                                    description: Weight value
                                            box_weight_oz:
                                              type: number
                                              format: float
                                              nullable: true
                                            box_weight_lb:
                                              type: number
                                              format: float
                                              nullable: true
                                            carton_weight:
                                              type: array
                                              nullable: true
                                              items:
                                                type: object
                                                required:
                                                  - unit
                                                  - value
                                                properties:
                                                  unit:
                                                    type: string
                                                    enum:
                                                      - lb
                                                      - oz
                                                    description: Weight unit
                                                  value:
                                                    type: number
                                                    format: float
                                                    minimum: 0
                                                    description: Weight value
                                            carton_weight_oz:
                                              type: number
                                              format: float
                                              nullable: true
                                            carton_weight_lb:
                                              type: number
                                              format: float
                                              nullable: true
                                            shipping_weight:
                                              type: array
                                              nullable: true
                                              items:
                                                type: object
                                                required:
                                                  - unit
                                                  - value
                                                properties:
                                                  unit:
                                                    type: string
                                                    enum:
                                                      - lb
                                                      - oz
                                                    description: Weight unit
                                                  value:
                                                    type: number
                                                    format: float
                                                    minimum: 0
                                                    description: Weight value
                                            shipping_weight_oz:
                                              type: number
                                              format: float
                                              nullable: true
                                            shipping_weight_lb:
                                              type: number
                                              format: float
                                              nullable: true
                                            pallet_weight:
                                              type: array
                                              nullable: true
                                              items:
                                                type: object
                                                required:
                                                  - unit
                                                  - value
                                                properties:
                                                  unit:
                                                    type: string
                                                    enum:
                                                      - lb
                                                      - oz
                                                    description: Weight unit
                                                  value:
                                                    type: number
                                                    format: float
                                                    minimum: 0
                                                    description: Weight value
                                            pallet_weight_oz:
                                              type: number
                                              format: float
                                              nullable: true
                                            pallet_weight_lb:
                                              type: number
                                              format: float
                                              nullable: true
                                            attachments:
                                              type: array
                                              description: Variant-specific attachments
                                              items:
                                                type: object
                                                properties:
                                                  id:
                                                    type: integer
                                                    description: Unique identifier for the attachment
                                                  name:
                                                    type: string
                                                    description: Filename of the attachment
                                                  type:
                                                    type: string
                                                    description: MIME type of the attachment
                                                  size:
                                                    type: integer
                                                    description: File size in bytes
                                                  full_url:
                                                    type: string
                                                    description: Full resolution URL of the attachment
                                                  thumb_url:
                                                    type: string
                                                    description: Thumbnail URL of the attachment (if applicable)
                                                required:
                                                  - id
                                                  - name
                                                  - type
                                                  - size
                                                  - full_url
                                            retail_price:
                                              type: number
                                              format: float
                                            wholesale_price:
                                              type: number
                                              format: float
                                            custom_fields:
                                              type: array
                                              items:
                                                type: object
                                            variant_attributes:
                                              type: array
                                              nullable: true
                                              description: |
                                                The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                                Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                                `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                                on that axis.
                                              items:
                                                type: object
                                                properties:
                                                  variant_name:
                                                    type: string
                                                    description: Name of the variant axis (e.g. "Size")
                                                  variant_terms:
                                                    type: array
                                                    description: Term value(s) selected for this child on that axis
                                                    items:
                                                      type: string
                                            sku:
                                              type: string
                                            upc:
                                              type: string
                                            hs_code:
                                              type: string
                                              nullable: true
                                              description: HS/HTS tariff code for the product (max 50 characters)
                                            round_up_as_component:
                                              type: boolean
                                              description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                            created_at:
                                              type: string
                                              format: date-time
                                            updated_at:
                                              type: string
                                              format: date-time
                                      variant_attributes:
                                        type: array
                                        nullable: true
                                        description: |
                                          Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                                          each axis. On a parent product, this is the union of all terms used by its child variants. On a
                                          child variant, this holds the specific term(s) the child is assigned to.

                                          Set via the request field `product_variants` (same shape) on create/update.
                                        items:
                                          type: object
                                          properties:
                                            variant_name:
                                              type: string
                                              description: 'Name of the variant axis (e.g. "Size", "Color")'
                                            variant_terms:
                                              type: array
                                              description: Terms on this axis
                                              items:
                                                type: string
                                      sku:
                                        type: string
                                        description: Internal SKU
                                      alternate_skus:
                                        type: array
                                        description: Alternate SKUs
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                            sku:
                                              type: string
                                      upc:
                                        type: string
                                        description: UPC/Barcode
                                      hs_code:
                                        type: string
                                        nullable: true
                                        description: HS/HTS tariff code for the product (max 50 characters)
                                      tags:
                                        type: array
                                        description: Tags associated with the product
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                              description: Unique identifier for the tag
                                            name:
                                              type: string
                                              description: Name of the tag
                                            description:
                                              type: string
                                              nullable: true
                                              description: Description of the tag
                                            icon:
                                              type: string
                                              nullable: true
                                              description: Icon identifier or URL for the tag
                                            color:
                                              type: string
                                              nullable: true
                                              description: Color code for the tag
                                          required:
                                            - id
                                            - name
                                      substitutions:
                                        type: array
                                        description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                              description: Substitution record ID
                                            priority:
                                              type: integer
                                              description: Substitution priority (lower number = higher priority)
                                            product:
                                              type: object
                                              description: The substitute product
                                              properties:
                                                id:
                                                  type: integer
                                                  description: Unique identifier for the product
                                                name:
                                                  type: string
                                                  description: Product name
                                                description:
                                                  type: string
                                                  nullable: true
                                                  description: Product description
                                                retail_price:
                                                  type: number
                                                  format: float
                                                  description: Retail price
                                                wholesale_price:
                                                  type: number
                                                  format: float
                                                  description: Wholesale price
                                                unit_cost:
                                                  type: number
                                                  format: float
                                                  description: Cost per unit
                                                product_weight:
                                                  type: array
                                                  nullable: true
                                                  items:
                                                    type: object
                                                    required:
                                                      - unit
                                                      - value
                                                    properties:
                                                      unit:
                                                        type: string
                                                        enum:
                                                          - lb
                                                          - oz
                                                        description: Weight unit
                                                      value:
                                                        type: number
                                                        format: float
                                                        minimum: 0
                                                        description: Weight value
                                                product_weight_oz:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                product_weight_lb:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                dimensional_weight:
                                                  type: array
                                                  nullable: true
                                                  items:
                                                    type: object
                                                    required:
                                                      - unit
                                                      - value
                                                    properties:
                                                      unit:
                                                        type: string
                                                        enum:
                                                          - lb
                                                          - oz
                                                        description: Weight unit
                                                      value:
                                                        type: number
                                                        format: float
                                                        minimum: 0
                                                        description: Weight value
                                                dimensional_weight_oz:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                dimensional_weight_lb:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                product_length:
                                                  type: number
                                                  format: float
                                                  description: Length of the product (in inches)
                                                product_width:
                                                  type: number
                                                  format: float
                                                  description: Width of the product (in inches)
                                                product_height:
                                                  type: number
                                                  format: float
                                                  description: Height of the product (in inches)
                                                box_weight:
                                                  type: array
                                                  nullable: true
                                                  items:
                                                    type: object
                                                    required:
                                                      - unit
                                                      - value
                                                    properties:
                                                      unit:
                                                        type: string
                                                        enum:
                                                          - lb
                                                          - oz
                                                        description: Weight unit
                                                      value:
                                                        type: number
                                                        format: float
                                                        minimum: 0
                                                        description: Weight value
                                                box_weight_oz:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                box_weight_lb:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                box_length:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Length of the box (in inches)
                                                box_width:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Width of the box (in inches)
                                                box_height:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Height of the box (in inches)
                                                carton_weight:
                                                  type: array
                                                  nullable: true
                                                  items:
                                                    type: object
                                                    required:
                                                      - unit
                                                      - value
                                                    properties:
                                                      unit:
                                                        type: string
                                                        enum:
                                                          - lb
                                                          - oz
                                                        description: Weight unit
                                                      value:
                                                        type: number
                                                        format: float
                                                        minimum: 0
                                                        description: Weight value
                                                carton_weight_oz:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                carton_weight_lb:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                carton_length:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Length of the carton (in inches)
                                                carton_width:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Width of the carton (in inches)
                                                carton_height:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Height of the carton (in inches)
                                                shipping_weight:
                                                  type: array
                                                  nullable: true
                                                  items:
                                                    type: object
                                                    required:
                                                      - unit
                                                      - value
                                                    properties:
                                                      unit:
                                                        type: string
                                                        enum:
                                                          - lb
                                                          - oz
                                                        description: Weight unit
                                                      value:
                                                        type: number
                                                        format: float
                                                        minimum: 0
                                                        description: Weight value
                                                shipping_weight_oz:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                shipping_weight_lb:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                shipping_length:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Shipping length (in inches)
                                                shipping_width:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Shipping width (in inches)
                                                shipping_height:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Shipping height (in inches)
                                                pallet_weight:
                                                  type: array
                                                  nullable: true
                                                  items:
                                                    type: object
                                                    required:
                                                      - unit
                                                      - value
                                                    properties:
                                                      unit:
                                                        type: string
                                                        enum:
                                                          - lb
                                                          - oz
                                                        description: Weight unit
                                                      value:
                                                        type: number
                                                        format: float
                                                        minimum: 0
                                                        description: Weight value
                                                pallet_weight_oz:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                pallet_weight_lb:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                pallet_length:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Length of the pallet (in inches)
                                                pallet_width:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Width of the pallet (in inches)
                                                pallet_height:
                                                  type: number
                                                  format: float
                                                  nullable: true
                                                  description: Height of the pallet (in inches)
                                                sellable:
                                                  type: boolean
                                                  description: Whether the product can be sold
                                                discontinued:
                                                  type: boolean
                                                  description: Whether the product is discontinued
                                                is_drop_ship_item:
                                                  type: boolean
                                                  description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                                taxable:
                                                  type: boolean
                                                  description: Whether the product is subject to sales tax. Defaults to true when not set.
                                                image_url:
                                                  type: string
                                                  nullable: true
                                                  description: URL to the product's main image
                                                sku:
                                                  type: string
                                                  description: Internal SKU
                                                upc:
                                                  type: string
                                                  description: UPC/Barcode
                                                hs_code:
                                                  type: string
                                                  nullable: true
                                                  description: HS/HTS tariff code for the product (max 50 characters)
                                                round_up_as_component:
                                                  type: boolean
                                                  description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                                created_at:
                                                  type: string
                                                  format: date-time
                                                  description: Timestamp when the product was created
                                                updated_at:
                                                  type: string
                                                  format: date-time
                                                  description: Timestamp when the product was last updated
                                      supplier:
                                        type: object
                                        nullable: true
                                        description: Supplier information
                                      type:
                                        type: string
                                        enum:
                                          - PRODUCT
                                          - KIT
                                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                      kit_items:
                                        type: array
                                        nullable: true
                                        description: Kit items (components) for kit products. Only present when type = KIT.
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                              description: Unique identifier for the kit item
                                            product_id:
                                              type: integer
                                              description: ID of the product component
                                            quantity:
                                              type: number
                                              format: float
                                              description: Quantity of this component in the kit
                                            uom_id:
                                              type: integer
                                              description: Unit of measure ID for the quantity
                                            base_uom_quantity:
                                              type: number
                                              format: float
                                              description: Quantity converted to base unit of measure
                                            price:
                                              type: number
                                              format: float
                                              description: Price for this kit item
                                            original_price:
                                              type: number
                                              format: float
                                              description: Original price for this kit item
                                            total:
                                              type: number
                                              format: float
                                              description: Calculated total (quantity * price)
                                            product:
                                              type: object
                                              nullable: true
                                              description: Product information for this kit item (when loaded)
                                              properties:
                                                id:
                                                  type: integer
                                                name:
                                                  type: string
                                                sku:
                                                  type: string
                                                description:
                                                  type: string
                                                  nullable: true
                                                retail_price:
                                                  type: number
                                                  format: float
                                                wholesale_price:
                                                  type: number
                                                  format: float
                                            unit_of_measure:
                                              type: object
                                              nullable: true
                                              description: Unit of measure information (when loaded)
                                              properties:
                                                id:
                                                  type: integer
                                                name:
                                                  type: string
                                                description:
                                                  type: string
                                                  nullable: true
                                                base_unit:
                                                  type: boolean
                                      priority_list:
                                        type: object
                                        nullable: true
                                        description: Fulfillment priority list assigned to this product
                                        properties:
                                          id:
                                            type: integer
                                            description: Priority list ID
                                          name:
                                            type: string
                                            description: Priority list name
                                          description:
                                            type: string
                                            nullable: true
                                            description: Priority list description
                                      distribution_template:
                                        type: object
                                        nullable: true
                                        description: |
                                          The distribution template (size curve) directly assigned to this product.
                                          Returns `null` when no template is assigned (the tenant default applies
                                          when resolving for production-run drafting). Use the dedicated
                                          `PUT /products/{productId}/distribution-template` endpoint to assign one.
                                        properties:
                                          id:
                                            type: integer
                                            description: Distribution template ID
                                          name:
                                            type: string
                                            description: Distribution template name
                                          source:
                                            type: string
                                            enum:
                                              - assigned
                                            description: Always `assigned` — only directly assigned templates are returned here.
                                      distribution_template_category:
                                        type: object
                                        nullable: true
                                        description: |
                                          The size-curve category assigned to this master SKU, used for
                                          category × warehouse resolution of a distribution template when no
                                          template is directly pinned. Returns `null` when no category is assigned.
                                          Use the dedicated `PUT /products/{productId}/distribution-template-category`
                                          endpoint to assign one.
                                        properties:
                                          id:
                                            type: integer
                                            description: Size-curve category ID
                                          name:
                                            type: string
                                            description: Size-curve category name
                                      boms:
                                        type: array
                                        description: BOMs (Bills of Materials) associated with this product
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                              description: Unique identifier for the BOM
                                            name:
                                              type: string
                                              description: BOM name
                                            items:
                                              type: array
                                              description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                                              items:
                                                type: object
                                                properties:
                                                  id:
                                                    type: integer
                                                    description: Unique identifier for the BOM item
                                                  bom_id:
                                                    type: integer
                                                    description: ID of the BOM this item belongs to
                                                  product_id:
                                                    type: integer
                                                    description: ID of the product/component
                                                  product:
                                                    type: object
                                                    nullable: true
                                                    description: Product information (when loaded)
                                                    properties:
                                                      id:
                                                        type: integer
                                                      name:
                                                        type: string
                                                      sku:
                                                        type: string
                                                      description:
                                                        type: string
                                                        nullable: true
                                                  quantity:
                                                    type: number
                                                    format: float
                                                    description: Quantity required for this item
                                                  base_quantity:
                                                    type: number
                                                    format: float
                                                    description: Base quantity (converted to base unit of measure)
                                                  note:
                                                    type: string
                                                    nullable: true
                                                    description: Optional note for this item
                                                  uom_id:
                                                    type: integer
                                                    nullable: true
                                                    description: Unit of measure ID
                                                  unit_of_measure:
                                                    type: object
                                                    nullable: true
                                                    description: Unit of measure information (when loaded)
                                                    properties:
                                                      id:
                                                        type: integer
                                                      name:
                                                        type: string
                                                  order:
                                                    type: integer
                                                    nullable: true
                                                    description: Display order for this item
                                                  consumption_basis:
                                                    type: string
                                                    enum:
                                                      - planned
                                                      - actual
                                                    description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                                  created_at:
                                                    type: string
                                                    format: date-time
                                                    description: Timestamp when the item was created
                                                  updated_at:
                                                    type: string
                                                    format: date-time
                                                    description: Timestamp when the item was last updated
                                                required:
                                                  - id
                                                  - bom_id
                                                  - product_id
                                                  - quantity
                                            extra_costs:
                                              type: array
                                              description: Additional costs associated with the BOM
                                              items:
                                                type: object
                                                properties:
                                                  id:
                                                    type: integer
                                                    description: Unique identifier for the extra cost
                                                  name:
                                                    type: string
                                                    description: Name/description of the extra cost
                                                  quantity:
                                                    type: number
                                                    format: float
                                                    description: Quantity for this cost item
                                                  unit_price:
                                                    type: number
                                                    format: float
                                                    description: Unit price for this cost item
                                                  line_total:
                                                    type: number
                                                    format: float
                                                    description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                                  created_at:
                                                    type: string
                                                    format: date-time
                                                    description: Timestamp when the extra cost was created
                                                  updated_at:
                                                    type: string
                                                    format: date-time
                                                    description: Timestamp when the extra cost was last updated
                                                required:
                                                  - id
                                                  - name
                                                  - quantity
                                                  - unit_price
                                                  - line_total
                                            created_at:
                                              type: string
                                              format: date-time
                                              description: Timestamp when the BOM was created
                                            updated_at:
                                              type: string
                                              format: date-time
                                              description: Timestamp when the BOM was last updated
                                          required:
                                            - id
                                            - name
                                      created_at:
                                        type: string
                                        format: date-time
                                        description: Timestamp when the product was created
                                      updated_at:
                                        type: string
                                        format: date-time
                                        description: Timestamp when the product was last updated
                                      created_by:
                                        type: integer
                                        description: |
                                          ID of the user who created the product. `0` for products created before
                                          provenance was recorded or by a system path with no attributable user.
                                          Products created through the External API are stamped with the API token's user.
                                      updated_by:
                                        type: integer
                                        description: ID of the user who last updated the product. `0` when never attributed.
                                      created_via:
                                        type: string
                                        nullable: true
                                        enum:
                                          - user
                                          - api
                                          - import
                                          - auto_create_sku
                                          - job
                                          - system
                                        description: |
                                          How the product was created, stamped once at creation and never changed:
                                          `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                                          `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                                          console command), or `system` (other internal write). `null` for products created
                                          before provenance was recorded (unknown source).

                                          Always present on single-product responses. On product **list** endpoints
                                          (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                                          it is only returned when requested with `?include=created_via`.
                        sales_orders:
                          type: array
                          description: Sales orders linked to this picklist. Only present when loaded. A picklist attaches through either sales orders or fulfillment orders.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Unique identifier for the sales order
                              created_at:
                                type: string
                                format: date-time
                                description: Timestamp when the order was created
                              updated_at:
                                type: string
                                format: date-time
                                description: Timestamp when the order was last updated
                              status:
                                type: string
                                description: Current status of the order
                              order_id:
                                type: string
                                description: External order identifier
                              order_number:
                                type: string
                                description: Order number
                              order_date:
                                type: string
                                format: date
                                description: Date when the order was placed
                              payment_date:
                                type: string
                                format: date
                                description: Date when payment was received
                              ship_by_date:
                                type: string
                                format: date
                                description: Required ship by date
                              age:
                                type: integer
                                description: Age of the order in days
                              order_status:
                                type: string
                                description: Status of the order
                              customer_id:
                                type: string
                                description: Customer identifier
                              customer_username:
                                type: string
                                description: Customer's username
                              customer_email:
                                type: string
                                description: Customer's email address
                              bill_to:
                                type: object
                                description: Billing information
                              ship_to:
                                type: object
                                description: Shipping information
                              requested_shipping_service:
                                type: string
                                nullable: true
                                description: What shipping service to use when shipping this order
                              total:
                                type: number
                                format: float
                                description: Total order amount
                              total_paid:
                                type: number
                                format: float
                                description: Amount paid
                              total_tax:
                                type: number
                                format: float
                                description: Total tax amount
                              total_shipping:
                                type: number
                                format: float
                                description: Total shipping amount
                              customer_notes:
                                type: string
                                description: Notes from the customer
                              internal_notes:
                                type: string
                                description: Internal notes
                              ship_date:
                                type: string
                                format: date
                                description: Date when order was shipped
                              hold_until_date:
                                type: string
                                format: date
                                description: Hold until date
                              earliest_ship_date:
                                type: string
                                format: date
                                nullable: true
                                description: Earliest date the order can be shipped
                              user_id:
                                type: integer
                                description: User ID associated with the order
                              externally_fulfilled:
                                type: boolean
                                description: Whether the order is fulfilled externally
                              externally_fulfilled_by:
                                type: string
                                description: Entity fulfilling the order externally
                              is_posted:
                                type: boolean
                                description: Whether the order is posted
                              posted_by:
                                type: string
                                description: User who posted the order
                              not_sync:
                                type: boolean
                                description: Sync status
                              sales_posted:
                                type: boolean
                                description: Sales posting status
                              split_order:
                                type: boolean
                                description: Whether the order is split
                              skip_inventory:
                                type: boolean
                                description: Whether to skip inventory
                              skip_sales_report:
                                type: boolean
                                description: Whether to skip sales report
                              channel_id:
                                type: integer
                                description: Channel identifier
                              total_order_cost:
                                type: number
                                format: float
                                description: Total cost of order
                              total_order_quantity:
                                type: number
                                format: float
                                description: Total quantity of items
                              order_cost_details:
                                type: object
                                description: Detailed order cost information
                              source:
                                type: string
                                description: Order source
                              shipstation_order_id:
                                type: string
                                description: ShipStation order identifier
                              type:
                                type: string
                                description: Order type
                              parent_id:
                                type: integer
                                description: Parent order ID if applicable
                              shipping_revenue:
                                type: number
                                format: float
                                description: Revenue from shipping
                              product_total:
                                type: number
                                format: float
                                description: Total product amount
                              total_discount:
                                type: number
                                format: float
                                description: Total discount amount
                              picking_status:
                                type: string
                                description: Status of picking process
                              starred_description:
                                type: string
                                description: Description for starred orders
                              customer_po_number:
                                type: string
                                description: Customer PO number
                              company_id:
                                type: integer
                                nullable: true
                                description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                                example: 123
                              company:
                                nullable: true
                                description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the company
                                    example: 123456
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: When the company was created
                                    example: '2023-03-15T14:30:00Z'
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: When the company was last updated
                                    example: '2023-03-15T14:30:00Z'
                                  status:
                                    type: string
                                    description: Status of the company
                                    enum:
                                      - active
                                      - inactive
                                    example: active
                                  name:
                                    type: string
                                    description: Company name
                                    example: Acme Corporation
                                  type:
                                    type: string
                                    nullable: true
                                    description: Type of business
                                    example: Retail
                                  phone:
                                    type: string
                                    nullable: true
                                    description: Primary phone number for the company
                                    example: 555-123-4567
                                  address:
                                    type: string
                                    nullable: true
                                    description: Street address for the company
                                    example: 123 Main St
                                  address_line_2:
                                    type: string
                                    nullable: true
                                    description: Additional address information
                                    example: Suite 500
                                  city:
                                    type: string
                                    nullable: true
                                    description: City
                                    example: Austin
                                  state:
                                    type: string
                                    nullable: true
                                    description: State/province
                                    example: TX
                                  postal_code:
                                    type: string
                                    nullable: true
                                    description: Postal/ZIP code
                                    example: '78701'
                                  country:
                                    type: string
                                    nullable: true
                                    description: Country
                                    example: USA
                                  full_address:
                                    type: string
                                    nullable: true
                                    description: Complete formatted address
                                    example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                                  shipping_first_name:
                                    type: string
                                    nullable: true
                                    description: First name for shipping contact (legacy field)
                                    example: John
                                  shipping_last_name:
                                    type: string
                                    nullable: true
                                    description: Last name for shipping contact (legacy field)
                                    example: Doe
                                  shipping_email:
                                    type: string
                                    format: email
                                    nullable: true
                                    description: Email for shipping contact (legacy field)
                                    example: shipping@acmecorp.com
                                  shipping_phone:
                                    type: string
                                    nullable: true
                                    description: Phone number for shipping contact (legacy field)
                                    example: 555-987-6543
                                  shipping_address:
                                    type: string
                                    nullable: true
                                    description: Shipping street address (legacy field)
                                    example: 456 Warehouse Blvd
                                  shipping_city:
                                    type: string
                                    nullable: true
                                    description: Shipping city (legacy field)
                                    example: Austin
                                  shipping_state:
                                    type: string
                                    nullable: true
                                    description: Shipping state/province (legacy field)
                                    example: TX
                                  shipping_postal_code:
                                    type: string
                                    nullable: true
                                    description: Shipping postal/ZIP code (legacy field)
                                    example: '78745'
                                  shipping_country:
                                    type: string
                                    nullable: true
                                    description: Shipping country (legacy field)
                                    example: USA
                                  shipping_full_address:
                                    type: string
                                    nullable: true
                                    description: Complete formatted shipping address (legacy field)
                                    example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                                  payment_term:
                                    type: string
                                    nullable: true
                                    description: Payment terms for the company
                                    example: Net 30
                                  tax_exempt:
                                    type: boolean
                                    nullable: true
                                    description: Whether the company is exempt from taxes
                                    example: false
                                  tax_rate:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Tax rate applied to the company's orders
                                    example: 8.25
                                  due_date_days:
                                    type: integer
                                    nullable: true
                                    description: Number of days until payment is due
                                    example: 30
                                  credit_limit:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Credit limit for the company. `null` means no limit is set.
                                    example: 5000
                                  header_discount_enabled:
                                    type: boolean
                                    description: Whether an order-header trade discount is applied by default for this company
                                    example: false
                                  header_discount_type:
                                    type: string
                                    nullable: true
                                    enum:
                                      - PERCENT
                                      - FIXED_AMOUNT
                                    description: How the header discount is calculated — a percentage of the order or a fixed amount
                                    example: PERCENT
                                  header_discount_value:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                                    example: 5
                                  header_discount_effective_from:
                                    type: string
                                    format: date
                                    nullable: true
                                    description: Date from which the header discount takes effect (YYYY-MM-DD)
                                    example: '2026-01-01'
                                  default_currency_code:
                                    type: string
                                    nullable: true
                                    description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                                    example: USD
                                  price_level:
                                    nullable: true
                                    description: Price level associated with this company
                                    type: object
                                    properties:
                                      id:
                                        type: number
                                        description: Unique identifier for the price level
                                        example: 123
                                      created_at:
                                        type: string
                                        format: date-time
                                        description: When the price level was created
                                        example: '2023-03-15T14:30:00Z'
                                      updated_at:
                                        type: string
                                        format: date-time
                                        description: When the price level was last updated
                                        example: '2023-03-15T14:30:00Z'
                                      status:
                                        type: string
                                        description: Status of the price level
                                        enum:
                                          - active
                                          - inactive
                                        example: active
                                      name:
                                        type: string
                                        description: Name of the price level
                                        example: Wholesale
                                      type:
                                        type: string
                                        description: Type of the price level
                                        example: percentage
                                      percent_increase:
                                        type: number
                                        format: float
                                        description: Percentage increase (or decrease) for this price level
                                        example: 15.5
                                  notes:
                                    type: string
                                    nullable: true
                                    description: Additional notes about the company
                                    example: 'Key account, requires special handling'
                                  fein:
                                    type: string
                                    nullable: true
                                    description: Federal Employer Identification Number
                                    example: 12-3456789
                                  tags:
                                    type: array
                                    nullable: true
                                    description: List of tags associated with the company
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the tag
                                        name:
                                          type: string
                                          description: Name of the tag
                                        description:
                                          type: string
                                          nullable: true
                                          description: Description of the tag
                                        icon:
                                          type: string
                                          nullable: true
                                          description: Icon identifier or URL for the tag
                                        color:
                                          type: string
                                          nullable: true
                                          description: Color code for the tag
                                      required:
                                        - id
                                        - name
                                  default_shipping:
                                    nullable: true
                                    description: Default shipping address
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the shipping address
                                        example: 789
                                      created_at:
                                        type: string
                                        format: date-time
                                        description: When the shipping address was created
                                        example: '2023-03-15T14:30:00Z'
                                      updated_at:
                                        type: string
                                        format: date-time
                                        description: When the shipping address was last updated
                                        example: '2023-03-15T14:30:00Z'
                                      company_id:
                                        type: integer
                                        description: ID of the company this shipping address belongs to
                                        example: 123456
                                      company_name:
                                        type: string
                                        nullable: true
                                        description: Name of the company
                                        example: Acme Corporation
                                      address:
                                        type: string
                                        description: Street address
                                        example: 456 Warehouse Blvd
                                      address_line_2:
                                        type: string
                                        nullable: true
                                        description: Additional address information
                                        example: Building 2
                                      city:
                                        type: string
                                        description: City
                                        example: Austin
                                      state:
                                        type: string
                                        description: State/province
                                        example: TX
                                      postal_code:
                                        type: string
                                        description: Postal/ZIP code
                                        example: '78745'
                                      country:
                                        type: string
                                        description: Country
                                        example: USA
                                      full_address:
                                        type: string
                                        description: Complete formatted address
                                        example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                      full_name:
                                        type: string
                                        description: Full name of the contact person
                                        example: John Doe
                                      first_name:
                                        type: string
                                        nullable: true
                                        description: First name of the contact person
                                        example: John
                                      last_name:
                                        type: string
                                        nullable: true
                                        description: Last name of the contact person
                                        example: Doe
                                      phone:
                                        type: string
                                        nullable: true
                                        description: Phone number
                                        example: 555-987-6543
                                      email:
                                        type: string
                                        format: email
                                        nullable: true
                                        description: Email address
                                        example: shipping@acmecorp.com
                                      is_default:
                                        type: boolean
                                        description: Whether this is the default shipping address
                                        example: true
                                    required:
                                      - id
                                      - company_id
                                      - address
                                      - city
                                      - state
                                      - postal_code
                                      - country
                                  shipping_addresses:
                                    type: array
                                    nullable: true
                                    description: List of shipping addresses for the company
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the shipping address
                                          example: 789
                                        created_at:
                                          type: string
                                          format: date-time
                                          description: When the shipping address was created
                                          example: '2023-03-15T14:30:00Z'
                                        updated_at:
                                          type: string
                                          format: date-time
                                          description: When the shipping address was last updated
                                          example: '2023-03-15T14:30:00Z'
                                        company_id:
                                          type: integer
                                          description: ID of the company this shipping address belongs to
                                          example: 123456
                                        company_name:
                                          type: string
                                          nullable: true
                                          description: Name of the company
                                          example: Acme Corporation
                                        address:
                                          type: string
                                          description: Street address
                                          example: 456 Warehouse Blvd
                                        address_line_2:
                                          type: string
                                          nullable: true
                                          description: Additional address information
                                          example: Building 2
                                        city:
                                          type: string
                                          description: City
                                          example: Austin
                                        state:
                                          type: string
                                          description: State/province
                                          example: TX
                                        postal_code:
                                          type: string
                                          description: Postal/ZIP code
                                          example: '78745'
                                        country:
                                          type: string
                                          description: Country
                                          example: USA
                                        full_address:
                                          type: string
                                          description: Complete formatted address
                                          example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                        full_name:
                                          type: string
                                          description: Full name of the contact person
                                          example: John Doe
                                        first_name:
                                          type: string
                                          nullable: true
                                          description: First name of the contact person
                                          example: John
                                        last_name:
                                          type: string
                                          nullable: true
                                          description: Last name of the contact person
                                          example: Doe
                                        phone:
                                          type: string
                                          nullable: true
                                          description: Phone number
                                          example: 555-987-6543
                                        email:
                                          type: string
                                          format: email
                                          nullable: true
                                          description: Email address
                                          example: shipping@acmecorp.com
                                        is_default:
                                          type: boolean
                                          description: Whether this is the default shipping address
                                          example: true
                                      required:
                                        - id
                                        - company_id
                                        - address
                                        - city
                                        - state
                                        - postal_code
                                        - country
                                  billing_info:
                                    type: object
                                    nullable: true
                                    description: Billing information
                                    properties:
                                      id:
                                        type: integer
                                        example: 456
                                      created_at:
                                        type: string
                                        format: date-time
                                        example: '2023-03-15T14:30:00Z'
                                      updated_at:
                                        type: string
                                        format: date-time
                                        example: '2023-03-15T14:30:00Z'
                                      first_name:
                                        type: string
                                        nullable: true
                                        example: Jane
                                      last_name:
                                        type: string
                                        nullable: true
                                        example: Smith
                                      email:
                                        type: string
                                        format: email
                                        nullable: true
                                        example: accounting@acmecorp.com
                                      receiving_bank_name:
                                        type: string
                                        nullable: true
                                        example: First National Bank
                                      receiving_bank_address:
                                        type: string
                                        nullable: true
                                        example: '789 Finance Street, Austin, TX 78701'
                                  client_type:
                                    type: object
                                    nullable: true
                                    description: Type of client
                                    properties:
                                      id:
                                        type: integer
                                        example: 123
                                      created_at:
                                        type: string
                                        format: date-time
                                        example: '2023-03-15T14:30:00Z'
                                      updated_at:
                                        type: string
                                        format: date-time
                                        example: '2023-03-15T14:30:00Z'
                                      name:
                                        type: string
                                        example: Retail
                                      description:
                                        type: string
                                        nullable: true
                                        example: Retail business client
                                  parent_company_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the parent company
                                    example: 456
                                  invoice_export_template_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the invoice export template
                                    example: 789
                                  custom_fields:
                                    type: object
                                    description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                    example:
                                      Industry: Manufacturing
                                      Region: Southwest
                                      Annual Revenue: $5M-$10M
                                  assigned_sales_reps:
                                    type: array
                                    description: |
                                      Sales rep users assigned to this company (Go Team members). Resolved from the company's
                                      `goTeamMember.user` relation. Only present when the relation is loaded.
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: User ID of the assigned sales rep
                                          example: 42
                                        email:
                                          type: string
                                          description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                          example: rep@example.com
                                        first_name:
                                          type: string
                                          nullable: true
                                          example: Jane
                                        last_name:
                                          type: string
                                          nullable: true
                                          example: Doe
                                  sales_channel:
                                    allOf:
                                      - type: object
                                        properties:
                                          id:
                                            type: integer
                                            description: Sales channel ID.
                                          status:
                                            type: string
                                            description: Sales channel status (e.g. active).
                                          label:
                                            type: string
                                            nullable: true
                                            description: Human-readable channel label.
                                          channel_type:
                                            type: string
                                            nullable: true
                                            description: Channel type (e.g. the integration/platform the channel represents).
                                          created_at:
                                            type: string
                                            format: date-time
                                          updated_at:
                                            type: string
                                            format: date-time
                                    nullable: true
                                    description: The company's default sales channel. Only present when the relation is loaded.
                                required:
                                  - id
                                  - name
                                  - status
                              custom_fields:
                                type: object
                                description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                additionalProperties:
                                  type: string
                              items:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the order item
                                    line_number:
                                      type: integer
                                      description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                                    created_at:
                                      type: string
                                      format: date-time
                                      description: Creation timestamp
                                    updated_at:
                                      type: string
                                      format: date-time
                                      description: Last update timestamp
                                    sku:
                                      type: string
                                      description: Stock keeping unit
                                    name:
                                      type: string
                                      description: Product name
                                    image_url:
                                      type: string
                                      description: URL of product image
                                    weight:
                                      type: object
                                      description: Weight information
                                    quantity:
                                      type: number
                                      format: float
                                      description: Ordered quantity
                                    unit_price:
                                      type: number
                                      format: float
                                      description: Price per unit
                                    tax:
                                      type: number
                                      format: float
                                      description: Tax amount
                                    shipping:
                                      type: number
                                      format: float
                                      description: Shipping amount
                                    warehouse_location:
                                      type: string
                                      description: Location in warehouse
                                    options:
                                      type: object
                                      description: Additional options
                                    fulfillment_sku:
                                      type: string
                                      description: SKU used for fulfillment
                                    adjustment:
                                      type: number
                                      format: float
                                      description: Price adjustment
                                    upc:
                                      type: string
                                      description: Universal Product Code
                                    stock_id:
                                      type: integer
                                      description: Stock identifier
                                    kit_id:
                                      type: integer
                                      description: Kit identifier if part of a kit
                                    non_physical_item:
                                      type: boolean
                                      description: Whether item is non-physical
                                    ignore_item:
                                      type: boolean
                                      description: Whether to ignore this item
                                    is_locally_added:
                                      type: boolean
                                      description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                                    quantity_shipped:
                                      type: number
                                      format: float
                                      description: Quantity shipped
                                    quantity_cancelled:
                                      type: number
                                      format: float
                                      description: Quantity cancelled
                                    quantity_invoiced:
                                      type: number
                                      format: float
                                      description: Quantity invoiced
                                    quantity_ordered:
                                      type: number
                                      format: float
                                      description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                                    base_uom_id:
                                      type: integer
                                      description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                                    ordered_uom_id:
                                      type: integer
                                      description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                                    product_id:
                                      type: integer
                                      description: Product identifier
                                    total_returned_base_quantity:
                                      type: number
                                      format: float
                                      description: Total quantity returned
                                    parent_id:
                                      type: integer
                                      description: Parent item ID
                                    status:
                                      type: string
                                      description: Item status
                                    discount:
                                      type: number
                                      format: float
                                      description: Discount amount
                                    estimated_ship_date:
                                      type: string
                                      format: date
                                      description: Estimated shipping date
                                    custom_fields:
                                      type: object
                                      description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                      additionalProperties:
                                        type: string
                                    product:
                                      type: object
                                      description: Product information
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the product
                                        name:
                                          type: string
                                          description: Product name
                                        description:
                                          type: string
                                          nullable: true
                                          description: Product description
                                        retail_price:
                                          type: number
                                          format: float
                                          description: Retail price
                                        wholesale_price:
                                          type: number
                                          format: float
                                          description: Wholesale price
                                        unit_cost:
                                          type: number
                                          format: float
                                          description: Cost per unit
                                        product_weight:
                                          type: number
                                          format: float
                                          description: Weight of the product
                                        product_length:
                                          type: number
                                          format: float
                                          description: Length of the product (in inches)
                                        product_width:
                                          type: number
                                          format: float
                                          description: Width of the product (in inches)
                                        product_height:
                                          type: number
                                          format: float
                                          description: Height of the product (in inches)
                                        sellable:
                                          type: boolean
                                          description: Whether the product can be sold
                                        discontinued:
                                          type: boolean
                                          description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                        image_url:
                                          type: string
                                          nullable: true
                                          description: URL to the product's main image
                                        category:
                                          type: object
                                          nullable: true
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                          description: Product category information
                                        subcategory:
                                          type: object
                                          nullable: true
                                          properties:
                                            id:
                                              type: integer
                                            name:
                                              type: string
                                          description: Product subcategory information
                                        custom_fields:
                                          type: object
                                          description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                          additionalProperties:
                                            type: string
                                        variant_attributes:
                                          type: object
                                          nullable: true
                                          description: Available variant attributes
                                        sku:
                                          type: string
                                          description: Internal SKU
                                        alternate_skus:
                                          type: array
                                          description: Alternate SKUs
                                          items:
                                            type: object
                                            properties:
                                              id:
                                                type: integer
                                              sku:
                                                type: string
                                        upc:
                                          type: string
                                          description: UPC/Barcode
                                        tags:
                                          type: array
                                          description: Tags associated with the product
                                          items:
                                            type: object
                                            properties:
                                              id:
                                                type: integer
                                                description: Unique identifier for the tag
                                              name:
                                                type: string
                                                description: Name of the tag
                                              description:
                                                type: string
                                                nullable: true
                                                description: Description of the tag
                                              icon:
                                                type: string
                                                nullable: true
                                                description: Icon identifier or URL for the tag
                                              color:
                                                type: string
                                                nullable: true
                                                description: Color code for the tag
                                            required:
                                              - id
                                              - name
                                        supplier:
                                          type: object
                                          nullable: true
                                          description: Supplier information
                                        type:
                                          type: string
                                          enum:
                                            - PRODUCT
                                            - KIT
                                          description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                        kit_items:
                                          type: array
                                          nullable: true
                                          description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                          items:
                                            type: object
                                            properties:
                                              id:
                                                type: integer
                                                description: Unique identifier for the kit item
                                              product_id:
                                                type: integer
                                                description: ID of the product component
                                              quantity:
                                                type: number
                                                format: float
                                                description: Quantity of this component in the kit
                                              uom_id:
                                                type: integer
                                                description: Unit of measure ID for the quantity
                                              base_uom_quantity:
                                                type: number
                                                format: float
                                                description: Quantity converted to base unit of measure
                                              price:
                                                type: number
                                                format: float
                                                description: Price for this kit item
                                              original_price:
                                                type: number
                                                format: float
                                                description: Original price for this kit item
                                              total:
                                                type: number
                                                format: float
                                                description: Calculated total (quantity * price)
                                              product:
                                                type: object
                                                nullable: true
                                                description: Product information for this kit item (when loaded)
                                                properties:
                                                  id:
                                                    type: integer
                                                  name:
                                                    type: string
                                                  sku:
                                                    type: string
                                                  description:
                                                    type: string
                                                    nullable: true
                                                  retail_price:
                                                    type: number
                                                    format: float
                                                  wholesale_price:
                                                    type: number
                                                    format: float
                                              unit_of_measure:
                                                type: object
                                                nullable: true
                                                description: Unit of measure information (when loaded)
                                                properties:
                                                  id:
                                                    type: integer
                                                  name:
                                                    type: string
                                                  description:
                                                    type: string
                                                    nullable: true
                                                  base_unit:
                                                    type: boolean
                                        created_at:
                                          type: string
                                          format: date-time
                                          description: Timestamp when the product was created
                                        updated_at:
                                          type: string
                                          format: date-time
                                          description: Timestamp when the product was last updated
                                    tags:
                                      type: array
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          description:
                                            type: string
                                          icon:
                                            type: string
                                          color:
                                            type: string
                                          discount_structure:
                                            type: object
                                          markup_structure:
                                            type: object
                                      description: Tags associated with the sales order item
                                description: Line items in the order
                              fulfillment_orders:
                                type: array
                                description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Fulfillment order ID
                                    order_number:
                                      type: string
                                      description: Fulfillment order number
                                    order_key:
                                      type: string
                                      nullable: true
                                      description: Fulfillment order key
                                    order_status:
                                      type: string
                                      description: Fulfillment order status
                                    sales_order_id:
                                      type: integer
                                      description: Associated sales order ID
                                    warehouse_group_id:
                                      type: integer
                                      nullable: true
                                      description: Warehouse group ID
                                    destination_oms_id:
                                      type: integer
                                      nullable: true
                                      description: Destination app integration account ID
                                    destination_oms_store_id:
                                      type: integer
                                      nullable: true
                                    fulfillment_channel_id:
                                      type: integer
                                      nullable: true
                                    pushed_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    packing_slip_printed_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                      description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                                    error_message:
                                      type: string
                                      nullable: true
                                      description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                                    ship_by_date:
                                      type: string
                                      format: date
                                      nullable: true
                                      description: Ship by date
                                    total:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Order total
                                    bill_to:
                                      type: object
                                      nullable: true
                                      description: Billing address
                                      properties:
                                        name:
                                          type: string
                                        company:
                                          type: string
                                        street1:
                                          type: string
                                        street2:
                                          type: string
                                        street3:
                                          type: string
                                        city:
                                          type: string
                                        state:
                                          type: string
                                        postal_code:
                                          type: string
                                        country:
                                          type: string
                                        phone:
                                          type: string
                                    ship_to:
                                      type: object
                                      nullable: true
                                      description: Shipping address
                                      properties:
                                        name:
                                          type: string
                                        company:
                                          type: string
                                        street1:
                                          type: string
                                        street2:
                                          type: string
                                        street3:
                                          type: string
                                        city:
                                          type: string
                                        state:
                                          type: string
                                        postal_code:
                                          type: string
                                        country:
                                          type: string
                                        phone:
                                          type: string
                                    invoice_to:
                                      type: object
                                      nullable: true
                                      description: Invoice address
                                      properties:
                                        name:
                                          type: string
                                        company:
                                          type: string
                                        street1:
                                          type: string
                                        street2:
                                          type: string
                                        street3:
                                          type: string
                                        city:
                                          type: string
                                        state:
                                          type: string
                                        postal_code:
                                          type: string
                                        country:
                                          type: string
                                        phone:
                                          type: string
                                    sales_order:
                                      type: object
                                      nullable: true
                                      description: Nested sales order data
                                    picklists:
                                      type: array
                                      description: Associated picklists
                                      items:
                                        type: object
                                    fulfillment_order_items:
                                      type: array
                                      description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            nullable: true
                                            description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                          shipment_id:
                                            type: integer
                                            nullable: true
                                            description: ID of the fulfillment order this line belongs to.
                                          status:
                                            nullable: true
                                            description: Line status.
                                          sales_order_item_id:
                                            type: integer
                                            nullable: true
                                            description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                          product_id:
                                            type: integer
                                            nullable: true
                                            description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                          sku:
                                            type: string
                                            nullable: true
                                          name:
                                            type: string
                                            nullable: true
                                          weight:
                                            nullable: true
                                            description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                          dimensions:
                                            nullable: true
                                            description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                          quantity:
                                            type: number
                                            description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                          unit_price:
                                            type: number
                                            description: Unit price. Always `0` on synthetic component rows.
                                          lot_id:
                                            type: integer
                                            nullable: true
                                          lot_number:
                                            type: string
                                            nullable: true
                                          expiry_date:
                                            type: string
                                            nullable: true
                                            description: Lot expiry date.
                                          created_at:
                                            type: string
                                            format: date-time
                                          updated_at:
                                            type: string
                                            format: date-time
                                          is_kit_component:
                                            type: boolean
                                            description: True when the row is a component of a kit (stored or synthetic).
                                          parent_fulfillment_order_item_id:
                                            type: integer
                                            nullable: true
                                            description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                          kit_sales_order_item_id:
                                            type: integer
                                            nullable: true
                                            description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                          is_synthetic:
                                            type: boolean
                                            description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                                    total_weight:
                                      type: object
                                      nullable: true
                                      description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                                      properties:
                                        total_oz:
                                          type: number
                                          format: float
                                          description: Total weight in ounces
                                        total_lb:
                                          type: number
                                          format: float
                                          description: Total weight in pounds
                                        line_count:
                                          type: integer
                                          description: Number of fulfillment order lines
                                        weighed_line_count:
                                          type: integer
                                          description: Number of lines that had a usable weight and contributed to the total
                                        is_complete:
                                          type: boolean
                                          description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                                    tags:
                                      type: array
                                      description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            description: Unique identifier for the tag
                                          name:
                                            type: string
                                            description: Name of the tag
                                          description:
                                            type: string
                                            nullable: true
                                            description: Description of the tag
                                          icon:
                                            type: string
                                            nullable: true
                                            description: Icon identifier or URL for the tag
                                          color:
                                            type: string
                                            nullable: true
                                            description: Color code for the tag
                                        required:
                                          - id
                                          - name
                                    purchase_orders:
                                      type: array
                                      description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                          order_status:
                                            type: string
                                            nullable: true
                                            enum:
                                              - active
                                              - deleted
                                              - completed
                                    source_reference_identifier:
                                      type: string
                                      nullable: true
                                      description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                                    held_for_item_change:
                                      type: boolean
                                      description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                                    created_at:
                                      type: string
                                      format: date-time
                                      description: When the fulfillment order was created
                                    updated_at:
                                      type: string
                                      format: date-time
                                      description: When the fulfillment order was last updated
                              tags:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    name:
                                      type: string
                                    description:
                                      type: string
                                    icon:
                                      type: string
                                    color:
                                      type: string
                                    discount_structure:
                                      type: object
                                    markup_structure:
                                      type: object
                                description: Tags associated with the order
                        fulfillment_orders:
                          type: array
                          description: Fulfillment orders linked to this picklist. Only present when loaded. A picklist attaches through either fulfillment orders or sales orders.
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: Fulfillment order ID
                              order_number:
                                type: string
                                description: Fulfillment order number
                              order_key:
                                type: string
                                nullable: true
                                description: Fulfillment order key
                              order_status:
                                type: string
                                description: Fulfillment order status
                              sales_order_id:
                                type: integer
                                description: Associated sales order ID
                              warehouse_group_id:
                                type: integer
                                nullable: true
                                description: Warehouse group ID
                              destination_oms_id:
                                type: integer
                                nullable: true
                                description: Destination app integration account ID
                              destination_oms_store_id:
                                type: integer
                                nullable: true
                              fulfillment_channel_id:
                                type: integer
                                nullable: true
                              pushed_at:
                                type: string
                                format: date-time
                                nullable: true
                              packing_slip_printed_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                              error_message:
                                type: string
                                nullable: true
                                description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                              ship_by_date:
                                type: string
                                format: date
                                nullable: true
                                description: Ship by date
                              total:
                                type: number
                                format: float
                                nullable: true
                                description: Order total
                              bill_to:
                                type: object
                                nullable: true
                                description: Billing address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              ship_to:
                                type: object
                                nullable: true
                                description: Shipping address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              invoice_to:
                                type: object
                                nullable: true
                                description: Invoice address
                                properties:
                                  name:
                                    type: string
                                  company:
                                    type: string
                                  street1:
                                    type: string
                                  street2:
                                    type: string
                                  street3:
                                    type: string
                                  city:
                                    type: string
                                  state:
                                    type: string
                                  postal_code:
                                    type: string
                                  country:
                                    type: string
                                  phone:
                                    type: string
                              sales_order:
                                type: object
                                nullable: true
                                description: Nested sales order data
                              picklists:
                                type: array
                                description: Associated picklists
                                items:
                                  type: object
                              fulfillment_order_items:
                                type: array
                                description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      nullable: true
                                      description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                    shipment_id:
                                      type: integer
                                      nullable: true
                                      description: ID of the fulfillment order this line belongs to.
                                    status:
                                      nullable: true
                                      description: Line status.
                                    sales_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                    product_id:
                                      type: integer
                                      nullable: true
                                      description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                    sku:
                                      type: string
                                      nullable: true
                                    name:
                                      type: string
                                      nullable: true
                                    weight:
                                      nullable: true
                                      description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                    dimensions:
                                      nullable: true
                                      description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                    quantity:
                                      type: number
                                      description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                    unit_price:
                                      type: number
                                      description: Unit price. Always `0` on synthetic component rows.
                                    lot_id:
                                      type: integer
                                      nullable: true
                                    lot_number:
                                      type: string
                                      nullable: true
                                    expiry_date:
                                      type: string
                                      nullable: true
                                      description: Lot expiry date.
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    is_kit_component:
                                      type: boolean
                                      description: True when the row is a component of a kit (stored or synthetic).
                                    parent_fulfillment_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                    kit_sales_order_item_id:
                                      type: integer
                                      nullable: true
                                      description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                    is_synthetic:
                                      type: boolean
                                      description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                              total_weight:
                                type: object
                                nullable: true
                                description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                                properties:
                                  total_oz:
                                    type: number
                                    format: float
                                    description: Total weight in ounces
                                  total_lb:
                                    type: number
                                    format: float
                                    description: Total weight in pounds
                                  line_count:
                                    type: integer
                                    description: Number of fulfillment order lines
                                  weighed_line_count:
                                    type: integer
                                    description: Number of lines that had a usable weight and contributed to the total
                                  is_complete:
                                    type: boolean
                                    description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                              tags:
                                type: array
                                description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the tag
                                    name:
                                      type: string
                                      description: Name of the tag
                                    description:
                                      type: string
                                      nullable: true
                                      description: Description of the tag
                                    icon:
                                      type: string
                                      nullable: true
                                      description: Icon identifier or URL for the tag
                                    color:
                                      type: string
                                      nullable: true
                                      description: Color code for the tag
                                  required:
                                    - id
                                    - name
                              purchase_orders:
                                type: array
                                description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                    order_status:
                                      type: string
                                      nullable: true
                                      enum:
                                        - active
                                        - deleted
                                        - completed
                              source_reference_identifier:
                                type: string
                                nullable: true
                                description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                              held_for_item_change:
                                type: boolean
                                description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                              created_at:
                                type: string
                                format: date-time
                                description: When the fulfillment order was created
                              updated_at:
                                type: string
                                format: date-time
                                description: When the fulfillment order was last updated
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                        description: The current page number
                        example: 1
                      from:
                        type: integer
                        description: The starting index of the paginated results
                        example: 1
                      last_page:
                        type: integer
                        description: The last page number
                        example: 5
                      per_page:
                        type: integer
                        description: Number of items per page
                        example: 10
                      to:
                        type: integer
                        description: The ending index of the paginated results
                        example: 10
                      total:
                        type: integer
                        description: Total number of items across all pages
                        example: 50
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
  '/pickflow/picklists/{id}/wip-lots':
    get:
      operationId: getPicklistWipLots
      tags:
        - Picklists
      summary: List lots staged in a picklist's WIP bin
      description: |-
        Between pick-complete and pack, picked units sit in the picklist's WIP (work-in-progress) bin and their lot is recorded only on that bin's stock rows. This endpoint is the read for that bin, so a packer can name the lot it is putting in a package instead of inferring one (CS-10083).

        Behavior:
        - Scoped to the picklist's own WIP bin. Stock in any other bin is not part of
          this tote and is not returned.

        - Bin rows with no remaining on-hand are omitted (a fully packed-out row
          survives at zero in the database and would otherwise offer a lot that has
          already left the tote).

        - Non-lot stock shares the bin and is listed with `lot_id: null`, so the
          payload is the whole tote rather than only its lot-tracked half.

        - A picklist with no WIP bin yet (picking still in progress) returns
          `{"data": []}` with `200`, not an error.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: The picklist ID.
      responses:
        '200':
          description: The lots (and non-lot stock) currently in the picklist's WIP bin.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        picklist_id:
                          type: integer
                          example: 4821
                        location_id:
                          type: integer
                          description: The WIP bin (location) holding the stock.
                          example: 9903
                        rfq_id:
                          type: integer
                          description: Product (RFQ) ID.
                          example: 5512
                        sku:
                          type: string
                          nullable: true
                          example: WIDGET-BLUE
                        lot_tracking:
                          type: boolean
                          description: Whether the product is lot-tracked.
                          example: true
                        lot_id:
                          type: integer
                          nullable: true
                          description: Lot ID; `null` for non-lot stock in the bin.
                          example: 546
                        lot_number:
                          type: string
                          nullable: true
                          example: L-546
                        manufacturer_code:
                          type: string
                          nullable: true
                          example: MC-9
                        production_date:
                          type: string
                          format: date
                          nullable: true
                          example: '2026-01-15'
                        expiry_date:
                          type: string
                          format: date
                          nullable: true
                          example: '2027-01-15'
                        qty_onhand:
                          type: number
                          format: float
                          description: Remaining on-hand for this row in the WIP bin.
                          example: 12
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: Picklist not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/pickflow/picklists/{id}/complete':
    post:
      operationId: completePicklist
      tags:
        - Picklists
      summary: Complete picking for a picklist
      description: |-
        Mark a picklist's lines as picked and move the picked stock into the picklist's WIP bin.

        Each item must name the product (`rfq_id`), the bin the stock is deducted from (`location_id`), and — for a lot-tracked product — the lot (`lot_id`) that was picked (CS-10083). camelCase keys (`picklistItemId`, `rfqId`, `locationId`, `lotId`, `quantityPicked`, `toteBarcode`) are still accepted and normalized.

        **Retries are safe.** A picklist that is already `picked` or `packed` returns `200` with `already_completed: true`, `transfers_completed: 0` and no stock movement — use it to distinguish "my earlier call landed" from "this ran now". A retry is never an error.

        Caller-correctable refusals (wrong lot, wrong bin, short pick, an item from another picklist) answer `422` in the same `{ message, errors }` shape as a validation failure, keyed by field path; every bad line is reported in one response.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: The picklist ID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                      - picklist_item_id
                      - picked_quantity
                      - rfq_id
                      - location_id
                    properties:
                      picklist_item_id:
                        type: integer
                        description: Must belong to this picklist.
                      picked_quantity:
                        type: number
                        description: Must equal the line's available quantity.
                      rfq_id:
                        type: integer
                        description: Product (RFQ) ID; must be the product on that picklist line. The stock transfer cannot infer it.
                      location_id:
                        type: integer
                        description: The bin the stock is deducted from; must be the line's pick location.
                      lot_id:
                        type: integer
                        nullable: true
                        description: Required when the product is lot-tracked; must belong to that product and hold on-hand in `location_id`.
                      tote:
                        type: string
                        maxLength: 255
                        nullable: true
                        description: Optional free-text tote barcode.
      responses:
        '200':
          description: Picklist completed (or already completed on a safe retry).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Picklist completed successfully
                  picklist_id:
                    type: integer
                    example: 4821
                  already_completed:
                    type: boolean
                    description: '`true` when the picklist was already `picked`/`packed` and this call moved no stock.'
                    example: false
                  items_updated:
                    type: integer
                    example: 3
                  transfers_completed:
                    type: integer
                    description: '`0` on an already-completed retry.'
                    example: 3
                  wip_location_id:
                    type: integer
                    nullable: true
                    example: 9903
                  wip_location_name:
                    type: string
                    nullable: true
                    example: WIP-PICKLIST-4821
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: Picklist not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error or a caller-correctable pick refusal (wrong lot, wrong bin, short pick, over-pick, missing `rfq_id`/`location_id`, or an item from another picklist). Keyed by field path — e.g. `items.0.lot_id`, `items.0.location_id`, or `items` for line-level refusals.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/picklists/{id}':
    get:
      operationId: getPicklistById
      tags:
        - Picklists
      summary: Get a picklist
      description: 'Retrieve a single picklist by ID, including its line items. Each item names the lot it is assigned to — `lot_id`, `lot_number`, `production_date` and `expiry_date` are always present, with `null` for non-lot stock (CS-10083). Each `sales_orders[].items[].product` with `type = KIT` also includes its `kit_items` (components with their `product`), so a sales-order picklist exposes the bill of materials behind each kit line (CS-11261).'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: The picklist ID.
      responses:
        '200':
          description: The picklist.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: 'A picklist groups the items to be picked for one or more fulfillment orders or sales orders, and tracks the picking/packing lifecycle.'
                    properties:
                      id:
                        type: integer
                        description: Picklist ID
                        example: 12
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                        example: '2026-09-01T14:20:00.000000Z'
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                        example: '2026-09-01T15:03:11.000000Z'
                      status:
                        type: string
                        description: External picklist status.
                        enum:
                          - created
                          - picking
                          - picked
                          - packed
                          - deleted
                        example: picking
                      picking_started_at:
                        type: string
                        format: date-time
                        nullable: true
                        example: '2026-09-01T14:25:00.000000Z'
                      picking_ended_at:
                        type: string
                        format: date-time
                        nullable: true
                        example: null
                      packing_started_at:
                        type: string
                        format: date-time
                        nullable: true
                        example: null
                      packing_ended_at:
                        type: string
                        format: date-time
                        nullable: true
                        example: null
                      picked_by_user:
                        description: 'User who picked the picklist, or `null` when not recorded.'
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                            nullable: true
                      packed_by_user:
                        description: 'User who packed the picklist, or `null` when not recorded.'
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                            nullable: true
                      shipped_by_user:
                        description: 'User who shipped the picklist, or `null` when not recorded.'
                        type: object
                        nullable: true
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                            nullable: true
                      items:
                        type: array
                        description: The line items on this picklist.
                        items:
                          type: object
                          description: 'A single line on a picklist — the product/RFQ to pick, from where, and how much.'
                          properties:
                            id:
                              type: integer
                              description: Picklist item ID
                              example: 4501
                            picklist_id:
                              type: integer
                              description: ID of the parent picklist
                              example: 12
                            location_id:
                              type: integer
                              nullable: true
                              description: ID of the inventory location the item is picked from
                              example: 88
                            rfq_id:
                              type: integer
                              nullable: true
                              description: ID of the product (RFQ) being picked
                              example: 1023
                            available_quantity:
                              type: number
                              format: float
                              nullable: true
                              description: Quantity available to pick at the location
                              example: 25
                            picked_quantity:
                              type: number
                              format: float
                              nullable: true
                              description: Quantity that has been picked so far
                              example: 10
                            lot_id:
                              type: integer
                              nullable: true
                              description: 'ID of the lot the item is picked from, when lot tracking applies'
                              example: 305
                            lot_number:
                              type: string
                              nullable: true
                              description: Human-readable lot number the item is assigned to — the number printed on the carton. `null` for non-lot stock. Only reflects the eager-loaded lot.
                              example: L-546
                            production_date:
                              type: string
                              format: date
                              nullable: true
                              description: Production date of the assigned lot (`YYYY-MM-DD`). `null` for non-lot stock.
                              example: '2026-01-15'
                            expiry_date:
                              type: string
                              format: date
                              nullable: true
                              description: Expiry date of the assigned lot (`YYYY-MM-DD`). `null` for non-lot stock.
                              example: '2027-01-15'
                            lot_deduction_strategy:
                              type: string
                              nullable: true
                              description: 'Which lot Luminous would pick when a caller omits `lot_id`. `null` means no per-product override (the warehouse group setting, or newest-lot fallback, applies). PickFlow can suggest this to the picker.'
                              example: null
                            uom_id:
                              type: integer
                              nullable: true
                              description: ID of the unit of measure for the picked quantities
                              example: 7
                            uom:
                              description: Unit of measure for the picked quantities. Only present when loaded.
                              nullable: true
                              allOf:
                                - type: object
                                  description: 'A single unit of measure (e.g. "Pound", "Kilogram") belonging to a unit class.'
                                  properties:
                                    id:
                                      type: integer
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                                    status:
                                      type: string
                                      nullable: true
                                    unit_class_id:
                                      type: integer
                                    unit_class:
                                      type: object
                                      description: Present when the relation is loaded.
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        base_class:
                                          type: boolean
                                    name:
                                      type: string
                                    description:
                                      type: string
                                      nullable: true
                                    base_unit:
                                      type: boolean
                                      description: True if this UOM is the base unit for its class.
                                    unit_conversion_rules:
                                      type: array
                                      description: Present when the relation is loaded.
                                      items:
                                        type: object
                                        description: |
                                          A rule converting from one unit of measure to another. `type=SYSTEM` rules apply globally for a class (e.g.
                                          1 lb = 0.453592 kg). `type=SKU` rules override system rules for a specific product (`product_id`).
                                        properties:
                                          id:
                                            type: integer
                                          created_at:
                                            type: string
                                            format: date-time
                                          updated_at:
                                            type: string
                                            format: date-time
                                          status:
                                            type: string
                                            nullable: true
                                          base_unit_of_measure_id:
                                            type: integer
                                          base_unit_of_measure:
                                            type: object
                                            description: Present when the relation is loaded.
                                            nullable: true
                                            properties:
                                              id:
                                                type: integer
                                              name:
                                                type: string
                                              unit_class_id:
                                                type: integer
                                              base_unit:
                                                type: boolean
                                          converted_unit_of_measure_id:
                                            type: integer
                                          converted_unit_of_measure:
                                            type: object
                                            description: Present when the relation is loaded.
                                            nullable: true
                                            properties:
                                              id:
                                                type: integer
                                              name:
                                                type: string
                                              unit_class_id:
                                                type: integer
                                              base_unit:
                                                type: boolean
                                          conversion_factor:
                                            type: number
                                            description: Multiply a quantity in `base_unit_of_measure` by this factor to get the quantity in `converted_unit_of_measure`.
                                          type:
                                            type: string
                                            enum:
                                              - SYSTEM
                                              - SKU
                                          product_id:
                                            type: integer
                                            nullable: true
                                            description: Required when `type=SKU`; null when `type=SYSTEM`.
                                          product:
                                            type: object
                                            nullable: true
                                            description: Present when the relation is loaded. Shape mirrors the standard product resource.
                                            additionalProperties: true
                                          product_alternate_skus:
                                            type: array
                                            description: Present when the relation is loaded.
                                            items:
                                              type: object
                                              additionalProperties: true
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                              example: '2026-09-01T14:22:00.000000Z'
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                              example: '2026-09-01T15:03:11.000000Z'
                            quantity_per_fulfillment_order:
                              type: array
                              description: Breakdown showing how this item's aggregated quantity is distributed across the fulfillment orders on the picklist.
                              items:
                                type: object
                                properties:
                                  fulfillment_order_id:
                                    type: integer
                                    example: 9001
                                  order_key:
                                    type: string
                                    nullable: true
                                    description: 'External order key of the fulfillment order, when available'
                                    example: 114-2938471-0011
                                  quantity:
                                    type: number
                                    format: float
                                    example: 6
                                  sales_items:
                                    type: array
                                    description: The underlying sales items that make up this quantity.
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          example: 77012
                                        sku:
                                          type: string
                                          nullable: true
                                          example: WIDGET-BLUE
                                        name:
                                          type: string
                                          nullable: true
                                          example: Blue Widget
                                        quantity:
                                          type: number
                                          format: float
                                          example: 6
                                        rfq_id:
                                          type: integer
                                          nullable: true
                                          example: 1023
                                        kit_id:
                                          type: integer
                                          nullable: true
                                          description: Set when the sales item is a component of a kit
                                          example: null
                                        order_item_id:
                                          type: string
                                          nullable: true
                                          example: oi_88213
                            location:
                              description: The inventory location the item is picked from. Only present when loaded.
                              nullable: true
                              allOf:
                                - type: object
                                  properties:
                                    id:
                                      type: integer
                                    status:
                                      type: string
                                    name:
                                      type: string
                                    parent_id:
                                      type: integer
                                      nullable: true
                                    created_at:
                                      type: string
                                      format: date-time
                                    updated_at:
                                      type: string
                                      format: date-time
                            product:
                              description: The product (RFQ) being picked. Only present when loaded.
                              nullable: true
                              allOf:
                                - type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the product
                                    name:
                                      type: string
                                      description: Product name
                                    description:
                                      type: string
                                      nullable: true
                                      description: Product description
                                    retail_price:
                                      type: number
                                      format: float
                                      description: Retail price
                                    wholesale_price:
                                      type: number
                                      format: float
                                      description: Wholesale price
                                    unit_cost:
                                      type: number
                                      format: float
                                      description: 'Cost per unit, in the tenant base currency (the weighted inventory cost).'
                                    purchase_unit_cost:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: |
                                        Purchase (FOB) price in the preferred supplier's currency, as stored on the preferred supplier's supplier SKU. Only populated when the product's preferred supplier has a default currency that differs from the tenant base currency and a purchase cost is set; otherwise `null` (the cost lives in `unit_cost`).
                                    purchase_currency:
                                      type: string
                                      nullable: true
                                      description: |
                                        ISO currency code of `purchase_unit_cost` (the preferred supplier's default currency). `null` whenever `purchase_unit_cost` is `null`.
                                    landed_cost:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Landed cost per unit
                                    estimated_landed_cost:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: 'Planner''s estimated landed cost per unit, stored on the product. Separate from the computed `landed_cost`. `null` when unset.'
                                    design_link:
                                      type: string
                                      nullable: true
                                      description: Product design URL or link. `null` when unset or empty.
                                    manufacturing_fee:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Manufacturing fee per unit
                                    product_weight:
                                      type: array
                                      nullable: true
                                      items:
                                        type: object
                                        required:
                                          - unit
                                          - value
                                        properties:
                                          unit:
                                            type: string
                                            enum:
                                              - lb
                                              - oz
                                            description: Weight unit
                                          value:
                                            type: number
                                            format: float
                                            minimum: 0
                                            description: Weight value
                                    product_weight_oz:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total product weight in ounces (computed from product_weight)
                                    product_weight_lb:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total product weight in pounds (computed from product_weight)
                                    dimensional_weight:
                                      type: array
                                      nullable: true
                                      items:
                                        type: object
                                        required:
                                          - unit
                                          - value
                                        properties:
                                          unit:
                                            type: string
                                            enum:
                                              - lb
                                              - oz
                                            description: Weight unit
                                          value:
                                            type: number
                                            format: float
                                            minimum: 0
                                            description: Weight value
                                    dimensional_weight_oz:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total dimensional weight in ounces (computed from dimensional_weight)
                                    dimensional_weight_lb:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total dimensional weight in pounds (computed from dimensional_weight)
                                    product_length:
                                      type: number
                                      format: float
                                      description: Length of the product (in inches)
                                    product_width:
                                      type: number
                                      format: float
                                      description: Width of the product (in inches)
                                    product_height:
                                      type: number
                                      format: float
                                      description: Height of the product (in inches)
                                    box_weight:
                                      type: array
                                      nullable: true
                                      items:
                                        type: object
                                        required:
                                          - unit
                                          - value
                                        properties:
                                          unit:
                                            type: string
                                            enum:
                                              - lb
                                              - oz
                                            description: Weight unit
                                          value:
                                            type: number
                                            format: float
                                            minimum: 0
                                            description: Weight value
                                    box_weight_oz:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total box weight in ounces (computed from box_weight)
                                    box_weight_lb:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total box weight in pounds (computed from box_weight)
                                    box_length:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Length of the box (in inches)
                                    box_width:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Width of the box (in inches)
                                    box_height:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Height of the box (in inches)
                                    carton_weight:
                                      type: array
                                      nullable: true
                                      items:
                                        type: object
                                        required:
                                          - unit
                                          - value
                                        properties:
                                          unit:
                                            type: string
                                            enum:
                                              - lb
                                              - oz
                                            description: Weight unit
                                          value:
                                            type: number
                                            format: float
                                            minimum: 0
                                            description: Weight value
                                    carton_weight_oz:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total carton weight in ounces (computed from carton_weight)
                                    carton_weight_lb:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total carton weight in pounds (computed from carton_weight)
                                    carton_length:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Length of the carton (in inches)
                                    carton_width:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Width of the carton (in inches)
                                    carton_height:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Height of the carton (in inches)
                                    units_per_carton:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Number of units per carton (Shipping & Packing). `null` when not set.
                                    shipping_weight:
                                      type: array
                                      nullable: true
                                      items:
                                        type: object
                                        required:
                                          - unit
                                          - value
                                        properties:
                                          unit:
                                            type: string
                                            enum:
                                              - lb
                                              - oz
                                            description: Weight unit
                                          value:
                                            type: number
                                            format: float
                                            minimum: 0
                                            description: Weight value
                                    shipping_weight_oz:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total shipping weight in ounces (computed from shipping_weight)
                                    shipping_weight_lb:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total shipping weight in pounds (computed from shipping_weight)
                                    shipping_length:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Shipping length (in inches)
                                    shipping_width:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Shipping width (in inches)
                                    shipping_height:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Shipping height (in inches)
                                    pallet_weight:
                                      type: array
                                      nullable: true
                                      items:
                                        type: object
                                        required:
                                          - unit
                                          - value
                                        properties:
                                          unit:
                                            type: string
                                            enum:
                                              - lb
                                              - oz
                                            description: Weight unit
                                          value:
                                            type: number
                                            format: float
                                            minimum: 0
                                            description: Weight value
                                    pallet_weight_oz:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total pallet weight in ounces (computed from pallet_weight)
                                    pallet_weight_lb:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Total pallet weight in pounds (computed from pallet_weight)
                                    pallet_length:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Length of the pallet (in inches)
                                    pallet_width:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Width of the pallet (in inches)
                                    pallet_height:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Height of the pallet (in inches)
                                    cartons_per_pallet:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Number of cartons per pallet (Shipping & Packing). `null` when not set.
                                    units_per_pallet:
                                      type: number
                                      format: float
                                      nullable: true
                                      description: Number of units per pallet (Shipping & Packing). `null` when not set.
                                    default_receiving_location_id:
                                      type: integer
                                      nullable: true
                                      description: Default location (bin) ID for receiving this product. Same name as the create/update field. `null` when not set.
                                    default_assembly_location_id:
                                      type: integer
                                      nullable: true
                                      description: Default location (bin) ID where assembled goods (BOM output) are credited for this product. Same name as the create/update field. `null` when not set.
                                    lead_time_days:
                                      type: integer
                                      nullable: true
                                      description: 'Lead time stored on the product, in calendar days. `null` when not set; `0` is a stored zero, not a missing value. Read-only on the API.'
                                    sellable:
                                      type: boolean
                                      description: Whether the product can be sold
                                    discontinued:
                                      type: boolean
                                      description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                    is_drop_ship_item:
                                      type: boolean
                                      description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                    taxable:
                                      type: boolean
                                      description: Whether the product is subject to sales tax. Defaults to true when not set.
                                    lot_tracking:
                                      type: boolean
                                      description: 'Whether lot (batch) tracking is enabled for this product. When true, on-hand stock is tracked per lot and lot-aware endpoints (e.g. `/lots`, the `lot_stocks` breakdown on inventory stock, and lot fields on adjustments/receiving) apply.'
                                    lot_deduction_strategy:
                                      type: string
                                      nullable: true
                                      description: 'Which lot Luminous picks on its own when a caller omits `lot_id` on a lot-tracked pick or shipment. `null` means there is no per-product override, so the warehouse group''s setting (or a newest-lot fallback) applies. PickFlow should suggest this lot to the picker so its suggestion matches what Luminous would have chosen.'
                                    round_up_as_component:
                                      type: boolean
                                      description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                    default_supply_method:
                                      type: string
                                      nullable: true
                                      enum:
                                        - purchase
                                        - vendor_supplied
                                        - assemble
                                        - on_hand
                                        - assembly_order
                                        - buy_and_ship
                                        - brand_supplied
                                      description: Default supply mode used when planning replenishment for this product
                                    image_url:
                                      type: string
                                      nullable: true
                                      description: URL to the product's main image
                                    images:
                                      type: array
                                      description: |
                                        The product's image gallery, in order. Position 1 is the hero image channels receive first.
                                        Only returned by single-product reads (`GET /products/{id}` and the create/update responses), not
                                        by `GET /products`. `url` and `thumbnail_url` are presigned and expire within two hours, so fetch
                                        them again rather than storing them.
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            description: 'Gallery image ID (use with `DELETE /products/{productId}/images/{imageId}`).'
                                          url:
                                            type: string
                                            description: Presigned URL of the full-size image.
                                          thumbnail_url:
                                            type: string
                                            nullable: true
                                            description: Presigned URL of the thumbnail.
                                          position:
                                            type: integer
                                            description: 1-based position in the gallery.
                                    category:
                                      type: object
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                      description: Product category information
                                    subcategory:
                                      type: object
                                      nullable: true
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                      description: Product subcategory information
                                    custom_fields:
                                      type: object
                                      description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                      additionalProperties:
                                        type: string
                                    attachments:
                                      type: array
                                      description: Product attachments
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            description: Unique identifier for the attachment
                                          name:
                                            type: string
                                            description: Filename of the attachment
                                          type:
                                            type: string
                                            description: MIME type of the attachment
                                          size:
                                            type: integer
                                            description: File size in bytes
                                          full_url:
                                            type: string
                                            description: Full resolution URL of the attachment
                                          thumb_url:
                                            type: string
                                            description: Thumbnail URL of the attachment (if applicable)
                                        required:
                                          - id
                                          - name
                                          - type
                                          - size
                                          - full_url
                                    variants:
                                      type: array
                                      description: Product variants
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                          description:
                                            type: string
                                            nullable: true
                                          product_weight:
                                            type: array
                                            nullable: true
                                            items:
                                              type: object
                                              required:
                                                - unit
                                                - value
                                              properties:
                                                unit:
                                                  type: string
                                                  enum:
                                                    - lb
                                                    - oz
                                                  description: Weight unit
                                                value:
                                                  type: number
                                                  format: float
                                                  minimum: 0
                                                  description: Weight value
                                          product_weight_oz:
                                            type: number
                                            format: float
                                            nullable: true
                                          product_weight_lb:
                                            type: number
                                            format: float
                                            nullable: true
                                          dimensional_weight:
                                            type: array
                                            nullable: true
                                            items:
                                              type: object
                                              required:
                                                - unit
                                                - value
                                              properties:
                                                unit:
                                                  type: string
                                                  enum:
                                                    - lb
                                                    - oz
                                                  description: Weight unit
                                                value:
                                                  type: number
                                                  format: float
                                                  minimum: 0
                                                  description: Weight value
                                          dimensional_weight_oz:
                                            type: number
                                            format: float
                                            nullable: true
                                          dimensional_weight_lb:
                                            type: number
                                            format: float
                                            nullable: true
                                          box_weight:
                                            type: array
                                            nullable: true
                                            items:
                                              type: object
                                              required:
                                                - unit
                                                - value
                                              properties:
                                                unit:
                                                  type: string
                                                  enum:
                                                    - lb
                                                    - oz
                                                  description: Weight unit
                                                value:
                                                  type: number
                                                  format: float
                                                  minimum: 0
                                                  description: Weight value
                                          box_weight_oz:
                                            type: number
                                            format: float
                                            nullable: true
                                          box_weight_lb:
                                            type: number
                                            format: float
                                            nullable: true
                                          carton_weight:
                                            type: array
                                            nullable: true
                                            items:
                                              type: object
                                              required:
                                                - unit
                                                - value
                                              properties:
                                                unit:
                                                  type: string
                                                  enum:
                                                    - lb
                                                    - oz
                                                  description: Weight unit
                                                value:
                                                  type: number
                                                  format: float
                                                  minimum: 0
                                                  description: Weight value
                                          carton_weight_oz:
                                            type: number
                                            format: float
                                            nullable: true
                                          carton_weight_lb:
                                            type: number
                                            format: float
                                            nullable: true
                                          shipping_weight:
                                            type: array
                                            nullable: true
                                            items:
                                              type: object
                                              required:
                                                - unit
                                                - value
                                              properties:
                                                unit:
                                                  type: string
                                                  enum:
                                                    - lb
                                                    - oz
                                                  description: Weight unit
                                                value:
                                                  type: number
                                                  format: float
                                                  minimum: 0
                                                  description: Weight value
                                          shipping_weight_oz:
                                            type: number
                                            format: float
                                            nullable: true
                                          shipping_weight_lb:
                                            type: number
                                            format: float
                                            nullable: true
                                          pallet_weight:
                                            type: array
                                            nullable: true
                                            items:
                                              type: object
                                              required:
                                                - unit
                                                - value
                                              properties:
                                                unit:
                                                  type: string
                                                  enum:
                                                    - lb
                                                    - oz
                                                  description: Weight unit
                                                value:
                                                  type: number
                                                  format: float
                                                  minimum: 0
                                                  description: Weight value
                                          pallet_weight_oz:
                                            type: number
                                            format: float
                                            nullable: true
                                          pallet_weight_lb:
                                            type: number
                                            format: float
                                            nullable: true
                                          attachments:
                                            type: array
                                            description: Variant-specific attachments
                                            items:
                                              type: object
                                              properties:
                                                id:
                                                  type: integer
                                                  description: Unique identifier for the attachment
                                                name:
                                                  type: string
                                                  description: Filename of the attachment
                                                type:
                                                  type: string
                                                  description: MIME type of the attachment
                                                size:
                                                  type: integer
                                                  description: File size in bytes
                                                full_url:
                                                  type: string
                                                  description: Full resolution URL of the attachment
                                                thumb_url:
                                                  type: string
                                                  description: Thumbnail URL of the attachment (if applicable)
                                              required:
                                                - id
                                                - name
                                                - type
                                                - size
                                                - full_url
                                          retail_price:
                                            type: number
                                            format: float
                                          wholesale_price:
                                            type: number
                                            format: float
                                          custom_fields:
                                            type: array
                                            items:
                                              type: object
                                          variant_attributes:
                                            type: array
                                            nullable: true
                                            description: |
                                              The variant option terms this child SKU is assigned to (e.g. Size=Large, Color=Red).
                                              Returned in the same `[{variant_name, variant_terms[]}]` shape as the parent product's
                                              `variant_attributes` taxonomy, with each entry holding the term(s) selected for this child
                                              on that axis.
                                            items:
                                              type: object
                                              properties:
                                                variant_name:
                                                  type: string
                                                  description: Name of the variant axis (e.g. "Size")
                                                variant_terms:
                                                  type: array
                                                  description: Term value(s) selected for this child on that axis
                                                  items:
                                                    type: string
                                          sku:
                                            type: string
                                          upc:
                                            type: string
                                          hs_code:
                                            type: string
                                            nullable: true
                                            description: HS/HTS tariff code for the product (max 50 characters)
                                          round_up_as_component:
                                            type: boolean
                                            description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                          created_at:
                                            type: string
                                            format: date-time
                                          updated_at:
                                            type: string
                                            format: date-time
                                    variant_attributes:
                                      type: array
                                      nullable: true
                                      description: |
                                        Variant option taxonomy for this product — the axes (e.g. Size, Color) and the allowed terms on
                                        each axis. On a parent product, this is the union of all terms used by its child variants. On a
                                        child variant, this holds the specific term(s) the child is assigned to.

                                        Set via the request field `product_variants` (same shape) on create/update.
                                      items:
                                        type: object
                                        properties:
                                          variant_name:
                                            type: string
                                            description: 'Name of the variant axis (e.g. "Size", "Color")'
                                          variant_terms:
                                            type: array
                                            description: Terms on this axis
                                            items:
                                              type: string
                                    sku:
                                      type: string
                                      description: Internal SKU
                                    alternate_skus:
                                      type: array
                                      description: Alternate SKUs
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                          sku:
                                            type: string
                                    upc:
                                      type: string
                                      description: UPC/Barcode
                                    hs_code:
                                      type: string
                                      nullable: true
                                      description: HS/HTS tariff code for the product (max 50 characters)
                                    tags:
                                      type: array
                                      description: Tags associated with the product
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            description: Unique identifier for the tag
                                          name:
                                            type: string
                                            description: Name of the tag
                                          description:
                                            type: string
                                            nullable: true
                                            description: Description of the tag
                                          icon:
                                            type: string
                                            nullable: true
                                            description: Icon identifier or URL for the tag
                                          color:
                                            type: string
                                            nullable: true
                                            description: Color code for the tag
                                        required:
                                          - id
                                          - name
                                    substitutions:
                                      type: array
                                      description: 'Product substitutions, these products may be substituted if the main product is out of stock'
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            description: Substitution record ID
                                          priority:
                                            type: integer
                                            description: Substitution priority (lower number = higher priority)
                                          product:
                                            type: object
                                            description: The substitute product
                                            properties:
                                              id:
                                                type: integer
                                                description: Unique identifier for the product
                                              name:
                                                type: string
                                                description: Product name
                                              description:
                                                type: string
                                                nullable: true
                                                description: Product description
                                              retail_price:
                                                type: number
                                                format: float
                                                description: Retail price
                                              wholesale_price:
                                                type: number
                                                format: float
                                                description: Wholesale price
                                              unit_cost:
                                                type: number
                                                format: float
                                                description: Cost per unit
                                              product_weight:
                                                type: array
                                                nullable: true
                                                items:
                                                  type: object
                                                  required:
                                                    - unit
                                                    - value
                                                  properties:
                                                    unit:
                                                      type: string
                                                      enum:
                                                        - lb
                                                        - oz
                                                      description: Weight unit
                                                    value:
                                                      type: number
                                                      format: float
                                                      minimum: 0
                                                      description: Weight value
                                              product_weight_oz:
                                                type: number
                                                format: float
                                                nullable: true
                                              product_weight_lb:
                                                type: number
                                                format: float
                                                nullable: true
                                              dimensional_weight:
                                                type: array
                                                nullable: true
                                                items:
                                                  type: object
                                                  required:
                                                    - unit
                                                    - value
                                                  properties:
                                                    unit:
                                                      type: string
                                                      enum:
                                                        - lb
                                                        - oz
                                                      description: Weight unit
                                                    value:
                                                      type: number
                                                      format: float
                                                      minimum: 0
                                                      description: Weight value
                                              dimensional_weight_oz:
                                                type: number
                                                format: float
                                                nullable: true
                                              dimensional_weight_lb:
                                                type: number
                                                format: float
                                                nullable: true
                                              product_length:
                                                type: number
                                                format: float
                                                description: Length of the product (in inches)
                                              product_width:
                                                type: number
                                                format: float
                                                description: Width of the product (in inches)
                                              product_height:
                                                type: number
                                                format: float
                                                description: Height of the product (in inches)
                                              box_weight:
                                                type: array
                                                nullable: true
                                                items:
                                                  type: object
                                                  required:
                                                    - unit
                                                    - value
                                                  properties:
                                                    unit:
                                                      type: string
                                                      enum:
                                                        - lb
                                                        - oz
                                                      description: Weight unit
                                                    value:
                                                      type: number
                                                      format: float
                                                      minimum: 0
                                                      description: Weight value
                                              box_weight_oz:
                                                type: number
                                                format: float
                                                nullable: true
                                              box_weight_lb:
                                                type: number
                                                format: float
                                                nullable: true
                                              box_length:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Length of the box (in inches)
                                              box_width:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Width of the box (in inches)
                                              box_height:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Height of the box (in inches)
                                              carton_weight:
                                                type: array
                                                nullable: true
                                                items:
                                                  type: object
                                                  required:
                                                    - unit
                                                    - value
                                                  properties:
                                                    unit:
                                                      type: string
                                                      enum:
                                                        - lb
                                                        - oz
                                                      description: Weight unit
                                                    value:
                                                      type: number
                                                      format: float
                                                      minimum: 0
                                                      description: Weight value
                                              carton_weight_oz:
                                                type: number
                                                format: float
                                                nullable: true
                                              carton_weight_lb:
                                                type: number
                                                format: float
                                                nullable: true
                                              carton_length:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Length of the carton (in inches)
                                              carton_width:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Width of the carton (in inches)
                                              carton_height:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Height of the carton (in inches)
                                              shipping_weight:
                                                type: array
                                                nullable: true
                                                items:
                                                  type: object
                                                  required:
                                                    - unit
                                                    - value
                                                  properties:
                                                    unit:
                                                      type: string
                                                      enum:
                                                        - lb
                                                        - oz
                                                      description: Weight unit
                                                    value:
                                                      type: number
                                                      format: float
                                                      minimum: 0
                                                      description: Weight value
                                              shipping_weight_oz:
                                                type: number
                                                format: float
                                                nullable: true
                                              shipping_weight_lb:
                                                type: number
                                                format: float
                                                nullable: true
                                              shipping_length:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Shipping length (in inches)
                                              shipping_width:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Shipping width (in inches)
                                              shipping_height:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Shipping height (in inches)
                                              pallet_weight:
                                                type: array
                                                nullable: true
                                                items:
                                                  type: object
                                                  required:
                                                    - unit
                                                    - value
                                                  properties:
                                                    unit:
                                                      type: string
                                                      enum:
                                                        - lb
                                                        - oz
                                                      description: Weight unit
                                                    value:
                                                      type: number
                                                      format: float
                                                      minimum: 0
                                                      description: Weight value
                                              pallet_weight_oz:
                                                type: number
                                                format: float
                                                nullable: true
                                              pallet_weight_lb:
                                                type: number
                                                format: float
                                                nullable: true
                                              pallet_length:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Length of the pallet (in inches)
                                              pallet_width:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Width of the pallet (in inches)
                                              pallet_height:
                                                type: number
                                                format: float
                                                nullable: true
                                                description: Height of the pallet (in inches)
                                              sellable:
                                                type: boolean
                                                description: Whether the product can be sold
                                              discontinued:
                                                type: boolean
                                                description: Whether the product is discontinued
                                              is_drop_ship_item:
                                                type: boolean
                                                description: Whether the product is flagged as a drop-ship item. A preference marker only — it does not currently change fulfillment-order routing or purchase-order creation.
                                              taxable:
                                                type: boolean
                                                description: Whether the product is subject to sales tax. Defaults to true when not set.
                                              image_url:
                                                type: string
                                                nullable: true
                                                description: URL to the product's main image
                                              sku:
                                                type: string
                                                description: Internal SKU
                                              upc:
                                                type: string
                                                description: UPC/Barcode
                                              hs_code:
                                                type: string
                                                nullable: true
                                                description: HS/HTS tariff code for the product (max 50 characters)
                                              round_up_as_component:
                                                type: boolean
                                                description: 'Whether this product, when consumed as a BOM component, has its consumption quantity rounded up to whole units. Intended for discrete items (e.g. labels, boxes) that cannot be consumed fractionally.'
                                              created_at:
                                                type: string
                                                format: date-time
                                                description: Timestamp when the product was created
                                              updated_at:
                                                type: string
                                                format: date-time
                                                description: Timestamp when the product was last updated
                                    supplier:
                                      type: object
                                      nullable: true
                                      description: Supplier information
                                    type:
                                      type: string
                                      enum:
                                        - PRODUCT
                                        - KIT
                                      description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                    kit_items:
                                      type: array
                                      nullable: true
                                      description: Kit items (components) for kit products. Only present when type = KIT.
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            description: Unique identifier for the kit item
                                          product_id:
                                            type: integer
                                            description: ID of the product component
                                          quantity:
                                            type: number
                                            format: float
                                            description: Quantity of this component in the kit
                                          uom_id:
                                            type: integer
                                            description: Unit of measure ID for the quantity
                                          base_uom_quantity:
                                            type: number
                                            format: float
                                            description: Quantity converted to base unit of measure
                                          price:
                                            type: number
                                            format: float
                                            description: Price for this kit item
                                          original_price:
                                            type: number
                                            format: float
                                            description: Original price for this kit item
                                          total:
                                            type: number
                                            format: float
                                            description: Calculated total (quantity * price)
                                          product:
                                            type: object
                                            nullable: true
                                            description: Product information for this kit item (when loaded)
                                            properties:
                                              id:
                                                type: integer
                                              name:
                                                type: string
                                              sku:
                                                type: string
                                              description:
                                                type: string
                                                nullable: true
                                              retail_price:
                                                type: number
                                                format: float
                                              wholesale_price:
                                                type: number
                                                format: float
                                          unit_of_measure:
                                            type: object
                                            nullable: true
                                            description: Unit of measure information (when loaded)
                                            properties:
                                              id:
                                                type: integer
                                              name:
                                                type: string
                                              description:
                                                type: string
                                                nullable: true
                                              base_unit:
                                                type: boolean
                                    priority_list:
                                      type: object
                                      nullable: true
                                      description: Fulfillment priority list assigned to this product
                                      properties:
                                        id:
                                          type: integer
                                          description: Priority list ID
                                        name:
                                          type: string
                                          description: Priority list name
                                        description:
                                          type: string
                                          nullable: true
                                          description: Priority list description
                                    distribution_template:
                                      type: object
                                      nullable: true
                                      description: |
                                        The distribution template (size curve) directly assigned to this product.
                                        Returns `null` when no template is assigned (the tenant default applies
                                        when resolving for production-run drafting). Use the dedicated
                                        `PUT /products/{productId}/distribution-template` endpoint to assign one.
                                      properties:
                                        id:
                                          type: integer
                                          description: Distribution template ID
                                        name:
                                          type: string
                                          description: Distribution template name
                                        source:
                                          type: string
                                          enum:
                                            - assigned
                                          description: Always `assigned` — only directly assigned templates are returned here.
                                    distribution_template_category:
                                      type: object
                                      nullable: true
                                      description: |
                                        The size-curve category assigned to this master SKU, used for
                                        category × warehouse resolution of a distribution template when no
                                        template is directly pinned. Returns `null` when no category is assigned.
                                        Use the dedicated `PUT /products/{productId}/distribution-template-category`
                                        endpoint to assign one.
                                      properties:
                                        id:
                                          type: integer
                                          description: Size-curve category ID
                                        name:
                                          type: string
                                          description: Size-curve category name
                                    boms:
                                      type: array
                                      description: BOMs (Bills of Materials) associated with this product
                                      items:
                                        type: object
                                        properties:
                                          id:
                                            type: integer
                                            description: Unique identifier for the BOM
                                          name:
                                            type: string
                                            description: BOM name
                                          items:
                                            type: array
                                            description: 'BOM items (components/products). Returned sorted by each item''s `order` value, then by `id`, so lines appear in the sequence saved on the BOM.'
                                            items:
                                              type: object
                                              properties:
                                                id:
                                                  type: integer
                                                  description: Unique identifier for the BOM item
                                                bom_id:
                                                  type: integer
                                                  description: ID of the BOM this item belongs to
                                                product_id:
                                                  type: integer
                                                  description: ID of the product/component
                                                product:
                                                  type: object
                                                  nullable: true
                                                  description: Product information (when loaded)
                                                  properties:
                                                    id:
                                                      type: integer
                                                    name:
                                                      type: string
                                                    sku:
                                                      type: string
                                                    description:
                                                      type: string
                                                      nullable: true
                                                quantity:
                                                  type: number
                                                  format: float
                                                  description: Quantity required for this item
                                                base_quantity:
                                                  type: number
                                                  format: float
                                                  description: Base quantity (converted to base unit of measure)
                                                note:
                                                  type: string
                                                  nullable: true
                                                  description: Optional note for this item
                                                uom_id:
                                                  type: integer
                                                  nullable: true
                                                  description: Unit of measure ID
                                                unit_of_measure:
                                                  type: object
                                                  nullable: true
                                                  description: Unit of measure information (when loaded)
                                                  properties:
                                                    id:
                                                      type: integer
                                                    name:
                                                      type: string
                                                order:
                                                  type: integer
                                                  nullable: true
                                                  description: Display order for this item
                                                consumption_basis:
                                                  type: string
                                                  enum:
                                                    - planned
                                                    - actual
                                                  description: Determines how much of this component an assembly/work order consumes. `planned` consumes the BOM-defined quantity; `actual` consumes the quantity actually reported during production. Defaults to `planned`.
                                                created_at:
                                                  type: string
                                                  format: date-time
                                                  description: Timestamp when the item was created
                                                updated_at:
                                                  type: string
                                                  format: date-time
                                                  description: Timestamp when the item was last updated
                                              required:
                                                - id
                                                - bom_id
                                                - product_id
                                                - quantity
                                          extra_costs:
                                            type: array
                                            description: Additional costs associated with the BOM
                                            items:
                                              type: object
                                              properties:
                                                id:
                                                  type: integer
                                                  description: Unique identifier for the extra cost
                                                name:
                                                  type: string
                                                  description: Name/description of the extra cost
                                                quantity:
                                                  type: number
                                                  format: float
                                                  description: Quantity for this cost item
                                                unit_price:
                                                  type: number
                                                  format: float
                                                  description: Unit price for this cost item
                                                line_total:
                                                  type: number
                                                  format: float
                                                  description: 'Total cost (quantity × unit_price), calculated automatically on the backend. This field is read-only and should not be provided when creating or updating extra costs.'
                                                created_at:
                                                  type: string
                                                  format: date-time
                                                  description: Timestamp when the extra cost was created
                                                updated_at:
                                                  type: string
                                                  format: date-time
                                                  description: Timestamp when the extra cost was last updated
                                              required:
                                                - id
                                                - name
                                                - quantity
                                                - unit_price
                                                - line_total
                                          created_at:
                                            type: string
                                            format: date-time
                                            description: Timestamp when the BOM was created
                                          updated_at:
                                            type: string
                                            format: date-time
                                            description: Timestamp when the BOM was last updated
                                        required:
                                          - id
                                          - name
                                    created_at:
                                      type: string
                                      format: date-time
                                      description: Timestamp when the product was created
                                    updated_at:
                                      type: string
                                      format: date-time
                                      description: Timestamp when the product was last updated
                                    created_by:
                                      type: integer
                                      description: |
                                        ID of the user who created the product. `0` for products created before
                                        provenance was recorded or by a system path with no attributable user.
                                        Products created through the External API are stamped with the API token's user.
                                    updated_by:
                                      type: integer
                                      description: ID of the user who last updated the product. `0` when never attributed.
                                    created_via:
                                      type: string
                                      nullable: true
                                      enum:
                                        - user
                                        - api
                                        - import
                                        - auto_create_sku
                                        - job
                                        - system
                                      description: |
                                        How the product was created, stamped once at creation and never changed:
                                        `user` (app UI), `api` (External API), `import` (product import/spreadsheet),
                                        `auto_create_sku` (Auto-create SKUs order-processing job), `job` (queued job or
                                        console command), or `system` (other internal write). `null` for products created
                                        before provenance was recorded (unknown source).

                                        Always present on single-product responses. On product **list** endpoints
                                        (`GET /products`, `GET /products/company-pricing`, `GET /companies/{companyId}/products`)
                                        it is only returned when requested with `?include=created_via`.
                      sales_orders:
                        type: array
                        description: Sales orders linked to this picklist. Only present when loaded. A picklist attaches through either sales orders or fulfillment orders.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Unique identifier for the sales order
                            created_at:
                              type: string
                              format: date-time
                              description: Timestamp when the order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: Timestamp when the order was last updated
                            status:
                              type: string
                              description: Current status of the order
                            order_id:
                              type: string
                              description: External order identifier
                            order_number:
                              type: string
                              description: Order number
                            order_date:
                              type: string
                              format: date
                              description: Date when the order was placed
                            payment_date:
                              type: string
                              format: date
                              description: Date when payment was received
                            ship_by_date:
                              type: string
                              format: date
                              description: Required ship by date
                            age:
                              type: integer
                              description: Age of the order in days
                            order_status:
                              type: string
                              description: Status of the order
                            customer_id:
                              type: string
                              description: Customer identifier
                            customer_username:
                              type: string
                              description: Customer's username
                            customer_email:
                              type: string
                              description: Customer's email address
                            bill_to:
                              type: object
                              description: Billing information
                            ship_to:
                              type: object
                              description: Shipping information
                            requested_shipping_service:
                              type: string
                              nullable: true
                              description: What shipping service to use when shipping this order
                            total:
                              type: number
                              format: float
                              description: Total order amount
                            total_paid:
                              type: number
                              format: float
                              description: Amount paid
                            total_tax:
                              type: number
                              format: float
                              description: Total tax amount
                            total_shipping:
                              type: number
                              format: float
                              description: Total shipping amount
                            customer_notes:
                              type: string
                              description: Notes from the customer
                            internal_notes:
                              type: string
                              description: Internal notes
                            ship_date:
                              type: string
                              format: date
                              description: Date when order was shipped
                            hold_until_date:
                              type: string
                              format: date
                              description: Hold until date
                            earliest_ship_date:
                              type: string
                              format: date
                              nullable: true
                              description: Earliest date the order can be shipped
                            user_id:
                              type: integer
                              description: User ID associated with the order
                            externally_fulfilled:
                              type: boolean
                              description: Whether the order is fulfilled externally
                            externally_fulfilled_by:
                              type: string
                              description: Entity fulfilling the order externally
                            is_posted:
                              type: boolean
                              description: Whether the order is posted
                            posted_by:
                              type: string
                              description: User who posted the order
                            not_sync:
                              type: boolean
                              description: Sync status
                            sales_posted:
                              type: boolean
                              description: Sales posting status
                            split_order:
                              type: boolean
                              description: Whether the order is split
                            skip_inventory:
                              type: boolean
                              description: Whether to skip inventory
                            skip_sales_report:
                              type: boolean
                              description: Whether to skip sales report
                            channel_id:
                              type: integer
                              description: Channel identifier
                            total_order_cost:
                              type: number
                              format: float
                              description: Total cost of order
                            total_order_quantity:
                              type: number
                              format: float
                              description: Total quantity of items
                            order_cost_details:
                              type: object
                              description: Detailed order cost information
                            source:
                              type: string
                              description: Order source
                            shipstation_order_id:
                              type: string
                              description: ShipStation order identifier
                            type:
                              type: string
                              description: Order type
                            parent_id:
                              type: integer
                              description: Parent order ID if applicable
                            shipping_revenue:
                              type: number
                              format: float
                              description: Revenue from shipping
                            product_total:
                              type: number
                              format: float
                              description: Total product amount
                            total_discount:
                              type: number
                              format: float
                              description: Total discount amount
                            picking_status:
                              type: string
                              description: Status of picking process
                            starred_description:
                              type: string
                              description: Description for starred orders
                            customer_po_number:
                              type: string
                              description: Customer PO number
                            company_id:
                              type: integer
                              nullable: true
                              description: ID of the company (business account) associated with this sales order. Only present when a company is associated with the order.
                              example: 123
                            company:
                              nullable: true
                              description: Full company (business account) details associated with this sales order. Only present when a company is associated with the order.
                              type: object
                              properties:
                                id:
                                  type: integer
                                  description: Unique identifier for the company
                                  example: 123456
                                created_at:
                                  type: string
                                  format: date-time
                                  description: When the company was created
                                  example: '2023-03-15T14:30:00Z'
                                updated_at:
                                  type: string
                                  format: date-time
                                  description: When the company was last updated
                                  example: '2023-03-15T14:30:00Z'
                                status:
                                  type: string
                                  description: Status of the company
                                  enum:
                                    - active
                                    - inactive
                                  example: active
                                name:
                                  type: string
                                  description: Company name
                                  example: Acme Corporation
                                type:
                                  type: string
                                  nullable: true
                                  description: Type of business
                                  example: Retail
                                phone:
                                  type: string
                                  nullable: true
                                  description: Primary phone number for the company
                                  example: 555-123-4567
                                address:
                                  type: string
                                  nullable: true
                                  description: Street address for the company
                                  example: 123 Main St
                                address_line_2:
                                  type: string
                                  nullable: true
                                  description: Additional address information
                                  example: Suite 500
                                city:
                                  type: string
                                  nullable: true
                                  description: City
                                  example: Austin
                                state:
                                  type: string
                                  nullable: true
                                  description: State/province
                                  example: TX
                                postal_code:
                                  type: string
                                  nullable: true
                                  description: Postal/ZIP code
                                  example: '78701'
                                country:
                                  type: string
                                  nullable: true
                                  description: Country
                                  example: USA
                                full_address:
                                  type: string
                                  nullable: true
                                  description: Complete formatted address
                                  example: '123 Main St, Suite 500, Austin, TX 78701, USA'
                                shipping_first_name:
                                  type: string
                                  nullable: true
                                  description: First name for shipping contact (legacy field)
                                  example: John
                                shipping_last_name:
                                  type: string
                                  nullable: true
                                  description: Last name for shipping contact (legacy field)
                                  example: Doe
                                shipping_email:
                                  type: string
                                  format: email
                                  nullable: true
                                  description: Email for shipping contact (legacy field)
                                  example: shipping@acmecorp.com
                                shipping_phone:
                                  type: string
                                  nullable: true
                                  description: Phone number for shipping contact (legacy field)
                                  example: 555-987-6543
                                shipping_address:
                                  type: string
                                  nullable: true
                                  description: Shipping street address (legacy field)
                                  example: 456 Warehouse Blvd
                                shipping_city:
                                  type: string
                                  nullable: true
                                  description: Shipping city (legacy field)
                                  example: Austin
                                shipping_state:
                                  type: string
                                  nullable: true
                                  description: Shipping state/province (legacy field)
                                  example: TX
                                shipping_postal_code:
                                  type: string
                                  nullable: true
                                  description: Shipping postal/ZIP code (legacy field)
                                  example: '78745'
                                shipping_country:
                                  type: string
                                  nullable: true
                                  description: Shipping country (legacy field)
                                  example: USA
                                shipping_full_address:
                                  type: string
                                  nullable: true
                                  description: Complete formatted shipping address (legacy field)
                                  example: '456 Warehouse Blvd, Austin, TX 78745, USA'
                                payment_term:
                                  type: string
                                  nullable: true
                                  description: Payment terms for the company
                                  example: Net 30
                                tax_exempt:
                                  type: boolean
                                  nullable: true
                                  description: Whether the company is exempt from taxes
                                  example: false
                                tax_rate:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Tax rate applied to the company's orders
                                  example: 8.25
                                due_date_days:
                                  type: integer
                                  nullable: true
                                  description: Number of days until payment is due
                                  example: 30
                                credit_limit:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: Credit limit for the company. `null` means no limit is set.
                                  example: 5000
                                header_discount_enabled:
                                  type: boolean
                                  description: Whether an order-header trade discount is applied by default for this company
                                  example: false
                                header_discount_type:
                                  type: string
                                  nullable: true
                                  enum:
                                    - PERCENT
                                    - FIXED_AMOUNT
                                  description: How the header discount is calculated — a percentage of the order or a fixed amount
                                  example: PERCENT
                                header_discount_value:
                                  type: number
                                  format: float
                                  nullable: true
                                  description: 'The header discount amount — a percentage when `header_discount_type` is `PERCENT`, otherwise a fixed currency amount'
                                  example: 5
                                header_discount_effective_from:
                                  type: string
                                  format: date
                                  nullable: true
                                  description: Date from which the header discount takes effect (YYYY-MM-DD)
                                  example: '2026-01-01'
                                default_currency_code:
                                  type: string
                                  nullable: true
                                  description: Default ISO 4217 currency code for this company. Auto-applied to new orders created for the company.
                                  example: USD
                                price_level:
                                  nullable: true
                                  description: Price level associated with this company
                                  type: object
                                  properties:
                                    id:
                                      type: number
                                      description: Unique identifier for the price level
                                      example: 123
                                    created_at:
                                      type: string
                                      format: date-time
                                      description: When the price level was created
                                      example: '2023-03-15T14:30:00Z'
                                    updated_at:
                                      type: string
                                      format: date-time
                                      description: When the price level was last updated
                                      example: '2023-03-15T14:30:00Z'
                                    status:
                                      type: string
                                      description: Status of the price level
                                      enum:
                                        - active
                                        - inactive
                                      example: active
                                    name:
                                      type: string
                                      description: Name of the price level
                                      example: Wholesale
                                    type:
                                      type: string
                                      description: Type of the price level
                                      example: percentage
                                    percent_increase:
                                      type: number
                                      format: float
                                      description: Percentage increase (or decrease) for this price level
                                      example: 15.5
                                notes:
                                  type: string
                                  nullable: true
                                  description: Additional notes about the company
                                  example: 'Key account, requires special handling'
                                fein:
                                  type: string
                                  nullable: true
                                  description: Federal Employer Identification Number
                                  example: 12-3456789
                                tags:
                                  type: array
                                  nullable: true
                                  description: List of tags associated with the company
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the tag
                                      name:
                                        type: string
                                        description: Name of the tag
                                      description:
                                        type: string
                                        nullable: true
                                        description: Description of the tag
                                      icon:
                                        type: string
                                        nullable: true
                                        description: Icon identifier or URL for the tag
                                      color:
                                        type: string
                                        nullable: true
                                        description: Color code for the tag
                                    required:
                                      - id
                                      - name
                                default_shipping:
                                  nullable: true
                                  description: Default shipping address
                                  type: object
                                  properties:
                                    id:
                                      type: integer
                                      description: Unique identifier for the shipping address
                                      example: 789
                                    created_at:
                                      type: string
                                      format: date-time
                                      description: When the shipping address was created
                                      example: '2023-03-15T14:30:00Z'
                                    updated_at:
                                      type: string
                                      format: date-time
                                      description: When the shipping address was last updated
                                      example: '2023-03-15T14:30:00Z'
                                    company_id:
                                      type: integer
                                      description: ID of the company this shipping address belongs to
                                      example: 123456
                                    company_name:
                                      type: string
                                      nullable: true
                                      description: Name of the company
                                      example: Acme Corporation
                                    address:
                                      type: string
                                      description: Street address
                                      example: 456 Warehouse Blvd
                                    address_line_2:
                                      type: string
                                      nullable: true
                                      description: Additional address information
                                      example: Building 2
                                    city:
                                      type: string
                                      description: City
                                      example: Austin
                                    state:
                                      type: string
                                      description: State/province
                                      example: TX
                                    postal_code:
                                      type: string
                                      description: Postal/ZIP code
                                      example: '78745'
                                    country:
                                      type: string
                                      description: Country
                                      example: USA
                                    full_address:
                                      type: string
                                      description: Complete formatted address
                                      example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                    full_name:
                                      type: string
                                      description: Full name of the contact person
                                      example: John Doe
                                    first_name:
                                      type: string
                                      nullable: true
                                      description: First name of the contact person
                                      example: John
                                    last_name:
                                      type: string
                                      nullable: true
                                      description: Last name of the contact person
                                      example: Doe
                                    phone:
                                      type: string
                                      nullable: true
                                      description: Phone number
                                      example: 555-987-6543
                                    email:
                                      type: string
                                      format: email
                                      nullable: true
                                      description: Email address
                                      example: shipping@acmecorp.com
                                    is_default:
                                      type: boolean
                                      description: Whether this is the default shipping address
                                      example: true
                                  required:
                                    - id
                                    - company_id
                                    - address
                                    - city
                                    - state
                                    - postal_code
                                    - country
                                shipping_addresses:
                                  type: array
                                  nullable: true
                                  description: List of shipping addresses for the company
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the shipping address
                                        example: 789
                                      created_at:
                                        type: string
                                        format: date-time
                                        description: When the shipping address was created
                                        example: '2023-03-15T14:30:00Z'
                                      updated_at:
                                        type: string
                                        format: date-time
                                        description: When the shipping address was last updated
                                        example: '2023-03-15T14:30:00Z'
                                      company_id:
                                        type: integer
                                        description: ID of the company this shipping address belongs to
                                        example: 123456
                                      company_name:
                                        type: string
                                        nullable: true
                                        description: Name of the company
                                        example: Acme Corporation
                                      address:
                                        type: string
                                        description: Street address
                                        example: 456 Warehouse Blvd
                                      address_line_2:
                                        type: string
                                        nullable: true
                                        description: Additional address information
                                        example: Building 2
                                      city:
                                        type: string
                                        description: City
                                        example: Austin
                                      state:
                                        type: string
                                        description: State/province
                                        example: TX
                                      postal_code:
                                        type: string
                                        description: Postal/ZIP code
                                        example: '78745'
                                      country:
                                        type: string
                                        description: Country
                                        example: USA
                                      full_address:
                                        type: string
                                        description: Complete formatted address
                                        example: '456 Warehouse Blvd, Building 2, Austin, TX 78745, USA'
                                      full_name:
                                        type: string
                                        description: Full name of the contact person
                                        example: John Doe
                                      first_name:
                                        type: string
                                        nullable: true
                                        description: First name of the contact person
                                        example: John
                                      last_name:
                                        type: string
                                        nullable: true
                                        description: Last name of the contact person
                                        example: Doe
                                      phone:
                                        type: string
                                        nullable: true
                                        description: Phone number
                                        example: 555-987-6543
                                      email:
                                        type: string
                                        format: email
                                        nullable: true
                                        description: Email address
                                        example: shipping@acmecorp.com
                                      is_default:
                                        type: boolean
                                        description: Whether this is the default shipping address
                                        example: true
                                    required:
                                      - id
                                      - company_id
                                      - address
                                      - city
                                      - state
                                      - postal_code
                                      - country
                                billing_info:
                                  type: object
                                  nullable: true
                                  description: Billing information
                                  properties:
                                    id:
                                      type: integer
                                      example: 456
                                    created_at:
                                      type: string
                                      format: date-time
                                      example: '2023-03-15T14:30:00Z'
                                    updated_at:
                                      type: string
                                      format: date-time
                                      example: '2023-03-15T14:30:00Z'
                                    first_name:
                                      type: string
                                      nullable: true
                                      example: Jane
                                    last_name:
                                      type: string
                                      nullable: true
                                      example: Smith
                                    email:
                                      type: string
                                      format: email
                                      nullable: true
                                      example: accounting@acmecorp.com
                                    receiving_bank_name:
                                      type: string
                                      nullable: true
                                      example: First National Bank
                                    receiving_bank_address:
                                      type: string
                                      nullable: true
                                      example: '789 Finance Street, Austin, TX 78701'
                                client_type:
                                  type: object
                                  nullable: true
                                  description: Type of client
                                  properties:
                                    id:
                                      type: integer
                                      example: 123
                                    created_at:
                                      type: string
                                      format: date-time
                                      example: '2023-03-15T14:30:00Z'
                                    updated_at:
                                      type: string
                                      format: date-time
                                      example: '2023-03-15T14:30:00Z'
                                    name:
                                      type: string
                                      example: Retail
                                    description:
                                      type: string
                                      nullable: true
                                      example: Retail business client
                                parent_company_id:
                                  type: integer
                                  nullable: true
                                  description: ID of the parent company
                                  example: 456
                                invoice_export_template_id:
                                  type: integer
                                  nullable: true
                                  description: ID of the invoice export template
                                  example: 789
                                custom_fields:
                                  type: object
                                  description: 'Custom fields for the company. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                  example:
                                    Industry: Manufacturing
                                    Region: Southwest
                                    Annual Revenue: $5M-$10M
                                assigned_sales_reps:
                                  type: array
                                  description: |
                                    Sales rep users assigned to this company (Go Team members). Resolved from the company's
                                    `goTeamMember.user` relation. Only present when the relation is loaded.
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                        description: User ID of the assigned sales rep
                                        example: 42
                                      email:
                                        type: string
                                        description: Email of the assigned sales rep (PII-hashed when PII filtering is enabled)
                                        example: rep@example.com
                                      first_name:
                                        type: string
                                        nullable: true
                                        example: Jane
                                      last_name:
                                        type: string
                                        nullable: true
                                        example: Doe
                                sales_channel:
                                  allOf:
                                    - type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Sales channel ID.
                                        status:
                                          type: string
                                          description: Sales channel status (e.g. active).
                                        label:
                                          type: string
                                          nullable: true
                                          description: Human-readable channel label.
                                        channel_type:
                                          type: string
                                          nullable: true
                                          description: Channel type (e.g. the integration/platform the channel represents).
                                        created_at:
                                          type: string
                                          format: date-time
                                        updated_at:
                                          type: string
                                          format: date-time
                                  nullable: true
                                  description: The company's default sales channel. Only present when the relation is loaded.
                              required:
                                - id
                                - name
                                - status
                            custom_fields:
                              type: object
                              description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                              additionalProperties:
                                type: string
                            items:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the order item
                                  line_number:
                                    type: integer
                                    description: 'Sequential line number for this item on the sales order, only unique within the order, starts at 1'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: Creation timestamp
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: Last update timestamp
                                  sku:
                                    type: string
                                    description: Stock keeping unit
                                  name:
                                    type: string
                                    description: Product name
                                  image_url:
                                    type: string
                                    description: URL of product image
                                  weight:
                                    type: object
                                    description: Weight information
                                  quantity:
                                    type: number
                                    format: float
                                    description: Ordered quantity
                                  unit_price:
                                    type: number
                                    format: float
                                    description: Price per unit
                                  tax:
                                    type: number
                                    format: float
                                    description: Tax amount
                                  shipping:
                                    type: number
                                    format: float
                                    description: Shipping amount
                                  warehouse_location:
                                    type: string
                                    description: Location in warehouse
                                  options:
                                    type: object
                                    description: Additional options
                                  fulfillment_sku:
                                    type: string
                                    description: SKU used for fulfillment
                                  adjustment:
                                    type: number
                                    format: float
                                    description: Price adjustment
                                  upc:
                                    type: string
                                    description: Universal Product Code
                                  stock_id:
                                    type: integer
                                    description: Stock identifier
                                  kit_id:
                                    type: integer
                                    description: Kit identifier if part of a kit
                                  non_physical_item:
                                    type: boolean
                                    description: Whether item is non-physical
                                  ignore_item:
                                    type: boolean
                                    description: Whether to ignore this item
                                  is_locally_added:
                                    type: boolean
                                    description: True when the line was added in Luminous to a channel-sourced order and exists only in Luminous (it is not part of the order in the source channel and is never pushed back to it). False for lines that came from the channel or were created with the order.
                                  quantity_shipped:
                                    type: number
                                    format: float
                                    description: Quantity shipped
                                  quantity_cancelled:
                                    type: number
                                    format: float
                                    description: Quantity cancelled
                                  quantity_invoiced:
                                    type: number
                                    format: float
                                    description: Quantity invoiced
                                  quantity_ordered:
                                    type: number
                                    format: float
                                    description: 'Quantity ordered, expressed in the product''s base unit of measure. When the line was ordered in a non-base unit (see `ordered_uom_id`), this is the converted base-unit equivalent, not the originally submitted quantity.'
                                  base_uom_id:
                                    type: integer
                                    description: ID of the product's base unit of measure — the unit `quantity_ordered` is expressed in.
                                  ordered_uom_id:
                                    type: integer
                                    description: ID of the unit of measure the line was ordered in (the `uom_id` submitted on create). May differ from `base_uom_id` when ordering in a non-base unit.
                                  product_id:
                                    type: integer
                                    description: Product identifier
                                  total_returned_base_quantity:
                                    type: number
                                    format: float
                                    description: Total quantity returned
                                  parent_id:
                                    type: integer
                                    description: Parent item ID
                                  status:
                                    type: string
                                    description: Item status
                                  discount:
                                    type: number
                                    format: float
                                    description: Discount amount
                                  estimated_ship_date:
                                    type: string
                                    format: date
                                    description: Estimated shipping date
                                  custom_fields:
                                    type: object
                                    description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                    additionalProperties:
                                      type: string
                                  product:
                                    type: object
                                    description: Product information
                                    properties:
                                      id:
                                        type: integer
                                        description: Unique identifier for the product
                                      name:
                                        type: string
                                        description: Product name
                                      description:
                                        type: string
                                        nullable: true
                                        description: Product description
                                      retail_price:
                                        type: number
                                        format: float
                                        description: Retail price
                                      wholesale_price:
                                        type: number
                                        format: float
                                        description: Wholesale price
                                      unit_cost:
                                        type: number
                                        format: float
                                        description: Cost per unit
                                      product_weight:
                                        type: number
                                        format: float
                                        description: Weight of the product
                                      product_length:
                                        type: number
                                        format: float
                                        description: Length of the product (in inches)
                                      product_width:
                                        type: number
                                        format: float
                                        description: Width of the product (in inches)
                                      product_height:
                                        type: number
                                        format: float
                                        description: Height of the product (in inches)
                                      sellable:
                                        type: boolean
                                        description: Whether the product can be sold
                                      discontinued:
                                        type: boolean
                                        description: Whether the product is discontinued. Discontinued products will be hidden in the Luminous UI by default.
                                      image_url:
                                        type: string
                                        nullable: true
                                        description: URL to the product's main image
                                      category:
                                        type: object
                                        nullable: true
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                        description: Product category information
                                      subcategory:
                                        type: object
                                        nullable: true
                                        properties:
                                          id:
                                            type: integer
                                          name:
                                            type: string
                                        description: Product subcategory information
                                      custom_fields:
                                        type: object
                                        description: 'Dynamic custom fields with key-value pairs. Number-type custom fields come back as numbers (the stored numeric value, or stored numeric text converted to a number); a number field holding non-numeric text returns `null`.'
                                        additionalProperties:
                                          type: string
                                      variant_attributes:
                                        type: object
                                        nullable: true
                                        description: Available variant attributes
                                      sku:
                                        type: string
                                        description: Internal SKU
                                      alternate_skus:
                                        type: array
                                        description: Alternate SKUs
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                            sku:
                                              type: string
                                      upc:
                                        type: string
                                        description: UPC/Barcode
                                      tags:
                                        type: array
                                        description: Tags associated with the product
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                              description: Unique identifier for the tag
                                            name:
                                              type: string
                                              description: Name of the tag
                                            description:
                                              type: string
                                              nullable: true
                                              description: Description of the tag
                                            icon:
                                              type: string
                                              nullable: true
                                              description: Icon identifier or URL for the tag
                                            color:
                                              type: string
                                              nullable: true
                                              description: Color code for the tag
                                          required:
                                            - id
                                            - name
                                      supplier:
                                        type: object
                                        nullable: true
                                        description: Supplier information
                                      type:
                                        type: string
                                        enum:
                                          - PRODUCT
                                          - KIT
                                        description: 'Product type. PRODUCT for regular products, KIT for kit products that contain other products as components.'
                                      kit_items:
                                        type: array
                                        nullable: true
                                        description: 'Kit components for KIT products. Only present when the bill of materials is loaded, which today is on `GET /pickflow/picklists` (full view) and `GET /pickflow/picklists/{id}`, where a sales-order picklist has no fulfillment-order breakdown and the picking app expands each kit line into its components (CS-11261). Absent on other sales-order responses.'
                                        items:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                              description: Unique identifier for the kit item
                                            product_id:
                                              type: integer
                                              description: ID of the product component
                                            quantity:
                                              type: number
                                              format: float
                                              description: Quantity of this component in the kit
                                            uom_id:
                                              type: integer
                                              description: Unit of measure ID for the quantity
                                            base_uom_quantity:
                                              type: number
                                              format: float
                                              description: Quantity converted to base unit of measure
                                            price:
                                              type: number
                                              format: float
                                              description: Price for this kit item
                                            original_price:
                                              type: number
                                              format: float
                                              description: Original price for this kit item
                                            total:
                                              type: number
                                              format: float
                                              description: Calculated total (quantity * price)
                                            product:
                                              type: object
                                              nullable: true
                                              description: Product information for this kit item (when loaded)
                                              properties:
                                                id:
                                                  type: integer
                                                name:
                                                  type: string
                                                sku:
                                                  type: string
                                                description:
                                                  type: string
                                                  nullable: true
                                                retail_price:
                                                  type: number
                                                  format: float
                                                wholesale_price:
                                                  type: number
                                                  format: float
                                            unit_of_measure:
                                              type: object
                                              nullable: true
                                              description: Unit of measure information (when loaded)
                                              properties:
                                                id:
                                                  type: integer
                                                name:
                                                  type: string
                                                description:
                                                  type: string
                                                  nullable: true
                                                base_unit:
                                                  type: boolean
                                      created_at:
                                        type: string
                                        format: date-time
                                        description: Timestamp when the product was created
                                      updated_at:
                                        type: string
                                        format: date-time
                                        description: Timestamp when the product was last updated
                                  tags:
                                    type: array
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        description:
                                          type: string
                                        icon:
                                          type: string
                                        color:
                                          type: string
                                        discount_structure:
                                          type: object
                                        markup_structure:
                                          type: object
                                    description: Tags associated with the sales order item
                              description: Line items in the order
                            fulfillment_orders:
                              type: array
                              description: 'Fulfillment orders created from this sales order, in the same shape as GET /fulfillment-orders (including `fulfillment_order_items` with kit component rows). Present when the relation is loaded.'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Fulfillment order ID
                                  order_number:
                                    type: string
                                    description: Fulfillment order number
                                  order_key:
                                    type: string
                                    nullable: true
                                    description: Fulfillment order key
                                  order_status:
                                    type: string
                                    description: Fulfillment order status
                                  sales_order_id:
                                    type: integer
                                    description: Associated sales order ID
                                  warehouse_group_id:
                                    type: integer
                                    nullable: true
                                    description: Warehouse group ID
                                  destination_oms_id:
                                    type: integer
                                    nullable: true
                                    description: Destination app integration account ID
                                  destination_oms_store_id:
                                    type: integer
                                    nullable: true
                                  fulfillment_channel_id:
                                    type: integer
                                    nullable: true
                                  pushed_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                  packing_slip_printed_at:
                                    type: string
                                    format: date-time
                                    nullable: true
                                    description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                                  error_message:
                                    type: string
                                    nullable: true
                                    description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                                  ship_by_date:
                                    type: string
                                    format: date
                                    nullable: true
                                    description: Ship by date
                                  total:
                                    type: number
                                    format: float
                                    nullable: true
                                    description: Order total
                                  bill_to:
                                    type: object
                                    nullable: true
                                    description: Billing address
                                    properties:
                                      name:
                                        type: string
                                      company:
                                        type: string
                                      street1:
                                        type: string
                                      street2:
                                        type: string
                                      street3:
                                        type: string
                                      city:
                                        type: string
                                      state:
                                        type: string
                                      postal_code:
                                        type: string
                                      country:
                                        type: string
                                      phone:
                                        type: string
                                  ship_to:
                                    type: object
                                    nullable: true
                                    description: Shipping address
                                    properties:
                                      name:
                                        type: string
                                      company:
                                        type: string
                                      street1:
                                        type: string
                                      street2:
                                        type: string
                                      street3:
                                        type: string
                                      city:
                                        type: string
                                      state:
                                        type: string
                                      postal_code:
                                        type: string
                                      country:
                                        type: string
                                      phone:
                                        type: string
                                  invoice_to:
                                    type: object
                                    nullable: true
                                    description: Invoice address
                                    properties:
                                      name:
                                        type: string
                                      company:
                                        type: string
                                      street1:
                                        type: string
                                      street2:
                                        type: string
                                      street3:
                                        type: string
                                      city:
                                        type: string
                                      state:
                                        type: string
                                      postal_code:
                                        type: string
                                      country:
                                        type: string
                                      phone:
                                        type: string
                                  sales_order:
                                    type: object
                                    nullable: true
                                    description: Nested sales order data
                                  picklists:
                                    type: array
                                    description: Associated picklists
                                    items:
                                      type: object
                                  fulfillment_order_items:
                                    type: array
                                    description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          nullable: true
                                          description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                        shipment_id:
                                          type: integer
                                          nullable: true
                                          description: ID of the fulfillment order this line belongs to.
                                        status:
                                          nullable: true
                                          description: Line status.
                                        sales_order_item_id:
                                          type: integer
                                          nullable: true
                                          description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                        product_id:
                                          type: integer
                                          nullable: true
                                          description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                        sku:
                                          type: string
                                          nullable: true
                                        name:
                                          type: string
                                          nullable: true
                                        weight:
                                          nullable: true
                                          description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                        dimensions:
                                          nullable: true
                                          description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                        quantity:
                                          type: number
                                          description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                        unit_price:
                                          type: number
                                          description: Unit price. Always `0` on synthetic component rows.
                                        lot_id:
                                          type: integer
                                          nullable: true
                                        lot_number:
                                          type: string
                                          nullable: true
                                        expiry_date:
                                          type: string
                                          nullable: true
                                          description: Lot expiry date.
                                        created_at:
                                          type: string
                                          format: date-time
                                        updated_at:
                                          type: string
                                          format: date-time
                                        is_kit_component:
                                          type: boolean
                                          description: True when the row is a component of a kit (stored or synthetic).
                                        parent_fulfillment_order_item_id:
                                          type: integer
                                          nullable: true
                                          description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                        kit_sales_order_item_id:
                                          type: integer
                                          nullable: true
                                          description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                        is_synthetic:
                                          type: boolean
                                          description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                                  total_weight:
                                    type: object
                                    nullable: true
                                    description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                                    properties:
                                      total_oz:
                                        type: number
                                        format: float
                                        description: Total weight in ounces
                                      total_lb:
                                        type: number
                                        format: float
                                        description: Total weight in pounds
                                      line_count:
                                        type: integer
                                        description: Number of fulfillment order lines
                                      weighed_line_count:
                                        type: integer
                                        description: Number of lines that had a usable weight and contributed to the total
                                      is_complete:
                                        type: boolean
                                        description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                                  tags:
                                    type: array
                                    description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                          description: Unique identifier for the tag
                                        name:
                                          type: string
                                          description: Name of the tag
                                        description:
                                          type: string
                                          nullable: true
                                          description: Description of the tag
                                        icon:
                                          type: string
                                          nullable: true
                                          description: Icon identifier or URL for the tag
                                        color:
                                          type: string
                                          nullable: true
                                          description: Color code for the tag
                                      required:
                                        - id
                                        - name
                                  purchase_orders:
                                    type: array
                                    description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                                    items:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                        order_status:
                                          type: string
                                          nullable: true
                                          enum:
                                            - active
                                            - deleted
                                            - completed
                                  source_reference_identifier:
                                    type: string
                                    nullable: true
                                    description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                                  held_for_item_change:
                                    type: boolean
                                    description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                                  created_at:
                                    type: string
                                    format: date-time
                                    description: When the fulfillment order was created
                                  updated_at:
                                    type: string
                                    format: date-time
                                    description: When the fulfillment order was last updated
                            tags:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  description:
                                    type: string
                                  icon:
                                    type: string
                                  color:
                                    type: string
                                  discount_structure:
                                    type: object
                                  markup_structure:
                                    type: object
                              description: Tags associated with the order
                      fulfillment_orders:
                        type: array
                        description: Fulfillment orders linked to this picklist. Only present when loaded. A picklist attaches through either fulfillment orders or sales orders.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                              description: Fulfillment order ID
                            order_number:
                              type: string
                              description: Fulfillment order number
                            order_key:
                              type: string
                              nullable: true
                              description: Fulfillment order key
                            order_status:
                              type: string
                              description: Fulfillment order status
                            sales_order_id:
                              type: integer
                              description: Associated sales order ID
                            warehouse_group_id:
                              type: integer
                              nullable: true
                              description: Warehouse group ID
                            destination_oms_id:
                              type: integer
                              nullable: true
                              description: Destination app integration account ID
                            destination_oms_store_id:
                              type: integer
                              nullable: true
                            fulfillment_channel_id:
                              type: integer
                              nullable: true
                            pushed_at:
                              type: string
                              format: date-time
                              nullable: true
                            packing_slip_printed_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: When a packing slip for this fulfillment order was last successfully exported or sent to a print station (ISO-8601). `null` when the slip has not been printed.
                            error_message:
                              type: string
                              nullable: true
                              description: 'Last push error from the destination OMS, when the fulfillment order is in Error status'
                            ship_by_date:
                              type: string
                              format: date
                              nullable: true
                              description: Ship by date
                            total:
                              type: number
                              format: float
                              nullable: true
                              description: Order total
                            bill_to:
                              type: object
                              nullable: true
                              description: Billing address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            ship_to:
                              type: object
                              nullable: true
                              description: Shipping address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            invoice_to:
                              type: object
                              nullable: true
                              description: Invoice address
                              properties:
                                name:
                                  type: string
                                company:
                                  type: string
                                street1:
                                  type: string
                                street2:
                                  type: string
                                street3:
                                  type: string
                                city:
                                  type: string
                                state:
                                  type: string
                                postal_code:
                                  type: string
                                country:
                                  type: string
                                phone:
                                  type: string
                            sales_order:
                              type: object
                              nullable: true
                              description: Nested sales order data
                            picklists:
                              type: array
                              description: Associated picklists
                              items:
                                type: object
                            fulfillment_order_items:
                              type: array
                              description: 'Fulfillment order line items. Kit SKUs are broken out into their components: when the channel already expanded a kit into component lines at creation, those stored lines are returned with `is_kit_component: true`. When the fulfillment order stores a single kit line, that kit line is returned and is followed by read-only component rows built from the kit''s bill of materials (`is_synthetic: true`, `id: null`, `unit_price: 0`, `parent_fulfillment_order_item_id` pointing at the kit line).'
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    nullable: true
                                    description: Fulfillment order line ID. `null` for synthetic kit component rows.
                                  shipment_id:
                                    type: integer
                                    nullable: true
                                    description: ID of the fulfillment order this line belongs to.
                                  status:
                                    nullable: true
                                    description: Line status.
                                  sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'Sales order line this fulfillment line fulfills. On synthetic component rows, the kit''s sales order line.'
                                  product_id:
                                    type: integer
                                    nullable: true
                                    description: Luminous product ID. For a kit line this is the kit product; for a component row it is the component product.
                                  sku:
                                    type: string
                                    nullable: true
                                  name:
                                    type: string
                                    nullable: true
                                  weight:
                                    nullable: true
                                    description: Stored line weight (decoded JSON). Always `null` on synthetic component rows.
                                  dimensions:
                                    nullable: true
                                    description: Stored line dimensions (decoded JSON). Always `null` on synthetic component rows.
                                  quantity:
                                    type: number
                                    description: 'Quantity in selling units. For a synthetic component row, the kit line quantity multiplied by the component quantity per kit.'
                                  unit_price:
                                    type: number
                                    description: Unit price. Always `0` on synthetic component rows.
                                  lot_id:
                                    type: integer
                                    nullable: true
                                  lot_number:
                                    type: string
                                    nullable: true
                                  expiry_date:
                                    type: string
                                    nullable: true
                                    description: Lot expiry date.
                                  created_at:
                                    type: string
                                    format: date-time
                                  updated_at:
                                    type: string
                                    format: date-time
                                  is_kit_component:
                                    type: boolean
                                    description: True when the row is a component of a kit (stored or synthetic).
                                  parent_fulfillment_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On synthetic component rows, the ID of the kit line they were expanded from. Otherwise `null`.'
                                  kit_sales_order_item_id:
                                    type: integer
                                    nullable: true
                                    description: 'On kit component rows, the ID of the kit''s sales order line. Otherwise `null`.'
                                  is_synthetic:
                                    type: boolean
                                    description: True for read-only component rows built from the kit bill of materials at read time. They have no fulfillment order line ID and cannot be updated.
                            total_weight:
                              type: object
                              nullable: true
                              description: 'Total product weight of this fulfillment order''s own lines, at the fulfillment quantity. Present only when the line items are loaded. A product with no recorded weight contributes nothing, so a total of `0` usually means "weight unknown" rather than "weightless" — check `is_complete` before treating the total as authoritative.'
                              properties:
                                total_oz:
                                  type: number
                                  format: float
                                  description: Total weight in ounces
                                total_lb:
                                  type: number
                                  format: float
                                  description: Total weight in pounds
                                line_count:
                                  type: integer
                                  description: Number of fulfillment order lines
                                weighed_line_count:
                                  type: integer
                                  description: Number of lines that had a usable weight and contributed to the total
                                is_complete:
                                  type: boolean
                                  description: 'True only when there is at least one line and every line contributed a weight. When false, the total omits one or more lines whose product has no recorded weight.'
                            tags:
                              type: array
                              description: Tags attached directly to this fulfillment order. Present when the relation is loaded. Tags inherited from the parent sales order are not included.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                    description: Unique identifier for the tag
                                  name:
                                    type: string
                                    description: Name of the tag
                                  description:
                                    type: string
                                    nullable: true
                                    description: Description of the tag
                                  icon:
                                    type: string
                                    nullable: true
                                    description: Icon identifier or URL for the tag
                                  color:
                                    type: string
                                    nullable: true
                                    description: Color code for the tag
                                required:
                                  - id
                                  - name
                            purchase_orders:
                              type: array
                              description: Linked purchase orders. Present when the relation is loaded; deduplicated by ID.
                              items:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  order_status:
                                    type: string
                                    nullable: true
                                    enum:
                                      - active
                                      - deleted
                                      - completed
                            source_reference_identifier:
                              type: string
                              nullable: true
                              description: The source system's reference identifier for this fulfillment order (e.g. the originating OMS order ID)
                            held_for_item_change:
                              type: boolean
                              description: 'True when the fulfillment order is on hold because its sales order''s items changed after it was started and nobody has reviewed the change in Luminous yet. Always false once the fulfillment order is shipped, partially shipped or cancelled.'
                            created_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was created
                            updated_at:
                              type: string
                              format: date-time
                              description: When the fulfillment order was last updated
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: Picklist not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /cycle-counts:
    post:
      operationId: createCycleCountBatch
      tags:
        - Cycle Counts
      summary: Create a cycle count batch
      description: |-
        Creates a cycle count batch, which fans out into one session per warehouse in scope. This is a flat top-level alias of `POST /pickflow/cycle-counts` for out-of-UI callers — it targets the same create-batch action, accepts the same request body, and returns the same response. Prefer this path when you are not driving the pickflow mobile-app surface.

        **Scope Type A (`location`, default):** `warehouse_ids` is required; `location_ids` is optional and requires `count_mode: bin_location`.

        **Scope Type B (`item`):** supply `product_ids` or `lot_ids` instead; `warehouse_ids` is an optional narrowing filter (omit it to count every warehouse where the selection has stock). Requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag — a tenant without it gets a `403`, exactly as their UI would hide the option. Supplying both `product_ids` and `lot_ids` for an item-scope count is rejected with a `422`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |-
                Request body for creating a cycle count batch.
                **Scope Type A (`location`, the default):** `warehouse_ids` is required. Optionally narrow to specific bins with `location_ids` (which requires `count_mode: bin_location`).
                **Scope Type B (`item`, requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag):** supply `product_ids` or `lot_ids` instead. `warehouse_ids` becomes an optional narrowing filter — omit it to count every warehouse where the selection has stock.
              properties:
                name:
                  type: string
                  nullable: true
                scope_type:
                  type: string
                  enum:
                    - location
                    - item
                  default: location
                warehouse_ids:
                  type: array
                  items:
                    type: integer
                  description: Required unless `scope_type=item` (then an optional narrowing filter).
                location_ids:
                  type: array
                  items:
                    type: integer
                  description: 'Requires `count_mode: bin_location`.'
                product_ids:
                  type: array
                  items:
                    type: integer
                  description: Scope Type B "Products" sub-mode.
                lot_ids:
                  type: array
                  items:
                    type: integer
                  description: Scope Type B "Lots" sub-mode.
                category_ids:
                  type: array
                  items:
                    type: integer
                sub_category_id:
                  type: integer
                  nullable: true
                preferred_vendor_ids:
                  type: array
                  items:
                    type: integer
                count_mode:
                  type: string
                  enum:
                    - sku
                    - bin_location
                  default: sku
                is_blind_count:
                  type: boolean
                  default: false
                  description: 'When `true`, counters do not see expected quantities. If the tenant setting "Require blind cycle counts" is enabled, every new batch is created blind regardless of this value (a `false` value is overridden, not rejected).'
                include_discontinued:
                  type: boolean
                  default: false
                include_archived:
                  type: boolean
                  default: false
                include_inactive:
                  type: boolean
                  default: false
                include_zero_qty:
                  type: boolean
                  default: false
                remarks:
                  type: string
                  nullable: true
            examples:
              locationScope:
                summary: Scope Type A — whole warehouse
                value:
                  name: Q3 Warehouse 4 count
                  warehouse_ids:
                    - 4
                  is_blind_count: true
              itemScope:
                summary: 'Scope Type B — specific products, any warehouse with stock'
                value:
                  scope_type: item
                  product_ids:
                    - 101
                    - 203
      responses:
        '201':
          description: 'Created. Returns the batch with its per-warehouse sessions, including the resolved `products`/`lots` names for an item-scope count. May include a non-blocking `warning` when some selected products/lots had no stock.'
          content:
            application/json:
              schema:
                type: object
                description: A cycle count batch — the top-level grouping created by `POST /pickflow/cycle-counts`. A batch fans out into one session per warehouse in scope (see `sessions`).
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  name:
                    type: string
                    nullable: true
                  scopeType:
                    type: string
                    enum:
                      - location
                      - item
                    description: '`location` (Scope Type A) counts whole warehouses/bins; `item` (Scope Type B) counts specific products or lots. Item scope requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
                  countMode:
                    type: string
                    enum:
                      - sku
                      - bin_location
                  isBlindCount:
                    type: boolean
                    description: 'When true, counters do not see the expected quantity while counting.'
                  categoryId:
                    type: integer
                    nullable: true
                  subCategoryId:
                    type: integer
                    nullable: true
                  preferredVendorId:
                    type: integer
                    nullable: true
                  productIds:
                    type: array
                    nullable: true
                    items:
                      type: integer
                  lotIds:
                    type: array
                    nullable: true
                    items:
                      type: integer
                  products:
                    type: array
                    nullable: true
                    description: Resolved item-scope product selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        productName:
                          type: string
                        internalSku:
                          type: string
                  lots:
                    type: array
                    nullable: true
                    description: Resolved item-scope lot selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        lotNumber:
                          type: string
                        productName:
                          type: string
                          nullable: true
                        expiryDate:
                          type: string
                          format: date
                          nullable: true
                  remarks:
                    type: string
                    nullable: true
                  createdBy:
                    type: integer
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                  sessions:
                    type: array
                    description: The per-warehouse sessions belonging to this batch.
                    items:
                      type: object
                      description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                      properties:
                        id:
                          type: integer
                        uuid:
                          type: string
                        batchId:
                          type: integer
                        warehouseId:
                          type: integer
                        status:
                          type: string
                          enum:
                            - draft
                            - in_progress
                            - pending_review
                            - posted
                            - cancelled
                        skuCount:
                          type: integer
                          description: Number of distinct SKUs in the session.
                        countedSkuCount:
                          type: integer
                          description: Number of SKUs that have been counted so far.
                        theoreticalValue:
                          type: number
                          description: 'System (book) value of the stock in scope, at post time.'
                        totalVarianceQty:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        totalVarianceValue:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        accuracyPercentage:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        adjustmentId:
                          type: integer
                          nullable: true
                          description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                        startedBy:
                          type: integer
                          nullable: true
                        startedAt:
                          type: string
                          format: date-time
                          nullable: true
                        postedBy:
                          type: integer
                          nullable: true
                        postedAt:
                          type: string
                          format: date-time
                          nullable: true
                        cancelledBy:
                          type: integer
                          nullable: true
                        cancelledAt:
                          type: string
                          format: date-time
                          nullable: true
                        createdAt:
                          type: string
                          format: date-time
                        updatedAt:
                          type: string
                          format: date-time
                  sessionsCount:
                    type: integer
                    description: Total number of sessions in the batch. Present on the batch list/detail endpoints (redundant with `sessions.length` when the full collection is also returned).
                  warning:
                    type: string
                    description: Present only on the create response when `scope_type=item` and some selected products/lots had no stock and were dropped from the count.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /pickflow/cycle-counts:
    get:
      operationId: listPickflowCycleCountSessions
      tags:
        - Cycle Counts
      summary: List active sessions for a warehouse
      description: Lists `draft` and `in_progress` sessions for the given warehouse — the pickflow mobile-app use case. This endpoint pre-dates CS-8871 and returns a legacy session shape (not the `CycleCountSession` resource returned by the lifecycle endpoints).
      security:
        - BearerAuth: []
      parameters:
        - name: warehouse_id
          in: query
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Array of active cycle count sessions (legacy shape).
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
    post:
      operationId: createPickflowCycleCountBatch
      tags:
        - Cycle Counts
      summary: Create a cycle count batch
      description: |-
        Creates a cycle count batch, which fans out into one session per warehouse in scope.

        **Scope Type A (`location`, default):** `warehouse_ids` is required; `location_ids` is optional and requires `count_mode: bin_location`.

        **Scope Type B (`item`):** supply `product_ids` or `lot_ids` instead; `warehouse_ids` is an optional narrowing filter (omit it to count every warehouse where the selection has stock). Requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag — a tenant without it gets a `403`, exactly as their UI would hide the option.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: |-
                Request body for creating a cycle count batch.
                **Scope Type A (`location`, the default):** `warehouse_ids` is required. Optionally narrow to specific bins with `location_ids` (which requires `count_mode: bin_location`).
                **Scope Type B (`item`, requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag):** supply `product_ids` or `lot_ids` instead. `warehouse_ids` becomes an optional narrowing filter — omit it to count every warehouse where the selection has stock.
              properties:
                name:
                  type: string
                  nullable: true
                scope_type:
                  type: string
                  enum:
                    - location
                    - item
                  default: location
                warehouse_ids:
                  type: array
                  items:
                    type: integer
                  description: Required unless `scope_type=item` (then an optional narrowing filter).
                location_ids:
                  type: array
                  items:
                    type: integer
                  description: 'Requires `count_mode: bin_location`.'
                product_ids:
                  type: array
                  items:
                    type: integer
                  description: Scope Type B "Products" sub-mode.
                lot_ids:
                  type: array
                  items:
                    type: integer
                  description: Scope Type B "Lots" sub-mode.
                category_ids:
                  type: array
                  items:
                    type: integer
                sub_category_id:
                  type: integer
                  nullable: true
                preferred_vendor_ids:
                  type: array
                  items:
                    type: integer
                count_mode:
                  type: string
                  enum:
                    - sku
                    - bin_location
                  default: sku
                is_blind_count:
                  type: boolean
                  default: false
                  description: 'When `true`, counters do not see expected quantities. If the tenant setting "Require blind cycle counts" is enabled, every new batch is created blind regardless of this value (a `false` value is overridden, not rejected).'
                include_discontinued:
                  type: boolean
                  default: false
                include_archived:
                  type: boolean
                  default: false
                include_inactive:
                  type: boolean
                  default: false
                include_zero_qty:
                  type: boolean
                  default: false
                remarks:
                  type: string
                  nullable: true
            examples:
              locationScope:
                summary: Scope Type A — whole warehouse
                value:
                  name: Q3 Warehouse 4 count
                  warehouse_ids:
                    - 4
                  is_blind_count: true
              itemScope:
                summary: 'Scope Type B — specific products, any warehouse with stock'
                value:
                  scope_type: item
                  product_ids:
                    - 101
                    - 203
      responses:
        '201':
          description: Created. Returns the batch with its per-warehouse sessions. May include a non-blocking `warning` when some selected products/lots had no stock.
          content:
            application/json:
              schema:
                type: object
                description: A cycle count batch — the top-level grouping created by `POST /pickflow/cycle-counts`. A batch fans out into one session per warehouse in scope (see `sessions`).
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  name:
                    type: string
                    nullable: true
                  scopeType:
                    type: string
                    enum:
                      - location
                      - item
                    description: '`location` (Scope Type A) counts whole warehouses/bins; `item` (Scope Type B) counts specific products or lots. Item scope requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
                  countMode:
                    type: string
                    enum:
                      - sku
                      - bin_location
                  isBlindCount:
                    type: boolean
                    description: 'When true, counters do not see the expected quantity while counting.'
                  categoryId:
                    type: integer
                    nullable: true
                  subCategoryId:
                    type: integer
                    nullable: true
                  preferredVendorId:
                    type: integer
                    nullable: true
                  productIds:
                    type: array
                    nullable: true
                    items:
                      type: integer
                  lotIds:
                    type: array
                    nullable: true
                    items:
                      type: integer
                  products:
                    type: array
                    nullable: true
                    description: Resolved item-scope product selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        productName:
                          type: string
                        internalSku:
                          type: string
                  lots:
                    type: array
                    nullable: true
                    description: Resolved item-scope lot selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        lotNumber:
                          type: string
                        productName:
                          type: string
                          nullable: true
                        expiryDate:
                          type: string
                          format: date
                          nullable: true
                  remarks:
                    type: string
                    nullable: true
                  createdBy:
                    type: integer
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                  sessions:
                    type: array
                    description: The per-warehouse sessions belonging to this batch.
                    items:
                      type: object
                      description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                      properties:
                        id:
                          type: integer
                        uuid:
                          type: string
                        batchId:
                          type: integer
                        warehouseId:
                          type: integer
                        status:
                          type: string
                          enum:
                            - draft
                            - in_progress
                            - pending_review
                            - posted
                            - cancelled
                        skuCount:
                          type: integer
                          description: Number of distinct SKUs in the session.
                        countedSkuCount:
                          type: integer
                          description: Number of SKUs that have been counted so far.
                        theoreticalValue:
                          type: number
                          description: 'System (book) value of the stock in scope, at post time.'
                        totalVarianceQty:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        totalVarianceValue:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        accuracyPercentage:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        adjustmentId:
                          type: integer
                          nullable: true
                          description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                        startedBy:
                          type: integer
                          nullable: true
                        startedAt:
                          type: string
                          format: date-time
                          nullable: true
                        postedBy:
                          type: integer
                          nullable: true
                        postedAt:
                          type: string
                          format: date-time
                          nullable: true
                        cancelledBy:
                          type: integer
                          nullable: true
                        cancelledAt:
                          type: string
                          format: date-time
                          nullable: true
                        createdAt:
                          type: string
                          format: date-time
                        updatedAt:
                          type: string
                          format: date-time
                  sessionsCount:
                    type: integer
                    description: Total number of sessions in the batch. Present on the batch list/detail endpoints (redundant with `sessions.length` when the full collection is also returned).
                  warning:
                    type: string
                    description: Present only on the create response when `scope_type=item` and some selected products/lots had no stock and were dropped from the count.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /pickflow/cycle-counts/sku-estimate:
    get:
      operationId: getPickflowCycleCountSkuEstimate
      tags:
        - Cycle Counts
      summary: SKU-mode item-count estimate per warehouse
      description: 'Preview the item count a create-batch call would produce, before committing. Takes the same selection shape as the create body (minus `name`, `remarks`, and `is_blind_count`). `scope_type=item` requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
      security:
        - BearerAuth: []
      parameters:
        - name: warehouse_ids
          in: query
          schema:
            type: array
            items:
              type: integer
        - name: scope_type
          in: query
          schema:
            type: string
            enum:
              - location
              - item
        - name: product_ids
          in: query
          schema:
            type: array
            items:
              type: integer
        - name: lot_ids
          in: query
          schema:
            type: array
            items:
              type: integer
      responses:
        '200':
          description: '`{ estimate: { [warehouseId]: itemCount } }` for `scope_type=location` (default); `{ totalItemCount, warehouses: [...] }` for `scope_type=item`.'
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  /pickflow/cycle-counts/bin-location-estimate:
    get:
      operationId: getPickflowCycleCountBinLocationEstimate
      tags:
        - Cycle Counts
      summary: Bin-location-mode item-count estimate per warehouse
      description: 'Same as the SKU-mode estimate but for `count_mode: bin_location`; also accepts `location_ids`. Bin-location mode is available to every tenant; only `scope_type=item` requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
      security:
        - BearerAuth: []
      parameters:
        - name: warehouse_ids
          in: query
          schema:
            type: array
            items:
              type: integer
        - name: scope_type
          in: query
          schema:
            type: string
            enum:
              - location
              - item
        - name: product_ids
          in: query
          schema:
            type: array
            items:
              type: integer
        - name: lot_ids
          in: query
          schema:
            type: array
            items:
              type: integer
        - name: location_ids
          in: query
          schema:
            type: array
            items:
              type: integer
      responses:
        '200':
          description: Same response shape as the SKU-mode estimate.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: '`scope_type=item` was requested but the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag is not enabled for this tenant.'
  '/pickflow/cycle-counts/warehouses/{warehouseId}/locations/search':
    get:
      operationId: searchPickflowCycleCountLocations
      tags:
        - Cycle Counts
      summary: Search locations (bins) within a warehouse
      description: Search bins within a warehouse — backs building a Scope Type A payload. Requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.
      security:
        - BearerAuth: []
      parameters:
        - name: warehouseId
          in: path
          required: true
          schema:
            type: integer
        - name: search
          in: query
          schema:
            type: string
        - name: per_page
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: Paginated list of locations.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        locationName:
                          type: string
                        parentId:
                          type: integer
                          nullable: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  /pickflow/cycle-counts/products/search:
    get:
      operationId: searchPickflowCycleCountProducts
      tags:
        - Cycle Counts
      summary: Search products
      description: 'Search products — backs building a Scope Type B "Products" payload. Global, not warehouse-scoped. Requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
      security:
        - BearerAuth: []
      parameters:
        - name: search
          in: query
          schema:
            type: string
        - name: per_page
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: Paginated list of products.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        productName:
                          type: string
                        internalSku:
                          type: string
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  /pickflow/cycle-counts/lots/search:
    get:
      operationId: searchPickflowCycleCountLots
      tags:
        - Cycle Counts
      summary: Search lots
      description: 'Search lots — backs building a Scope Type B "Lots" payload. Global, not warehouse-scoped. Requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
      security:
        - BearerAuth: []
      parameters:
        - name: search
          in: query
          schema:
            type: string
        - name: per_page
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: Paginated list of lots.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        lotNumber:
                          type: string
                        productName:
                          type: string
                          nullable: true
                        expiryDate:
                          type: string
                          format: date
                          nullable: true
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: You do not have permission to perform this action
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Forbidden
                  message:
                    type: string
                    example: You do not have permission to access this resource
                  status_code:
                    type: integer
                    example: 403
  /pickflow/cycle-counts/batches:
    get:
      operationId: listPickflowCycleCountBatches
      tags:
        - Cycle Counts
      summary: List cycle count batches
      description: 'Paginated, filterable batch list — the same dashboard list the internal UI shows, exposed externally. Each batch includes its per-warehouse sessions with summary stats only; items are never embedded here (use the per-session items endpoint).'
      security:
        - BearerAuth: []
      parameters:
        - name: statuses
          in: query
          description: Matches batches with at least one session in any of these statuses.
          schema:
            type: array
            items:
              type: string
              enum:
                - draft
                - in_progress
                - pending_review
                - posted
                - cancelled
        - name: warehouse_id
          in: query
          schema:
            type: integer
        - name: created_at_from
          in: query
          schema:
            type: string
            format: date
        - name: created_at_to
          in: query
          schema:
            type: string
            format: date
        - name: per_page
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: 'Paginated list of batches, each with its per-warehouse sessions.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A cycle count batch — the top-level grouping created by `POST /pickflow/cycle-counts`. A batch fans out into one session per warehouse in scope (see `sessions`).
                      properties:
                        id:
                          type: integer
                        uuid:
                          type: string
                        name:
                          type: string
                          nullable: true
                        scopeType:
                          type: string
                          enum:
                            - location
                            - item
                          description: '`location` (Scope Type A) counts whole warehouses/bins; `item` (Scope Type B) counts specific products or lots. Item scope requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
                        countMode:
                          type: string
                          enum:
                            - sku
                            - bin_location
                        isBlindCount:
                          type: boolean
                          description: 'When true, counters do not see the expected quantity while counting.'
                        categoryId:
                          type: integer
                          nullable: true
                        subCategoryId:
                          type: integer
                          nullable: true
                        preferredVendorId:
                          type: integer
                          nullable: true
                        productIds:
                          type: array
                          nullable: true
                          items:
                            type: integer
                        lotIds:
                          type: array
                          nullable: true
                          items:
                            type: integer
                        products:
                          type: array
                          nullable: true
                          description: Resolved item-scope product selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              productName:
                                type: string
                              internalSku:
                                type: string
                        lots:
                          type: array
                          nullable: true
                          description: Resolved item-scope lot selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              lotNumber:
                                type: string
                              productName:
                                type: string
                                nullable: true
                              expiryDate:
                                type: string
                                format: date
                                nullable: true
                        remarks:
                          type: string
                          nullable: true
                        createdBy:
                          type: integer
                        createdAt:
                          type: string
                          format: date-time
                        updatedAt:
                          type: string
                          format: date-time
                        sessions:
                          type: array
                          description: The per-warehouse sessions belonging to this batch.
                          items:
                            type: object
                            description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                            properties:
                              id:
                                type: integer
                              uuid:
                                type: string
                              batchId:
                                type: integer
                              warehouseId:
                                type: integer
                              status:
                                type: string
                                enum:
                                  - draft
                                  - in_progress
                                  - pending_review
                                  - posted
                                  - cancelled
                              skuCount:
                                type: integer
                                description: Number of distinct SKUs in the session.
                              countedSkuCount:
                                type: integer
                                description: Number of SKUs that have been counted so far.
                              theoreticalValue:
                                type: number
                                description: 'System (book) value of the stock in scope, at post time.'
                              totalVarianceQty:
                                type: number
                                nullable: true
                                description: Populated once the session reaches pending_review.
                              totalVarianceValue:
                                type: number
                                nullable: true
                                description: Populated once the session reaches pending_review.
                              accuracyPercentage:
                                type: number
                                nullable: true
                                description: Populated once the session reaches pending_review.
                              adjustmentId:
                                type: integer
                                nullable: true
                                description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                              startedBy:
                                type: integer
                                nullable: true
                              startedAt:
                                type: string
                                format: date-time
                                nullable: true
                              postedBy:
                                type: integer
                                nullable: true
                              postedAt:
                                type: string
                                format: date-time
                                nullable: true
                              cancelledBy:
                                type: integer
                                nullable: true
                              cancelledAt:
                                type: string
                                format: date-time
                                nullable: true
                              createdAt:
                                type: string
                                format: date-time
                              updatedAt:
                                type: string
                                format: date-time
                        sessionsCount:
                          type: integer
                          description: Total number of sessions in the batch. Present on the batch list/detail endpoints (redundant with `sessions.length` when the full collection is also returned).
                        warning:
                          type: string
                          description: Present only on the create response when `scope_type=item` and some selected products/lots had no stock and were dropped from the count.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
  '/pickflow/cycle-counts/batches/{batchId}':
    get:
      operationId: getPickflowCycleCountBatch
      tags:
        - Cycle Counts
      summary: Get a cycle count batch
      description: Returns a batch with its per-warehouse sessions.
      security:
        - BearerAuth: []
      parameters:
        - name: batchId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The batch with its per-warehouse sessions.
          content:
            application/json:
              schema:
                type: object
                description: A cycle count batch — the top-level grouping created by `POST /pickflow/cycle-counts`. A batch fans out into one session per warehouse in scope (see `sessions`).
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  name:
                    type: string
                    nullable: true
                  scopeType:
                    type: string
                    enum:
                      - location
                      - item
                    description: '`location` (Scope Type A) counts whole warehouses/bins; `item` (Scope Type B) counts specific products or lots. Item scope requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
                  countMode:
                    type: string
                    enum:
                      - sku
                      - bin_location
                  isBlindCount:
                    type: boolean
                    description: 'When true, counters do not see the expected quantity while counting.'
                  categoryId:
                    type: integer
                    nullable: true
                  subCategoryId:
                    type: integer
                    nullable: true
                  preferredVendorId:
                    type: integer
                    nullable: true
                  productIds:
                    type: array
                    nullable: true
                    items:
                      type: integer
                  lotIds:
                    type: array
                    nullable: true
                    items:
                      type: integer
                  products:
                    type: array
                    nullable: true
                    description: Resolved item-scope product selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        productName:
                          type: string
                        internalSku:
                          type: string
                  lots:
                    type: array
                    nullable: true
                    description: Resolved item-scope lot selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        lotNumber:
                          type: string
                        productName:
                          type: string
                          nullable: true
                        expiryDate:
                          type: string
                          format: date
                          nullable: true
                  remarks:
                    type: string
                    nullable: true
                  createdBy:
                    type: integer
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                  sessions:
                    type: array
                    description: The per-warehouse sessions belonging to this batch.
                    items:
                      type: object
                      description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                      properties:
                        id:
                          type: integer
                        uuid:
                          type: string
                        batchId:
                          type: integer
                        warehouseId:
                          type: integer
                        status:
                          type: string
                          enum:
                            - draft
                            - in_progress
                            - pending_review
                            - posted
                            - cancelled
                        skuCount:
                          type: integer
                          description: Number of distinct SKUs in the session.
                        countedSkuCount:
                          type: integer
                          description: Number of SKUs that have been counted so far.
                        theoreticalValue:
                          type: number
                          description: 'System (book) value of the stock in scope, at post time.'
                        totalVarianceQty:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        totalVarianceValue:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        accuracyPercentage:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        adjustmentId:
                          type: integer
                          nullable: true
                          description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                        startedBy:
                          type: integer
                          nullable: true
                        startedAt:
                          type: string
                          format: date-time
                          nullable: true
                        postedBy:
                          type: integer
                          nullable: true
                        postedAt:
                          type: string
                          format: date-time
                          nullable: true
                        cancelledBy:
                          type: integer
                          nullable: true
                        cancelledAt:
                          type: string
                          format: date-time
                          nullable: true
                        createdAt:
                          type: string
                          format: date-time
                        updatedAt:
                          type: string
                          format: date-time
                  sessionsCount:
                    type: integer
                    description: Total number of sessions in the batch. Present on the batch list/detail endpoints (redundant with `sessions.length` when the full collection is also returned).
                  warning:
                    type: string
                    description: Present only on the create response when `scope_type=item` and some selected products/lots had no stock and were dropped from the count.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    delete:
      operationId: deletePickflowCycleCountBatch
      tags:
        - Cycle Counts
      summary: Delete a batch and all its sessions
      description: '**Destructive and irreversible from an external caller''s point of view** — there is no undelete endpoint. Refused (`422`) when any session in the batch is already `posted`. Requires an explicit `{"confirm": true}` body, the same external-only safety gate as `post`. The posted-status check runs against a row-locked read of every session in the batch, so a delete can''t race a concurrent `post` of one of them.'
      security:
        - BearerAuth: []
      parameters:
        - name: batchId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - confirm
              properties:
                confirm:
                  type: boolean
                  enum:
                    - true
                  description: Must be true. Explicit external-only acknowledgment of a destructive delete.
      responses:
        '200':
          description: Deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: 'A session in the batch is already posted, or `confirm` was missing/false.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/batches/{batchId}/start-all':
    post:
      operationId: startAllPickflowCycleCountBatchSessions
      tags:
        - Cycle Counts
      summary: Start every draft session in the batch
      description: Transitions every `draft` session in the batch to `in_progress`.
      security:
        - BearerAuth: []
      parameters:
        - name: batchId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The batch with its sessions now started.
          content:
            application/json:
              schema:
                type: object
                description: A cycle count batch — the top-level grouping created by `POST /pickflow/cycle-counts`. A batch fans out into one session per warehouse in scope (see `sessions`).
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  name:
                    type: string
                    nullable: true
                  scopeType:
                    type: string
                    enum:
                      - location
                      - item
                    description: '`location` (Scope Type A) counts whole warehouses/bins; `item` (Scope Type B) counts specific products or lots. Item scope requires the `CS_8871_CYCLE_COUNT_LOCATION_SCOPE` feature flag.'
                  countMode:
                    type: string
                    enum:
                      - sku
                      - bin_location
                  isBlindCount:
                    type: boolean
                    description: 'When true, counters do not see the expected quantity while counting.'
                  categoryId:
                    type: integer
                    nullable: true
                  subCategoryId:
                    type: integer
                    nullable: true
                  preferredVendorId:
                    type: integer
                    nullable: true
                  productIds:
                    type: array
                    nullable: true
                    items:
                      type: integer
                  lotIds:
                    type: array
                    nullable: true
                    items:
                      type: integer
                  products:
                    type: array
                    nullable: true
                    description: Resolved item-scope product selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        productName:
                          type: string
                        internalSku:
                          type: string
                  lots:
                    type: array
                    nullable: true
                    description: Resolved item-scope lot selections as human-readable names. Present only on single-batch responses (create / batch detail); the paginated batch list omits it (no per-row lookup).
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        lotNumber:
                          type: string
                        productName:
                          type: string
                          nullable: true
                        expiryDate:
                          type: string
                          format: date
                          nullable: true
                  remarks:
                    type: string
                    nullable: true
                  createdBy:
                    type: integer
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                  sessions:
                    type: array
                    description: The per-warehouse sessions belonging to this batch.
                    items:
                      type: object
                      description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                      properties:
                        id:
                          type: integer
                        uuid:
                          type: string
                        batchId:
                          type: integer
                        warehouseId:
                          type: integer
                        status:
                          type: string
                          enum:
                            - draft
                            - in_progress
                            - pending_review
                            - posted
                            - cancelled
                        skuCount:
                          type: integer
                          description: Number of distinct SKUs in the session.
                        countedSkuCount:
                          type: integer
                          description: Number of SKUs that have been counted so far.
                        theoreticalValue:
                          type: number
                          description: 'System (book) value of the stock in scope, at post time.'
                        totalVarianceQty:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        totalVarianceValue:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        accuracyPercentage:
                          type: number
                          nullable: true
                          description: Populated once the session reaches pending_review.
                        adjustmentId:
                          type: integer
                          nullable: true
                          description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                        startedBy:
                          type: integer
                          nullable: true
                        startedAt:
                          type: string
                          format: date-time
                          nullable: true
                        postedBy:
                          type: integer
                          nullable: true
                        postedAt:
                          type: string
                          format: date-time
                          nullable: true
                        cancelledBy:
                          type: integer
                          nullable: true
                        cancelledAt:
                          type: string
                          format: date-time
                          nullable: true
                        createdAt:
                          type: string
                          format: date-time
                        updatedAt:
                          type: string
                          format: date-time
                  sessionsCount:
                    type: integer
                    description: Total number of sessions in the batch. Present on the batch list/detail endpoints (redundant with `sessions.length` when the full collection is also returned).
                  warning:
                    type: string
                    description: Present only on the create response when `scope_type=item` and some selected products/lots had no stock and were dropped from the count.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
  '/pickflow/cycle-counts/batches/{batchId}/export':
    get:
      operationId: exportPickflowCycleCountBatch
      tags:
        - Cycle Counts
      summary: Export the batch-level variance report as CSV
      description: |-
        Returns the batch-level variance report (all warehouses) directly as a CSV file download (`Content-Disposition: attachment`), not a JSON-wrapped URL — the same contract as the other External API file-download endpoints.

        Columns, in order: Warehouse, Primary Vendor, SKU, Item, Pre-Commit Quantity, Pre-Commit Calculated Cost, Post-Commit Quantity, Post-Commit Calculated Cost, Commit Quantity Variance, Post-Commit Cost Variance, Bin Location. Bin Location is the bin recorded on the count line and is blank for warehouse-level counts; it is appended last so the earlier columns keep their positions.
      security:
        - BearerAuth: []
      parameters:
        - name: batchId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: 'CSV file (`text/csv`, `Content-Disposition: attachment`).'
          content:
            text/csv:
              schema:
                type: string
                format: binary
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
  '/pickflow/cycle-counts/{sessionId}':
    get:
      operationId: getPickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Get a cycle count session
      description: Returns session detail. The session must belong to the given `warehouse_id`. This endpoint pre-dates CS-8871 and returns a legacy session shape.
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
        - name: warehouse_id
          in: query
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The cycle count session (legacy shape).
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
    delete:
      operationId: deletePickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Delete a cycle count session
      description: '**Destructive and irreversible from an external caller''s point of view** — there is no undelete endpoint. Refused (`422`) when the session is already `posted`. Requires an explicit `{"confirm": true}` body, the same external-only safety gate as `post`. Row-locks the session before checking status (the same lock `post` uses), so this can''t race a concurrent `post` of the same session.'
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - confirm
              properties:
                confirm:
                  type: boolean
                  enum:
                    - true
                  description: Must be true. Explicit external-only acknowledgment of a destructive delete.
      responses:
        '200':
          description: Deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: 'Session is already posted, or `confirm` was missing/false.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/items':
    get:
      operationId: listPickflowCycleCountSessionItems
      tags:
        - Cycle Counts
      summary: List session items
      description: 'Paginated, filterable list of the items in a session. This endpoint pre-dates CS-8871 and returns a legacy item shape.'
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
        - name: warehouse_id
          in: query
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Paginated list of cycle count items (legacy shape).
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/pickflow/cycle-counts/{sessionId}/items/{itemId}/count':
    post:
      operationId: recordPickflowCycleCountItemCount
      tags:
        - Cycle Counts
      summary: Record a count for one item
      description: Records a counted quantity for a single item. The session must be `in_progress`. This endpoint pre-dates CS-8871.
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
        - name: itemId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                warehouse_id:
                  type: integer
                counted_qty:
                  type: number
                  nullable: true
      responses:
        '200':
          description: The updated cycle count item.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/scan':
    post:
      operationId: scanPickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Scan a barcode and record a count
      description: 'Records a count by barcode rather than item id — the scanner use case. This endpoint pre-dates CS-8871. When the scanned product sits in several bins or lots within the session, pass `location_id` (and `lot_id`) to count the right row; omitted, the first session item for the product is counted. A barcode that cannot be resolved to an item in the session returns `422`.'
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                warehouse_id:
                  type: integer
                barcode:
                  type: string
                counted_qty:
                  type: number
                location_id:
                  type: integer
                  nullable: true
                  description: Bin to count. Optional; targets one bin row when the product is in several.
                lot_id:
                  type: integer
                  nullable: true
                  description: Lot to count within the bin. Optional.
      responses:
        '200':
          description: The updated cycle count item.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: 'Validation error, or the barcode could not be resolved to an item in this session/bin'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/progress':
    get:
      operationId: getPickflowCycleCountSessionProgress
      tags:
        - Cycle Counts
      summary: Session counting-progress summary
      description: Returns a live counting-progress summary for a session. This endpoint pre-dates CS-8871.
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
        - name: warehouse_id
          in: query
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Counting-progress summary.
          content:
            application/json:
              schema:
                type: object
                properties:
                  sku_count:
                    type: integer
                  counted_sku_count:
                    type: integer
                  theoretical_value:
                    type: number
                  total_variance_qty:
                    type: number
                  total_variance_value:
                    type: number
                  accuracy_percentage:
                    type: number
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/pickflow/cycle-counts/{sessionId}/start':
    post:
      operationId: startPickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Start counting
      description: Transitions a session from `draft` to `in_progress`.
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The updated session.
          content:
            application/json:
              schema:
                type: object
                description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  batchId:
                    type: integer
                  warehouseId:
                    type: integer
                  status:
                    type: string
                    enum:
                      - draft
                      - in_progress
                      - pending_review
                      - posted
                      - cancelled
                  skuCount:
                    type: integer
                    description: Number of distinct SKUs in the session.
                  countedSkuCount:
                    type: integer
                    description: Number of SKUs that have been counted so far.
                  theoreticalValue:
                    type: number
                    description: 'System (book) value of the stock in scope, at post time.'
                  totalVarianceQty:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  totalVarianceValue:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  accuracyPercentage:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  adjustmentId:
                    type: integer
                    nullable: true
                    description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                  startedBy:
                    type: integer
                    nullable: true
                  startedAt:
                    type: string
                    format: date-time
                    nullable: true
                  postedBy:
                    type: integer
                    nullable: true
                  postedAt:
                    type: string
                    format: date-time
                    nullable: true
                  cancelledBy:
                    type: integer
                    nullable: true
                  cancelledAt:
                    type: string
                    format: date-time
                    nullable: true
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Session is not `draft`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/submit-review':
    post:
      operationId: submitReviewPickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Submit for review
      description: 'Transitions a session from `in_progress` to `pending_review`. The variance fields (`totalVarianceQty`, `totalVarianceValue`, `accuracyPercentage`) are populated on the returned session.'
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: 'The updated session, with variance fields populated.'
          content:
            application/json:
              schema:
                type: object
                description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  batchId:
                    type: integer
                  warehouseId:
                    type: integer
                  status:
                    type: string
                    enum:
                      - draft
                      - in_progress
                      - pending_review
                      - posted
                      - cancelled
                  skuCount:
                    type: integer
                    description: Number of distinct SKUs in the session.
                  countedSkuCount:
                    type: integer
                    description: Number of SKUs that have been counted so far.
                  theoreticalValue:
                    type: number
                    description: 'System (book) value of the stock in scope, at post time.'
                  totalVarianceQty:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  totalVarianceValue:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  accuracyPercentage:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  adjustmentId:
                    type: integer
                    nullable: true
                    description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                  startedBy:
                    type: integer
                    nullable: true
                  startedAt:
                    type: string
                    format: date-time
                    nullable: true
                  postedBy:
                    type: integer
                    nullable: true
                  postedAt:
                    type: string
                    format: date-time
                    nullable: true
                  cancelledBy:
                    type: integer
                    nullable: true
                  cancelledAt:
                    type: string
                    format: date-time
                    nullable: true
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Session is not `in_progress`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/reopen':
    post:
      operationId: reopenPickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Reopen for counting
      description: Transitions a session from `pending_review` back to `in_progress`.
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The updated session.
          content:
            application/json:
              schema:
                type: object
                description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  batchId:
                    type: integer
                  warehouseId:
                    type: integer
                  status:
                    type: string
                    enum:
                      - draft
                      - in_progress
                      - pending_review
                      - posted
                      - cancelled
                  skuCount:
                    type: integer
                    description: Number of distinct SKUs in the session.
                  countedSkuCount:
                    type: integer
                    description: Number of SKUs that have been counted so far.
                  theoreticalValue:
                    type: number
                    description: 'System (book) value of the stock in scope, at post time.'
                  totalVarianceQty:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  totalVarianceValue:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  accuracyPercentage:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  adjustmentId:
                    type: integer
                    nullable: true
                    description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                  startedBy:
                    type: integer
                    nullable: true
                  startedAt:
                    type: string
                    format: date-time
                    nullable: true
                  postedBy:
                    type: integer
                    nullable: true
                  postedAt:
                    type: string
                    format: date-time
                    nullable: true
                  cancelledBy:
                    type: integer
                    nullable: true
                  cancelledAt:
                    type: string
                    format: date-time
                    nullable: true
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Session is not `pending_review`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/post':
    post:
      operationId: postPickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Post a cycle count session
      description: |-
        Transitions a session from `pending_review` to `posted`.

        **This is the one endpoint in the cycle count surface with real financial/inventory blast radius.** It creates a genuine inventory adjustment and mutates on-hand stock and cost layers, via the same posting path as the UI. There is no dry-run mode and the result is not reversible through this API. Get explicit security/product sign-off before enabling this route for a live, automated (e.g. MCP-driven) caller in production.

        Requires an explicit `{"confirm": true}` body as an external-only safety gate (the UI's equivalent is an interactive confirmation dialog). Additionally returns `403` if the session's batch is `scope_type: item` and the tenant is not currently flagged for `CS_8871_CYCLE_COUNT_LOCATION_SCOPE`.

        **Locked against concurrent calls.** The pending-review status check runs against a `lockForUpdate()` read of the session row inside the posting transaction, so two near-simultaneous requests for the same session serialize — the second blocks until the first commits, then sees `posted` and returns `422` instead of also creating an adjustment.
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - confirm
              properties:
                confirm:
                  type: boolean
                  enum:
                    - true
                  description: 'Must be true. Explicit external-only acknowledgment that this posts a real, irreversible inventory adjustment.'
      responses:
        '200':
          description: 'The posted session, with `status=posted` and `adjustmentId` set.'
          content:
            application/json:
              schema:
                type: object
                description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  batchId:
                    type: integer
                  warehouseId:
                    type: integer
                  status:
                    type: string
                    enum:
                      - draft
                      - in_progress
                      - pending_review
                      - posted
                      - cancelled
                  skuCount:
                    type: integer
                    description: Number of distinct SKUs in the session.
                  countedSkuCount:
                    type: integer
                    description: Number of SKUs that have been counted so far.
                  theoreticalValue:
                    type: number
                    description: 'System (book) value of the stock in scope, at post time.'
                  totalVarianceQty:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  totalVarianceValue:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  accuracyPercentage:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  adjustmentId:
                    type: integer
                    nullable: true
                    description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                  startedBy:
                    type: integer
                    nullable: true
                  startedAt:
                    type: string
                    format: date-time
                    nullable: true
                  postedBy:
                    type: integer
                    nullable: true
                  postedAt:
                    type: string
                    format: date-time
                    nullable: true
                  cancelledBy:
                    type: integer
                    nullable: true
                  cancelledAt:
                    type: string
                    format: date-time
                    nullable: true
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: 'Session is not `pending_review`, or `confirm` was missing/false.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/cancel':
    post:
      operationId: cancelPickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Cancel a cycle count session
      description: Transitions a session from any non-posted status to `cancelled`. Posted sessions cannot be cancelled.
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The cancelled session.
          content:
            application/json:
              schema:
                type: object
                description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  batchId:
                    type: integer
                  warehouseId:
                    type: integer
                  status:
                    type: string
                    enum:
                      - draft
                      - in_progress
                      - pending_review
                      - posted
                      - cancelled
                  skuCount:
                    type: integer
                    description: Number of distinct SKUs in the session.
                  countedSkuCount:
                    type: integer
                    description: Number of SKUs that have been counted so far.
                  theoreticalValue:
                    type: number
                    description: 'System (book) value of the stock in scope, at post time.'
                  totalVarianceQty:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  totalVarianceValue:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  accuracyPercentage:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  adjustmentId:
                    type: integer
                    nullable: true
                    description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                  startedBy:
                    type: integer
                    nullable: true
                  startedAt:
                    type: string
                    format: date-time
                    nullable: true
                  postedBy:
                    type: integer
                    nullable: true
                  postedAt:
                    type: string
                    format: date-time
                    nullable: true
                  cancelledBy:
                    type: integer
                    nullable: true
                  cancelledAt:
                    type: string
                    format: date-time
                    nullable: true
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Session is already posted (posted sessions cannot be cancelled).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/reset-counts':
    post:
      operationId: resetPickflowCycleCountSessionCounts
      tags:
        - Cycle Counts
      summary: Reset all counted quantities
      description: 'Clears all counted quantities back to null, resetting `countedSkuCount` to 0. The session must be `in_progress`.'
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The session with counts reset.
          content:
            application/json:
              schema:
                type: object
                description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                properties:
                  id:
                    type: integer
                  uuid:
                    type: string
                  batchId:
                    type: integer
                  warehouseId:
                    type: integer
                  status:
                    type: string
                    enum:
                      - draft
                      - in_progress
                      - pending_review
                      - posted
                      - cancelled
                  skuCount:
                    type: integer
                    description: Number of distinct SKUs in the session.
                  countedSkuCount:
                    type: integer
                    description: Number of SKUs that have been counted so far.
                  theoreticalValue:
                    type: number
                    description: 'System (book) value of the stock in scope, at post time.'
                  totalVarianceQty:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  totalVarianceValue:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  accuracyPercentage:
                    type: number
                    nullable: true
                    description: Populated once the session reaches pending_review.
                  adjustmentId:
                    type: integer
                    nullable: true
                    description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                  startedBy:
                    type: integer
                    nullable: true
                  startedAt:
                    type: string
                    format: date-time
                    nullable: true
                  postedBy:
                    type: integer
                    nullable: true
                  postedAt:
                    type: string
                    format: date-time
                    nullable: true
                  cancelledBy:
                    type: integer
                    nullable: true
                  cancelledAt:
                    type: string
                    format: date-time
                    nullable: true
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: Session is not `in_progress`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/export':
    get:
      operationId: exportPickflowCycleCountSession
      tags:
        - Cycle Counts
      summary: Export the session-level variance report as CSV
      description: |-
        Returns the session-level (single-warehouse) variance report directly as a CSV file download (`Content-Disposition: attachment`).

        Uses the same column layout as the batch-level export: Warehouse, Primary Vendor, SKU, Item, Pre-Commit Quantity, Pre-Commit Calculated Cost, Post-Commit Quantity, Post-Commit Calculated Cost, Commit Quantity Variance, Post-Commit Cost Variance, Bin Location (blank for warehouse-level counts).
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: 'CSV file (`text/csv`, `Content-Disposition: attachment`).'
          content:
            text/csv:
              schema:
                type: string
                format: binary
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/pickflow/cycle-counts/{sessionId}/template':
    get:
      operationId: getPickflowCycleCountSessionTemplate
      tags:
        - Cycle Counts
      summary: Download the CSV count-sheet template
      description: 'Downloads a CSV count-sheet template for the session, pre-filled with the items to count. The session must be `in_progress`. Returned directly as a file download (`Content-Disposition: attachment`).'
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: 'CSV file (`text/csv`, `Content-Disposition: attachment`).'
          content:
            text/csv:
              schema:
                type: string
                format: binary
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Session is not `in_progress`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/validate-import':
    post:
      operationId: validatePickflowCycleCountImport
      tags:
        - Cycle Counts
      summary: Validate an uploaded counting-sheet CSV
      description: |-
        Step 1 of the two-step CSV import flow. Takes a real multipart CSV upload and returns which rows matched, which didn't, and which were invalid — **without writing anything**. The session must be `in_progress`.

        The import flow is stateless: no server-side upload state is kept between this call and `import-counts`. Round-trip the `matchedItems` object from this response straight into `import-counts` (as `matched_items`) to apply it.
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: 'CSV or TXT, max 10MB. Columns "SKU" and "Counted Qty".'
      responses:
        '200':
          description: The validation result.
          content:
            application/json:
              schema:
                type: object
                description: 'Result of validating an uploaded counting-sheet CSV. Nothing is written by the validate step — round-trip `matchedItems` back into `POST /pickflow/cycle-counts/{sessionId}/import-counts` (as `matched_items`) to apply it.'
                properties:
                  matchedCount:
                    type: integer
                  unmatchedCount:
                    type: integer
                  invalidCount:
                    type: integer
                  hasErrors:
                    type: boolean
                  hasMatchedItems:
                    type: boolean
                  unmatchedSkus:
                    type: array
                    items:
                      type: string
                    description: SKUs present in the upload that don't match any item in the session.
                  invalidRows:
                    type: object
                    additionalProperties:
                      type: string
                    description: 'row_index => error message, for rows with a non-numeric or negative quantity.'
                  matchedItems:
                    type: object
                    additionalProperties:
                      type: number
                    description: item_id => counted_qty. Round-trip this object as-is into `import-counts`'s `matched_items` field.
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: 'Session is not `in_progress`, or the file failed validation (missing/wrong type).'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  '/pickflow/cycle-counts/{sessionId}/import-counts':
    post:
      operationId: importPickflowCycleCountCounts
      tags:
        - Cycle Counts
      summary: Apply a validated import
      description: 'Step 2 of the two-step CSV import flow. `matched_items` is the `matchedItems` object returned by `validate-import`, round-tripped back as-is (item_id => counted_qty). The session must be `in_progress`.'
      security:
        - BearerAuth: []
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - matched_items
              properties:
                matched_items:
                  type: object
                  additionalProperties:
                    type: number
                  example:
                    '1042': 15
                    '1043': 0
      responses:
        '200':
          description: The number of items updated and the refreshed session.
          content:
            application/json:
              schema:
                type: object
                properties:
                  updated:
                    type: integer
                  session:
                    type: object
                    description: 'A per-warehouse cycle count session. Every batch produces one session per warehouse in scope. This is the CS-8871 response shape returned by the lifecycle endpoints (start, submit-review, reopen, post, cancel, reset-counts) and by the batch endpoints where sessions are nested.'
                    properties:
                      id:
                        type: integer
                      uuid:
                        type: string
                      batchId:
                        type: integer
                      warehouseId:
                        type: integer
                      status:
                        type: string
                        enum:
                          - draft
                          - in_progress
                          - pending_review
                          - posted
                          - cancelled
                      skuCount:
                        type: integer
                        description: Number of distinct SKUs in the session.
                      countedSkuCount:
                        type: integer
                        description: Number of SKUs that have been counted so far.
                      theoreticalValue:
                        type: number
                        description: 'System (book) value of the stock in scope, at post time.'
                      totalVarianceQty:
                        type: number
                        nullable: true
                        description: Populated once the session reaches pending_review.
                      totalVarianceValue:
                        type: number
                        nullable: true
                        description: Populated once the session reaches pending_review.
                      accuracyPercentage:
                        type: number
                        nullable: true
                        description: Populated once the session reaches pending_review.
                      adjustmentId:
                        type: integer
                        nullable: true
                        description: Id of the inventory adjustment created when the session is posted. Set once status is posted.
                      startedBy:
                        type: integer
                        nullable: true
                      startedAt:
                        type: string
                        format: date-time
                        nullable: true
                      postedBy:
                        type: integer
                        nullable: true
                      postedAt:
                        type: string
                        format: date-time
                        nullable: true
                      cancelledBy:
                        type: integer
                        nullable: true
                      cancelledAt:
                        type: string
                        format: date-time
                        nullable: true
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '403':
          description: 'Forbidden (for example, the feature is not enabled). Also returned when the API user is assigned to specific warehouses (warehouse assignment is set per user in the app) and this request touches a warehouse outside that assignment: `You are not assigned to this warehouse.`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: The requested resource was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Not Found
                  message:
                    type: string
                    example: The requested resource could not be found
                  status_code:
                    type: integer
                    example: 404
        '422':
          description: 'Session is not `in_progress`, or `matched_items` was missing.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /print-stations:
    get:
      operationId: listPrintStations
      tags:
        - Print Stations
      summary: List print stations
      description: 'List the tenant''s paired print stations, most recently paired first. Any external client (including PickFlow) can list stations and enqueue jobs directly. This endpoint is also exposed at `GET /pickflow/print-stations` as a PickFlow-specific alias. The station''s `token_hash` is never exposed.'
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: Print station ID.
                        name:
                          type: string
                          nullable: true
                          description: Station display name.
                        hostname:
                          type: string
                          nullable: true
                          description: Hostname of the machine running the station agent.
                        platform:
                          type: string
                          nullable: true
                          description: Operating system / platform of the station.
                        status:
                          type: string
                          description: 'Derived station status (e.g. online, offline) based on the last heartbeat.'
                        default_printer_name:
                          type: string
                          nullable: true
                          description: Name of the station's default printer.
                        printers:
                          type: array
                          description: Printers available on the station.
                          items:
                            type: object
                            additionalProperties: true
                            properties:
                              name:
                                type: string
                                description: Printer name (use this value as printer_name when enqueuing a job).
                        last_heartbeat_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: Timestamp of the station's most recent heartbeat (ISO 8601).
                        paired_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: When the station was paired (ISO 8601).
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
  '/print-stations/{stationId}/print-jobs':
    post:
      operationId: createPrintStationJob
      tags:
        - Print Stations
      summary: Enqueue a print job
      description: 'Enqueue a print job to a paired, non-revoked print station. The station''s agent picks it up on its next long-poll. Provide the payload as `payload_base64` (binary/PDF bytes) or `payload_text` (raw ZPL command stream) — exactly one is required. If `printer_name` is supplied it must match a printer available on the station.'
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: stationId
          required: true
          schema:
            type: string
          description: ID of the target print station.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - format
              properties:
                kind:
                  type: string
                  nullable: true
                  enum:
                    - shipping_label
                    - packing_slip
                    - raw
                  description: Job kind. Defaults to `raw`.
                format:
                  type: string
                  enum:
                    - zpl
                    - pdf
                  description: Payload format.
                printer_name:
                  type: string
                  nullable: true
                  description: Target printer name. Must match a printer available on the station; omit to use the station default.
                payload_base64:
                  type: string
                  nullable: true
                  description: Base64-encoded payload (binary/PDF bytes). Required when `payload_text` is not provided.
                payload_text:
                  type: string
                  nullable: true
                  description: Raw text payload (e.g. a ZPL command stream). Required when `payload_base64` is not provided.
                copies:
                  type: integer
                  nullable: true
                  minimum: 1
                  maximum: 10
                  description: Number of copies to print. Defaults to 1.
                metadata:
                  type: object
                  nullable: true
                  additionalProperties: true
                  description: Arbitrary metadata echoed back on the job.
      responses:
        '201':
          description: Print job enqueued
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Print job ID.
                      station_id:
                        type: string
                        description: ID of the station the job was enqueued to.
                      status:
                        type: string
                        description: Job status (e.g. queued).
                      kind:
                        type: string
                        description: 'Job kind (shipping_label, packing_slip, or raw).'
                      format:
                        type: string
                        description: Payload format (zpl or pdf).
                      printer_name:
                        type: string
                        nullable: true
                        description: 'Target printer name, or null to use the station default.'
                      copies:
                        type: integer
                        description: Number of copies to print.
                      metadata:
                        type: object
                        nullable: true
                        additionalProperties: true
                        description: Arbitrary caller-supplied metadata echoed back on the job.
                      created_at:
                        type: string
                        format: date-time
                        description: When the job was created (ISO 8601).
        '400':
          description: The requested printer is not available on the station.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  available_printers:
                    type: array
                    items:
                      type: string
        '401':
          description: Authentication credentials were missing or invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
                  message:
                    type: string
                    example: Authentication credentials are missing or invalid
                  status_code:
                    type: integer
                    example: 401
        '404':
          description: Print station not found or revoked.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
  /file-cabinet/folders:
    get:
      operationId: listDriveFolders
      tags:
        - Drive
      summary: List folders
      description: |
        List the top-level folders of the shared drive, or the sub-folders of `parent_id`.
        Each folder has `has_children`, so you can walk the tree one level at a time.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: parent_id
          schema:
            type: integer
          description: Return the sub-folders of this folder instead of the top-level folders
      responses:
        '200':
          description: Folders
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A Drive folder.
                      properties:
                        id:
                          type: integer
                          example: 41
                        type:
                          type: string
                          enum:
                            - folder
                        name:
                          type: string
                          example: SS27 Shoot
                        parent_id:
                          type: integer
                          nullable: true
                          description: 'Parent folder ID, or `null` for a top-level folder'
                        is_restricted:
                          type: boolean
                          description: Restricted folders are never visible to API tokens
                        is_system:
                          type: boolean
                          description: 'System folders (for example the record folders that hold emailed documents) cannot be renamed, moved or deleted'
                        is_my_files:
                          type: boolean
                          description: 'Always `false` for API tokens, which only see the shared drive'
                        has_children:
                          type: boolean
                          nullable: true
                          description: Whether the folder has visible sub-folders. Only set on folder listings.
                        tags:
                          type: array
                          items:
                            type: object
                            description: A Drive tag.
                            properties:
                              id:
                                type: integer
                                example: 12
                              name:
                                type: string
                                description: 'Tag name (at most 50 characters, unique ignoring case)'
                                example: SS27
                              color:
                                type: string
                                enum:
                                  - gray
                                  - blue
                                  - green
                                  - yellow
                                  - orange
                                  - red
                                  - purple
                                  - pink
                                description: Tag color. Unknown colors are stored as `gray`.
                                example: green
                        created_by:
                          type: integer
                          nullable: true
                          description: ID of the user who created the folder
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
                        updated_at:
                          type: string
                          format: date-time
                          nullable: true
                        deleted_at:
                          type: string
                          format: date-time
                          nullable: true
                          description: Set while the folder is in the trash
                        can_edit:
                          type: boolean
                          nullable: true
                          description: Whether the token's owner can edit this folder
                        is_starred:
                          type: boolean
                          nullable: true
                          description: Whether the token's owner has starred this folder
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createDriveFolder
      tags:
        - Drive
      summary: Create a folder
      description: |
        Create a folder at the top level, or inside `parent_id`.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 200
                  description: Folder name
                  example: SS27 Shoot
                parent_id:
                  type: integer
                  nullable: true
                  description: Parent folder ID. Omit for a top-level folder.
      responses:
        '201':
          description: Folder created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive folder.
                    properties:
                      id:
                        type: integer
                        example: 41
                      type:
                        type: string
                        enum:
                          - folder
                      name:
                        type: string
                        example: SS27 Shoot
                      parent_id:
                        type: integer
                        nullable: true
                        description: 'Parent folder ID, or `null` for a top-level folder'
                      is_restricted:
                        type: boolean
                        description: Restricted folders are never visible to API tokens
                      is_system:
                        type: boolean
                        description: 'System folders (for example the record folders that hold emailed documents) cannot be renamed, moved or deleted'
                      is_my_files:
                        type: boolean
                        description: 'Always `false` for API tokens, which only see the shared drive'
                      has_children:
                        type: boolean
                        nullable: true
                        description: Whether the folder has visible sub-folders. Only set on folder listings.
                      tags:
                        type: array
                        items:
                          type: object
                          description: A Drive tag.
                          properties:
                            id:
                              type: integer
                              example: 12
                            name:
                              type: string
                              description: 'Tag name (at most 50 characters, unique ignoring case)'
                              example: SS27
                            color:
                              type: string
                              enum:
                                - gray
                                - blue
                                - green
                                - yellow
                                - orange
                                - red
                                - purple
                                - pink
                              description: Tag color. Unknown colors are stored as `gray`.
                              example: green
                      created_by:
                        type: integer
                        nullable: true
                        description: ID of the user who created the folder
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      deleted_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: Set while the folder is in the trash
                      can_edit:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner can edit this folder
                      is_starred:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner has starred this folder
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/folders/{id}':
    get:
      operationId: getDriveFolder
      tags:
        - Drive
      summary: Get a folder and its contents
      description: |
        Get a folder with its breadcrumbs, its sub-folders and one page of its files.

        Files can be filtered and sorted. Use `search` (never `q`) to filter by name. To list
        every image in a folder, pass `mime=image/*`.

        Sub-folders come back in full on every page. Pass `include_folders=0` on later pages
        to skip them (`folders` is then an empty array).

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Folder ID
        - in: query
          name: search
          schema:
            type: string
          description: Only files whose name contains this text
        - in: query
          name: mime
          schema:
            type: string
          description: 'Only files of this MIME type. A trailing wildcard matches a family, e.g. `image/*`.'
          example: image/*
        - in: query
          name: kind
          schema:
            type: string
            enum:
              - image
              - pdf
              - document
              - spreadsheet
              - presentation
          description: Only files of this kind
        - in: query
          name: 'tag_ids[]'
          schema:
            type: array
            items:
              type: integer
          description: Only files carrying any of these tags
        - in: query
          name: created_by
          schema:
            type: integer
          description: Only files created by this user ID
        - in: query
          name: expiring_within_days
          schema:
            type: integer
          description: Only files with an expiry date within this many days
        - in: query
          name: updated_since
          schema:
            type: string
            format: date-time
          description: Only files updated at or after this time
        - in: query
          name: updated_before
          schema:
            type: string
            format: date-time
          description: Only files updated before this time
        - in: query
          name: sort
          schema:
            type: string
            enum:
              - name
              - updated_at
              - size_bytes
              - created_at
            default: name
          description: File sort field. Sub-folders sort by `name` or `updated_at`.
        - in: query
          name: direction
          schema:
            type: string
            enum:
              - asc
              - desc
            default: asc
        - in: query
          name: include_folders
          schema:
            type: boolean
            default: true
          description: Set to `0` on later pages to skip the sub-folders
        - in: query
          name: page
          schema:
            type: integer
            default: 1
        - in: query
          name: per_page
          schema:
            type: integer
            default: 100
            maximum: 500
          description: Files per page (max 500)
      responses:
        '200':
          description: Folder with contents
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      folder:
                        type: object
                        description: A Drive folder.
                        properties:
                          id:
                            type: integer
                            example: 41
                          type:
                            type: string
                            enum:
                              - folder
                          name:
                            type: string
                            example: SS27 Shoot
                          parent_id:
                            type: integer
                            nullable: true
                            description: 'Parent folder ID, or `null` for a top-level folder'
                          is_restricted:
                            type: boolean
                            description: Restricted folders are never visible to API tokens
                          is_system:
                            type: boolean
                            description: 'System folders (for example the record folders that hold emailed documents) cannot be renamed, moved or deleted'
                          is_my_files:
                            type: boolean
                            description: 'Always `false` for API tokens, which only see the shared drive'
                          has_children:
                            type: boolean
                            nullable: true
                            description: Whether the folder has visible sub-folders. Only set on folder listings.
                          tags:
                            type: array
                            items:
                              type: object
                              description: A Drive tag.
                              properties:
                                id:
                                  type: integer
                                  example: 12
                                name:
                                  type: string
                                  description: 'Tag name (at most 50 characters, unique ignoring case)'
                                  example: SS27
                                color:
                                  type: string
                                  enum:
                                    - gray
                                    - blue
                                    - green
                                    - yellow
                                    - orange
                                    - red
                                    - purple
                                    - pink
                                  description: Tag color. Unknown colors are stored as `gray`.
                                  example: green
                          created_by:
                            type: integer
                            nullable: true
                            description: ID of the user who created the folder
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                          updated_at:
                            type: string
                            format: date-time
                            nullable: true
                          deleted_at:
                            type: string
                            format: date-time
                            nullable: true
                            description: Set while the folder is in the trash
                          can_edit:
                            type: boolean
                            nullable: true
                            description: Whether the token's owner can edit this folder
                          is_starred:
                            type: boolean
                            nullable: true
                            description: Whether the token's owner has starred this folder
                      breadcrumbs:
                        type: array
                        description: The folders from the top level down to this folder
                        items:
                          type: object
                      folders:
                        type: array
                        items:
                          type: object
                          description: A Drive folder.
                          properties:
                            id:
                              type: integer
                              example: 41
                            type:
                              type: string
                              enum:
                                - folder
                            name:
                              type: string
                              example: SS27 Shoot
                            parent_id:
                              type: integer
                              nullable: true
                              description: 'Parent folder ID, or `null` for a top-level folder'
                            is_restricted:
                              type: boolean
                              description: Restricted folders are never visible to API tokens
                            is_system:
                              type: boolean
                              description: 'System folders (for example the record folders that hold emailed documents) cannot be renamed, moved or deleted'
                            is_my_files:
                              type: boolean
                              description: 'Always `false` for API tokens, which only see the shared drive'
                            has_children:
                              type: boolean
                              nullable: true
                              description: Whether the folder has visible sub-folders. Only set on folder listings.
                            tags:
                              type: array
                              items:
                                type: object
                                description: A Drive tag.
                                properties:
                                  id:
                                    type: integer
                                    example: 12
                                  name:
                                    type: string
                                    description: 'Tag name (at most 50 characters, unique ignoring case)'
                                    example: SS27
                                  color:
                                    type: string
                                    enum:
                                      - gray
                                      - blue
                                      - green
                                      - yellow
                                      - orange
                                      - red
                                      - purple
                                      - pink
                                    description: Tag color. Unknown colors are stored as `gray`.
                                    example: green
                            created_by:
                              type: integer
                              nullable: true
                              description: ID of the user who created the folder
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Set while the folder is in the trash
                            can_edit:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner can edit this folder
                            is_starred:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner has starred this folder
                      files:
                        type: array
                        items:
                          type: object
                          description: A Drive file.
                          properties:
                            id:
                              type: integer
                              example: 481
                            type:
                              type: string
                              enum:
                                - file
                            name:
                              type: string
                              example: STYLE123_BLK_01.jpg
                            folder_id:
                              type: integer
                              nullable: true
                              description: ID of the folder holding the file
                            extension:
                              type: string
                              nullable: true
                              example: jpg
                            mime_type:
                              type: string
                              nullable: true
                              example: image/jpeg
                            size_bytes:
                              type: integer
                              description: Size of the current version in bytes
                              example: 482113
                            is_restricted:
                              type: boolean
                              description: Restricted files are never visible to API tokens
                            is_image:
                              type: boolean
                            current_version:
                              allOf:
                                - type: object
                                  description: One uploaded version of a Drive file.
                                  properties:
                                    id:
                                      type: integer
                                      example: 33
                                    version_number:
                                      type: integer
                                      example: 2
                                    size_bytes:
                                      type: integer
                                      example: 482113
                                    mime_type:
                                      type: string
                                      nullable: true
                                      example: image/jpeg
                                    original_name:
                                      type: string
                                      nullable: true
                                      description: File name as uploaded
                                      example: STYLE123_BLK_01.jpg
                                    status:
                                      type: string
                                      description: Upload status. Only `ready` versions can be downloaded.
                                      example: ready
                                    uploaded_by:
                                      type: integer
                                      nullable: true
                                      description: ID of the user who uploaded the version
                                    completed_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    created_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                              nullable: true
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                            public_image_url:
                              type: string
                              nullable: true
                              description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                            expires_at:
                              type: string
                              format: date
                              nullable: true
                              description: 'Expiry date of the document, if one is set'
                            expiry_notify_user_ids:
                              type: array
                              items:
                                type: integer
                              description: Users notified before the file expires
                            tags:
                              type: array
                              items:
                                type: object
                                description: A Drive tag.
                                properties:
                                  id:
                                    type: integer
                                    example: 12
                                  name:
                                    type: string
                                    description: 'Tag name (at most 50 characters, unique ignoring case)'
                                    example: SS27
                                  color:
                                    type: string
                                    enum:
                                      - gray
                                      - blue
                                      - green
                                      - yellow
                                      - orange
                                      - red
                                      - purple
                                      - pink
                                    description: Tag color. Unknown colors are stored as `gray`.
                                    example: green
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Set while the file is in the trash
                            can_edit:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner can edit this file
                            is_starred:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner has starred this file
                      files_meta:
                        type: object
                        properties:
                          current_page:
                            type: integer
                          last_page:
                            type: integer
                          per_page:
                            type: integer
                          total:
                            type: integer
                          has_more:
                            type: boolean
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    patch:
      operationId: updateDriveFolder
      tags:
        - Drive
      summary: Update a folder
      description: |
        Rename a folder, move it to another parent, or change whether it is restricted.
        System folders cannot be renamed or moved.

        Requires the `fileCabinet.write` permission. You also need edit rights on the folder.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Folder ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 200
                  description: New folder name
                parent_id:
                  type: integer
                  nullable: true
                  description: 'New parent folder ID, or `null` to move it to the top level'
                is_restricted:
                  type: boolean
                  description: Restrict the folder. A restricted folder is no longer visible to API tokens.
      responses:
        '200':
          description: Folder updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive folder.
                    properties:
                      id:
                        type: integer
                        example: 41
                      type:
                        type: string
                        enum:
                          - folder
                      name:
                        type: string
                        example: SS27 Shoot
                      parent_id:
                        type: integer
                        nullable: true
                        description: 'Parent folder ID, or `null` for a top-level folder'
                      is_restricted:
                        type: boolean
                        description: Restricted folders are never visible to API tokens
                      is_system:
                        type: boolean
                        description: 'System folders (for example the record folders that hold emailed documents) cannot be renamed, moved or deleted'
                      is_my_files:
                        type: boolean
                        description: 'Always `false` for API tokens, which only see the shared drive'
                      has_children:
                        type: boolean
                        nullable: true
                        description: Whether the folder has visible sub-folders. Only set on folder listings.
                      tags:
                        type: array
                        items:
                          type: object
                          description: A Drive tag.
                          properties:
                            id:
                              type: integer
                              example: 12
                            name:
                              type: string
                              description: 'Tag name (at most 50 characters, unique ignoring case)'
                              example: SS27
                            color:
                              type: string
                              enum:
                                - gray
                                - blue
                                - green
                                - yellow
                                - orange
                                - red
                                - purple
                                - pink
                              description: Tag color. Unknown colors are stored as `gray`.
                              example: green
                      created_by:
                        type: integer
                        nullable: true
                        description: ID of the user who created the folder
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      deleted_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: Set while the folder is in the trash
                      can_edit:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner can edit this folder
                      is_starred:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner has starred this folder
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteDriveFolder
      tags:
        - Drive
      summary: Delete a folder
      description: |
        Move a folder and everything under it to the trash, as one batch. Items stay in the
        trash for 30 days, then are deleted forever. Restore the batch with
        `POST /file-cabinet/trash/restore`.

        Returns `422` for system folders, for a folder holding restricted items, and for a
        folder holding images still used as product images.

        Requires the `fileCabinet.write` permission. You also need edit rights on the folder.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Folder ID
      responses:
        '200':
          description: Folder moved to the trash
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      trash_batch:
                        type: string
                        description: ID of the delete operation
                        example: 5b0c9c1e-7a8f-4f43-9a52-0b7d0f6f2b11
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/folder/{id}/tags':
    put:
      operationId: setDriveFolderTags
      tags:
        - Drive
      summary: Set folder tags
      description: |
        Replace the tags on a folder. Send an empty `tag_ids` array to remove every tag.
        Create tags first with `POST /file-cabinet/tags`.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Folder ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - tag_ids
              properties:
                tag_ids:
                  type: array
                  items:
                    type: integer
                  description: The complete list of tag IDs the item should carry
      responses:
        '200':
          description: The item's tags
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A Drive tag.
                      properties:
                        id:
                          type: integer
                          example: 12
                        name:
                          type: string
                          description: 'Tag name (at most 50 characters, unique ignoring case)'
                          example: SS27
                        color:
                          type: string
                          enum:
                            - gray
                            - blue
                            - green
                            - yellow
                            - orange
                            - red
                            - purple
                            - pink
                          description: Tag color. Unknown colors are stored as `gray`.
                          example: green
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /file-cabinet/files:
    get:
      operationId: searchDriveFiles
      tags:
        - Drive
      summary: Search files
      description: |
        Search everything in the shared drive the token can see. Returns at most 50 files
        (newest first) and, when `search` is set and no file-only filter is used, at most 50
        folders whose name matches.

        Use `search` (never `q`) to filter by name.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: search
          schema:
            type: string
          description: Text the name must contain
        - in: query
          name: folder_id
          schema:
            type: integer
          description: Only files directly in this folder
        - in: query
          name: mime
          schema:
            type: string
          description: 'Only files of this MIME type. A trailing wildcard matches a family, e.g. `image/*`.'
        - in: query
          name: kind
          schema:
            type: string
            enum:
              - image
              - pdf
              - document
              - spreadsheet
              - presentation
        - in: query
          name: 'tag_ids[]'
          schema:
            type: array
            items:
              type: integer
          description: Only files carrying any of these tags
        - in: query
          name: created_by
          schema:
            type: integer
        - in: query
          name: expiring_within_days
          schema:
            type: integer
        - in: query
          name: updated_since
          schema:
            type: string
            format: date-time
        - in: query
          name: updated_before
          schema:
            type: string
            format: date-time
      responses:
        '200':
          description: Search results
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      folders:
                        type: array
                        items:
                          type: object
                          description: A Drive folder.
                          properties:
                            id:
                              type: integer
                              example: 41
                            type:
                              type: string
                              enum:
                                - folder
                            name:
                              type: string
                              example: SS27 Shoot
                            parent_id:
                              type: integer
                              nullable: true
                              description: 'Parent folder ID, or `null` for a top-level folder'
                            is_restricted:
                              type: boolean
                              description: Restricted folders are never visible to API tokens
                            is_system:
                              type: boolean
                              description: 'System folders (for example the record folders that hold emailed documents) cannot be renamed, moved or deleted'
                            is_my_files:
                              type: boolean
                              description: 'Always `false` for API tokens, which only see the shared drive'
                            has_children:
                              type: boolean
                              nullable: true
                              description: Whether the folder has visible sub-folders. Only set on folder listings.
                            tags:
                              type: array
                              items:
                                type: object
                                description: A Drive tag.
                                properties:
                                  id:
                                    type: integer
                                    example: 12
                                  name:
                                    type: string
                                    description: 'Tag name (at most 50 characters, unique ignoring case)'
                                    example: SS27
                                  color:
                                    type: string
                                    enum:
                                      - gray
                                      - blue
                                      - green
                                      - yellow
                                      - orange
                                      - red
                                      - purple
                                      - pink
                                    description: Tag color. Unknown colors are stored as `gray`.
                                    example: green
                            created_by:
                              type: integer
                              nullable: true
                              description: ID of the user who created the folder
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Set while the folder is in the trash
                            can_edit:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner can edit this folder
                            is_starred:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner has starred this folder
                      files:
                        type: array
                        items:
                          type: object
                          description: A Drive file.
                          properties:
                            id:
                              type: integer
                              example: 481
                            type:
                              type: string
                              enum:
                                - file
                            name:
                              type: string
                              example: STYLE123_BLK_01.jpg
                            folder_id:
                              type: integer
                              nullable: true
                              description: ID of the folder holding the file
                            extension:
                              type: string
                              nullable: true
                              example: jpg
                            mime_type:
                              type: string
                              nullable: true
                              example: image/jpeg
                            size_bytes:
                              type: integer
                              description: Size of the current version in bytes
                              example: 482113
                            is_restricted:
                              type: boolean
                              description: Restricted files are never visible to API tokens
                            is_image:
                              type: boolean
                            current_version:
                              allOf:
                                - type: object
                                  description: One uploaded version of a Drive file.
                                  properties:
                                    id:
                                      type: integer
                                      example: 33
                                    version_number:
                                      type: integer
                                      example: 2
                                    size_bytes:
                                      type: integer
                                      example: 482113
                                    mime_type:
                                      type: string
                                      nullable: true
                                      example: image/jpeg
                                    original_name:
                                      type: string
                                      nullable: true
                                      description: File name as uploaded
                                      example: STYLE123_BLK_01.jpg
                                    status:
                                      type: string
                                      description: Upload status. Only `ready` versions can be downloaded.
                                      example: ready
                                    uploaded_by:
                                      type: integer
                                      nullable: true
                                      description: ID of the user who uploaded the version
                                    completed_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    created_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                              nullable: true
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                            public_image_url:
                              type: string
                              nullable: true
                              description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                            expires_at:
                              type: string
                              format: date
                              nullable: true
                              description: 'Expiry date of the document, if one is set'
                            expiry_notify_user_ids:
                              type: array
                              items:
                                type: integer
                              description: Users notified before the file expires
                            tags:
                              type: array
                              items:
                                type: object
                                description: A Drive tag.
                                properties:
                                  id:
                                    type: integer
                                    example: 12
                                  name:
                                    type: string
                                    description: 'Tag name (at most 50 characters, unique ignoring case)'
                                    example: SS27
                                  color:
                                    type: string
                                    enum:
                                      - gray
                                      - blue
                                      - green
                                      - yellow
                                      - orange
                                      - red
                                      - purple
                                      - pink
                                    description: Tag color. Unknown colors are stored as `gray`.
                                    example: green
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Set while the file is in the trash
                            can_edit:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner can edit this file
                            is_starred:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner has starred this file
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: uploadDriveFile
      tags:
        - Drive
      summary: Upload a small file
      description: |
        Upload a file of up to 5 MB in a single request. Send `folder_id` to create a
        new file, or `file_id` to upload a new version of an existing file.

        Send either a multipart request with a `file` part, or a JSON body with the file
        bytes base64-encoded in `content_base64` (for clients that cannot send multipart).
        The 5 MB limit applies to the decoded bytes. Invalid base64 returns `422`.

        For larger files (up to 500 MB) use `POST /file-cabinet/uploads`.

        This endpoint does not support `If-Match`. A request that sends it returns `422`; use
        `POST /file-cabinet/uploads` to upload a version only if no one has saved a newer one.

        Uploading a new version of an image that was applied to SKUs refreshes those SKUs'
        product images.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The file to upload (max 5 MB)
                folder_id:
                  type: integer
                  description: Folder to create the file in. Required unless `file_id` is sent.
                file_id:
                  type: integer
                  description: Existing file to add a new version to. Required unless `folder_id` is sent.
          application/json:
            schema:
              type: object
              required:
                - content_base64
                - name
              properties:
                content_base64:
                  type: string
                  maxLength: 7000000
                  description: 'The file contents, base64-encoded (max 5 MB once decoded)'
                name:
                  type: string
                  maxLength: 200
                  description: 'File name, including extension'
                mime_type:
                  type: string
                  maxLength: 150
                  nullable: true
                  description: MIME type of the file. Inferred from the name when omitted.
                folder_id:
                  type: integer
                  nullable: true
                  description: Folder to create the file in. Required unless `file_id` is sent.
                file_id:
                  type: integer
                  nullable: true
                  description: Existing file to add a new version to. Required unless `folder_id` is sent.
      responses:
        '201':
          description: File uploaded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive file.
                    properties:
                      id:
                        type: integer
                        example: 481
                      type:
                        type: string
                        enum:
                          - file
                      name:
                        type: string
                        example: STYLE123_BLK_01.jpg
                      folder_id:
                        type: integer
                        nullable: true
                        description: ID of the folder holding the file
                      extension:
                        type: string
                        nullable: true
                        example: jpg
                      mime_type:
                        type: string
                        nullable: true
                        example: image/jpeg
                      size_bytes:
                        type: integer
                        description: Size of the current version in bytes
                        example: 482113
                      is_restricted:
                        type: boolean
                        description: Restricted files are never visible to API tokens
                      is_image:
                        type: boolean
                      current_version:
                        allOf:
                          - type: object
                            description: One uploaded version of a Drive file.
                            properties:
                              id:
                                type: integer
                                example: 33
                              version_number:
                                type: integer
                                example: 2
                              size_bytes:
                                type: integer
                                example: 482113
                              mime_type:
                                type: string
                                nullable: true
                                example: image/jpeg
                              original_name:
                                type: string
                                nullable: true
                                description: File name as uploaded
                                example: STYLE123_BLK_01.jpg
                              status:
                                type: string
                                description: Upload status. Only `ready` versions can be downloaded.
                                example: ready
                              uploaded_by:
                                type: integer
                                nullable: true
                                description: ID of the user who uploaded the version
                              completed_at:
                                type: string
                                format: date-time
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                        nullable: true
                      thumbnail_url:
                        type: string
                        nullable: true
                        description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                      public_image_url:
                        type: string
                        nullable: true
                        description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                      expires_at:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expiry date of the document, if one is set'
                      expiry_notify_user_ids:
                        type: array
                        items:
                          type: integer
                        description: Users notified before the file expires
                      tags:
                        type: array
                        items:
                          type: object
                          description: A Drive tag.
                          properties:
                            id:
                              type: integer
                              example: 12
                            name:
                              type: string
                              description: 'Tag name (at most 50 characters, unique ignoring case)'
                              example: SS27
                            color:
                              type: string
                              enum:
                                - gray
                                - blue
                                - green
                                - yellow
                                - orange
                                - red
                                - purple
                                - pink
                              description: Tag color. Unknown colors are stored as `gray`.
                              example: green
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      deleted_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: Set while the file is in the trash
                      can_edit:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner can edit this file
                      is_starred:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner has starred this file
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}':
    get:
      operationId: getDriveFile
      tags:
        - Drive
      summary: Get a file
      description: |
        Get one file. For images, `thumbnail_url` is a 400px JPEG.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      responses:
        '200':
          description: File
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive file.
                    properties:
                      id:
                        type: integer
                        example: 481
                      type:
                        type: string
                        enum:
                          - file
                      name:
                        type: string
                        example: STYLE123_BLK_01.jpg
                      folder_id:
                        type: integer
                        nullable: true
                        description: ID of the folder holding the file
                      extension:
                        type: string
                        nullable: true
                        example: jpg
                      mime_type:
                        type: string
                        nullable: true
                        example: image/jpeg
                      size_bytes:
                        type: integer
                        description: Size of the current version in bytes
                        example: 482113
                      is_restricted:
                        type: boolean
                        description: Restricted files are never visible to API tokens
                      is_image:
                        type: boolean
                      current_version:
                        allOf:
                          - type: object
                            description: One uploaded version of a Drive file.
                            properties:
                              id:
                                type: integer
                                example: 33
                              version_number:
                                type: integer
                                example: 2
                              size_bytes:
                                type: integer
                                example: 482113
                              mime_type:
                                type: string
                                nullable: true
                                example: image/jpeg
                              original_name:
                                type: string
                                nullable: true
                                description: File name as uploaded
                                example: STYLE123_BLK_01.jpg
                              status:
                                type: string
                                description: Upload status. Only `ready` versions can be downloaded.
                                example: ready
                              uploaded_by:
                                type: integer
                                nullable: true
                                description: ID of the user who uploaded the version
                              completed_at:
                                type: string
                                format: date-time
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                        nullable: true
                      thumbnail_url:
                        type: string
                        nullable: true
                        description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                      public_image_url:
                        type: string
                        nullable: true
                        description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                      expires_at:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expiry date of the document, if one is set'
                      expiry_notify_user_ids:
                        type: array
                        items:
                          type: integer
                        description: Users notified before the file expires
                      tags:
                        type: array
                        items:
                          type: object
                          description: A Drive tag.
                          properties:
                            id:
                              type: integer
                              example: 12
                            name:
                              type: string
                              description: 'Tag name (at most 50 characters, unique ignoring case)'
                              example: SS27
                            color:
                              type: string
                              enum:
                                - gray
                                - blue
                                - green
                                - yellow
                                - orange
                                - red
                                - purple
                                - pink
                              description: Tag color. Unknown colors are stored as `gray`.
                              example: green
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      deleted_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: Set while the file is in the trash
                      can_edit:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner can edit this file
                      is_starred:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner has starred this file
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    patch:
      operationId: updateDriveFile
      tags:
        - Drive
      summary: Update a file
      description: |
        Rename a file, move it to another folder, restrict it, or set its expiry.

        Requires the `fileCabinet.write` permission. You also need edit rights on the file.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 200
                folder_id:
                  type: integer
                  description: Move the file to this folder
                is_restricted:
                  type: boolean
                  description: Restrict the file. A restricted file is no longer visible to API tokens.
                expires_at:
                  type: string
                  format: date
                  nullable: true
                  description: 'Expiry date, or `null` to clear it'
                expiry_notify_user_ids:
                  type: array
                  items:
                    type: integer
                  description: Users to notify before the file expires
      responses:
        '200':
          description: File updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive file.
                    properties:
                      id:
                        type: integer
                        example: 481
                      type:
                        type: string
                        enum:
                          - file
                      name:
                        type: string
                        example: STYLE123_BLK_01.jpg
                      folder_id:
                        type: integer
                        nullable: true
                        description: ID of the folder holding the file
                      extension:
                        type: string
                        nullable: true
                        example: jpg
                      mime_type:
                        type: string
                        nullable: true
                        example: image/jpeg
                      size_bytes:
                        type: integer
                        description: Size of the current version in bytes
                        example: 482113
                      is_restricted:
                        type: boolean
                        description: Restricted files are never visible to API tokens
                      is_image:
                        type: boolean
                      current_version:
                        allOf:
                          - type: object
                            description: One uploaded version of a Drive file.
                            properties:
                              id:
                                type: integer
                                example: 33
                              version_number:
                                type: integer
                                example: 2
                              size_bytes:
                                type: integer
                                example: 482113
                              mime_type:
                                type: string
                                nullable: true
                                example: image/jpeg
                              original_name:
                                type: string
                                nullable: true
                                description: File name as uploaded
                                example: STYLE123_BLK_01.jpg
                              status:
                                type: string
                                description: Upload status. Only `ready` versions can be downloaded.
                                example: ready
                              uploaded_by:
                                type: integer
                                nullable: true
                                description: ID of the user who uploaded the version
                              completed_at:
                                type: string
                                format: date-time
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                        nullable: true
                      thumbnail_url:
                        type: string
                        nullable: true
                        description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                      public_image_url:
                        type: string
                        nullable: true
                        description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                      expires_at:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expiry date of the document, if one is set'
                      expiry_notify_user_ids:
                        type: array
                        items:
                          type: integer
                        description: Users notified before the file expires
                      tags:
                        type: array
                        items:
                          type: object
                          description: A Drive tag.
                          properties:
                            id:
                              type: integer
                              example: 12
                            name:
                              type: string
                              description: 'Tag name (at most 50 characters, unique ignoring case)'
                              example: SS27
                            color:
                              type: string
                              enum:
                                - gray
                                - blue
                                - green
                                - yellow
                                - orange
                                - red
                                - purple
                                - pink
                              description: Tag color. Unknown colors are stored as `gray`.
                              example: green
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      deleted_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: Set while the file is in the trash
                      can_edit:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner can edit this file
                      is_starred:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner has starred this file
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteDriveFile
      tags:
        - Drive
      summary: Delete a file
      description: |
        Move a file to the trash. It stays there for 30 days, then is deleted forever.
        Restore it with `POST /file-cabinet/trash/restore`.

        Returns `422` if the file is a product photo on a SKU.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      responses:
        '200':
          description: File moved to the trash
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      trash_batch:
                        type: string
                        description: ID of the delete operation
                        example: 5b0c9c1e-7a8f-4f43-9a52-0b7d0f6f2b11
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}/download':
    get:
      operationId: downloadDriveFile
      tags:
        - Drive
      summary: Get a download URL
      description: |
        Get a signed URL for a file's bytes. The URL is valid for 5 minutes and needs no
        `Authorization` header.

        Pass `inline=1` to get a URL that opens in the browser instead of downloading. Inline
        is honored for JPEG, PNG, GIF, WebP, PDF, plain text, MP4 and MP3 files only.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
        - in: query
          name: inline
          schema:
            type: boolean
            default: false
          description: Return a URL that previews the file in the browser
        - in: query
          name: version_id
          schema:
            type: integer
          description: Download this version instead of the current one
      responses:
        '200':
          description: Signed URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      url:
                        type: string
                        description: 'Signed URL, valid for 5 minutes'
                      inline:
                        type: boolean
                        description: Whether the URL previews in the browser
                      expires_in:
                        type: integer
                        description: Seconds until the URL expires
                        example: 300
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}/thumbnail':
    get:
      operationId: getDriveFileThumbnail
      tags:
        - Drive
      summary: Get a file thumbnail
      description: |
        Get the JPEG thumbnail of a file's current version as raw bytes (`Content-Type: image/jpeg`).
        Use this instead of the thumbnail URL when your app cannot fetch from the storage host,
        for example an embedded app or browser sandbox: request it with your API token and turn
        the response into a Blob. Responses may be cached privately for 5 minutes.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      responses:
        '200':
          description: JPEG thumbnail bytes
          content:
            image/jpeg:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: 'File not found, not visible to API tokens, or has no thumbnail'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}/content':
    get:
      operationId: getDriveFileContent
      tags:
        - Drive
      summary: Get image file content
      description: |
        Stream the current version of an image file through the API, with its own `Content-Type`.
        Signed download URLs do not send CORS headers, so a browser cannot read their pixels
        (`fetch()`, canvas); this endpoint can. Only JPEG, PNG, GIF and WebP files are served;
        other types return 422. For other files use `GET /file-cabinet/files/{id}/download`.

        The read is recorded in the file's activity log. Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      responses:
        '200':
          description: 'Image bytes, served inline with the file name'
          content:
            image/jpeg:
              schema:
                type: string
                format: binary
            image/png:
              schema:
                type: string
                format: binary
            image/gif:
              schema:
                type: string
                format: binary
            image/webp:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: The file is not an image (or has no ready version)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}/versions':
    get:
      operationId: listDriveFileVersions
      tags:
        - Drive
      summary: List file versions
      description: |
        Get a file's version history. To upload a new version, call `POST /file-cabinet/uploads`
        or `POST /file-cabinet/files` with `file_id`.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      responses:
        '200':
          description: Versions
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: One uploaded version of a Drive file.
                      properties:
                        id:
                          type: integer
                          example: 33
                        version_number:
                          type: integer
                          example: 2
                        size_bytes:
                          type: integer
                          example: 482113
                        mime_type:
                          type: string
                          nullable: true
                          example: image/jpeg
                        original_name:
                          type: string
                          nullable: true
                          description: File name as uploaded
                          example: STYLE123_BLK_01.jpg
                        status:
                          type: string
                          description: Upload status. Only `ready` versions can be downloaded.
                          example: ready
                        uploaded_by:
                          type: integer
                          nullable: true
                          description: ID of the user who uploaded the version
                        completed_at:
                          type: string
                          format: date-time
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                          nullable: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}/activity':
    get:
      operationId: listDriveFileActivity
      tags:
        - Drive
      summary: List file activity
      description: |
        Get a file's activity log, newest first.

        Writes and downloads made through the API are recorded with `actor_kind: api_token`.
        Listings and reads are not recorded.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
        - in: query
          name: page
          schema:
            type: integer
            default: 1
        - in: query
          name: per_page
          schema:
            type: integer
            default: 50
            maximum: 200
          description: Entries per page (max 200)
      responses:
        '200':
          description: Activity
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          type: object
                          description: One entry in a Drive file's activity log.
                          properties:
                            id:
                              type: integer
                              example: 901
                            action:
                              type: string
                              enum:
                                - create
                                - upload
                                - version
                                - version_restore
                                - rename
                                - move
                                - restrict
                                - view
                                - download
                                - share
                                - unshare
                                - public_link_created
                                - public_link_revoked
                                - public_access
                                - public_image_enabled
                                - public_image_disabled
                                - trash
                                - restore
                                - purge
                                - tag
                                - expiry
                                - reference_added
                                - reference_removed
                              example: download
                            actor_kind:
                              type: string
                              enum:
                                - user
                                - api_token
                                - public_link
                                - system
                              description: Who did it. Calls made through the API are recorded as `api_token`.
                              example: api_token
                            actor_user_id:
                              type: integer
                              nullable: true
                              example: 7
                            actor_name:
                              type: string
                              nullable: true
                              example: Kol Bot
                            meta:
                              type: object
                              description: 'Action-specific details (for example `version_id` on a download). `{}` when there are none.'
                              example:
                                version_id: 33
                            ip:
                              type: string
                              nullable: true
                              description: Only returned when the token's owner has the `fileCabinet.manage` permission
                            created_at:
                              type: string
                              format: date-time
                              example: '2026-10-14T15:02:11+00:00'
                      meta:
                        type: object
                        properties:
                          current_page:
                            type: integer
                          last_page:
                            type: integer
                          per_page:
                            type: integer
                          total:
                            type: integer
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}/references':
    get:
      operationId: listDriveFileReferences
      tags:
        - Drive
      summary: List where a file is used
      description: |
        List every record the file is linked to: attachments on sales orders, deals, lots and
        SKUs, product images, and the records whose emailed documents were filed here.

        Records the token's owner can't read are listed with `label: null`. Deleted records
        stay in the list with `missing: true`.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      responses:
        '200':
          description: References
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          description: Reference ID
                        role:
                          type: string
                          description: How the file is linked (for example `attachment`)
                        target_type:
                          type: string
                          enum:
                            - sales_order
                            - deal
                            - rfq_lot
                            - sku
                            - sku_image
                            - customer
                            - invoice
                            - purchase_order
                            - work_order
                            - production_batch
                        target_id:
                          type: integer
                        label:
                          type: string
                          nullable: true
                          description: 'Display name of the record, or `null` if the token''s owner can''t read it'
                        missing:
                          type: boolean
                          description: '`true` if the record has been deleted'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}/apply-to-sku':
    post:
      operationId: applyDriveFileToSku
      tags:
        - Drive
      summary: Apply an image to a SKU
      description: |
        Copy a Drive image into a SKU's product images, the images pushed to Shopify and other
        channels.

        With `set_as_photo: true` (or when the SKU has no photo yet), the SKU's main photo is
        set to the image's stable public URL. Uploading a new version of the image later
        refreshes every SKU it was applied to.

        Returns `422` if the file is not an image.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sku_id
              properties:
                sku_id:
                  type: integer
                  description: Product ID (as returned by `GET /products`)
                set_as_photo:
                  type: boolean
                  default: false
                  description: Also make the image the SKU's main photo
      responses:
        '201':
          description: Image applied
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      sku_image:
                        type: object
                        properties:
                          id:
                            type: integer
                          sku_id:
                            type: integer
                          full_size_path:
                            type: string
                            nullable: true
                          thumbnail_path:
                            type: string
                            nullable: true
                      photo_set:
                        type: boolean
                        description: Whether the SKU's main photo was set to this image
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/files/{id}/public-image':
    post:
      operationId: enableDriveFilePublicImage
      tags:
        - Drive
      summary: Turn on the public image URL
      description: |
        Turn on the stable public URL for an image. The URL is returned as `public_image_url`
        on the file and keeps working across new versions.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      responses:
        '200':
          description: File with its public image URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive file.
                    properties:
                      id:
                        type: integer
                        example: 481
                      type:
                        type: string
                        enum:
                          - file
                      name:
                        type: string
                        example: STYLE123_BLK_01.jpg
                      folder_id:
                        type: integer
                        nullable: true
                        description: ID of the folder holding the file
                      extension:
                        type: string
                        nullable: true
                        example: jpg
                      mime_type:
                        type: string
                        nullable: true
                        example: image/jpeg
                      size_bytes:
                        type: integer
                        description: Size of the current version in bytes
                        example: 482113
                      is_restricted:
                        type: boolean
                        description: Restricted files are never visible to API tokens
                      is_image:
                        type: boolean
                      current_version:
                        allOf:
                          - type: object
                            description: One uploaded version of a Drive file.
                            properties:
                              id:
                                type: integer
                                example: 33
                              version_number:
                                type: integer
                                example: 2
                              size_bytes:
                                type: integer
                                example: 482113
                              mime_type:
                                type: string
                                nullable: true
                                example: image/jpeg
                              original_name:
                                type: string
                                nullable: true
                                description: File name as uploaded
                                example: STYLE123_BLK_01.jpg
                              status:
                                type: string
                                description: Upload status. Only `ready` versions can be downloaded.
                                example: ready
                              uploaded_by:
                                type: integer
                                nullable: true
                                description: ID of the user who uploaded the version
                              completed_at:
                                type: string
                                format: date-time
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                        nullable: true
                      thumbnail_url:
                        type: string
                        nullable: true
                        description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                      public_image_url:
                        type: string
                        nullable: true
                        description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                      expires_at:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expiry date of the document, if one is set'
                      expiry_notify_user_ids:
                        type: array
                        items:
                          type: integer
                        description: Users notified before the file expires
                      tags:
                        type: array
                        items:
                          type: object
                          description: A Drive tag.
                          properties:
                            id:
                              type: integer
                              example: 12
                            name:
                              type: string
                              description: 'Tag name (at most 50 characters, unique ignoring case)'
                              example: SS27
                            color:
                              type: string
                              enum:
                                - gray
                                - blue
                                - green
                                - yellow
                                - orange
                                - red
                                - purple
                                - pink
                              description: Tag color. Unknown colors are stored as `gray`.
                              example: green
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      deleted_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: Set while the file is in the trash
                      can_edit:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner can edit this file
                      is_starred:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner has starred this file
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/file/{id}/tags':
    put:
      operationId: setDriveFileTags
      tags:
        - Drive
      summary: Set file tags
      description: |
        Replace the tags on a file. Send an empty `tag_ids` array to remove every tag.
        Create tags first with `POST /file-cabinet/tags`.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - tag_ids
              properties:
                tag_ids:
                  type: array
                  items:
                    type: integer
                  description: The complete list of tag IDs the item should carry
      responses:
        '200':
          description: The item's tags
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      description: A Drive tag.
                      properties:
                        id:
                          type: integer
                          example: 12
                        name:
                          type: string
                          description: 'Tag name (at most 50 characters, unique ignoring case)'
                          example: SS27
                        color:
                          type: string
                          enum:
                            - gray
                            - blue
                            - green
                            - yellow
                            - orange
                            - red
                            - purple
                            - pink
                          description: Tag color. Unknown colors are stored as `gray`.
                          example: green
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /file-cabinet/uploads:
    post:
      operationId: initiateDriveUpload
      tags:
        - Drive
      summary: Start a large upload
      description: |
        Start a direct upload of up to 500 MB. Uploading takes three steps:

        1. Call this endpoint. It returns an `upload_url` and the `headers` to send.
        2. `PUT` the file's bytes to `upload_url` with exactly the returned `Content-Type`
           header and **no** `Authorization` header. The URL is valid for `expires_in` seconds.
        3. Call `POST /file-cabinet/uploads/{versionId}/complete` with the returned `version_id`.

        Send `folder_id` to create a new file, or `file_id` to upload a new version of an
        existing file.

        **Avoiding overwrites.** When uploading a new version, send an `If-Match` header with the
        ID of the version you edited (`current_version.id` when you read the file). If another
        version has become current since then, this call, or the later complete call, returns
        `412` with `code: stale_edit` and the version that is current now. Without `If-Match`,
        the last upload to finish wins.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: header
          name: If-Match
          required: false
          schema:
            type: string
          example: '"33"'
          description: |
            ID of the version you edited, optionally quoted (a `W/` prefix is ignored). Only
            valid with `file_id`. A non-numeric value, or `If-Match` without `file_id`, returns `422`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - size
              properties:
                name:
                  type: string
                  maxLength: 200
                  description: 'File name, including the extension'
                  example: STYLE123_BLK_01.jpg
                size:
                  type: integer
                  minimum: 1
                  description: File size in bytes (max 500 MB). Must match the uploaded bytes.
                mime_type:
                  type: string
                  maxLength: 150
                  nullable: true
                  example: image/jpeg
                folder_id:
                  type: integer
                  description: Folder to create the file in. Required unless `file_id` is sent.
                file_id:
                  type: integer
                  description: Existing file to add a new version to. Required unless `folder_id` is sent.
      responses:
        '201':
          description: Upload started
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      file_id:
                        type: integer
                      version_id:
                        type: integer
                        description: 'Pass to `POST /file-cabinet/uploads/{versionId}/complete`'
                      upload_url:
                        type: string
                        description: Pre-signed URL to PUT the bytes to
                      method:
                        type: string
                        enum:
                          - PUT
                      headers:
                        type: object
                        description: Headers to send with the PUT
                        example:
                          Content-Type: image/jpeg
                      expires_in:
                        type: integer
                        description: Seconds until `upload_url` expires
                        example: 900
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '412':
          description: |
            Stale edit: the request carried `If-Match`, and another version of the file became
            current after the version you edited.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Someone saved a newer version of this file after you opened it.
                  code:
                    type: string
                    enum:
                      - stale_edit
                  current_version:
                    allOf:
                      - type: object
                        description: One uploaded version of a Drive file.
                        properties:
                          id:
                            type: integer
                            example: 33
                          version_number:
                            type: integer
                            example: 2
                          size_bytes:
                            type: integer
                            example: 482113
                          mime_type:
                            type: string
                            nullable: true
                            example: image/jpeg
                          original_name:
                            type: string
                            nullable: true
                            description: File name as uploaded
                            example: STYLE123_BLK_01.jpg
                          status:
                            type: string
                            description: Upload status. Only `ready` versions can be downloaded.
                            example: ready
                          uploaded_by:
                            type: integer
                            nullable: true
                            description: ID of the user who uploaded the version
                          completed_at:
                            type: string
                            format: date-time
                            nullable: true
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                    nullable: true
                    description: The version that is current now
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/uploads/{versionId}/complete':
    post:
      operationId: completeDriveUpload
      tags:
        - Drive
      summary: Finish a large upload
      description: |
        Finish an upload started with `POST /file-cabinet/uploads`, after the bytes have been
        PUT to `upload_url`. Returns `422` if the uploaded size does not match the declared
        `size`.

        If the upload was started with `If-Match` and another version of the file has become
        current since then, returns `412` with `code: stale_edit` and the upload is marked failed.
        Start a new upload to retry.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: versionId
          required: true
          schema:
            type: integer
          description: Version ID returned by `POST /file-cabinet/uploads`
      responses:
        '200':
          description: File ready
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive file.
                    properties:
                      id:
                        type: integer
                        example: 481
                      type:
                        type: string
                        enum:
                          - file
                      name:
                        type: string
                        example: STYLE123_BLK_01.jpg
                      folder_id:
                        type: integer
                        nullable: true
                        description: ID of the folder holding the file
                      extension:
                        type: string
                        nullable: true
                        example: jpg
                      mime_type:
                        type: string
                        nullable: true
                        example: image/jpeg
                      size_bytes:
                        type: integer
                        description: Size of the current version in bytes
                        example: 482113
                      is_restricted:
                        type: boolean
                        description: Restricted files are never visible to API tokens
                      is_image:
                        type: boolean
                      current_version:
                        allOf:
                          - type: object
                            description: One uploaded version of a Drive file.
                            properties:
                              id:
                                type: integer
                                example: 33
                              version_number:
                                type: integer
                                example: 2
                              size_bytes:
                                type: integer
                                example: 482113
                              mime_type:
                                type: string
                                nullable: true
                                example: image/jpeg
                              original_name:
                                type: string
                                nullable: true
                                description: File name as uploaded
                                example: STYLE123_BLK_01.jpg
                              status:
                                type: string
                                description: Upload status. Only `ready` versions can be downloaded.
                                example: ready
                              uploaded_by:
                                type: integer
                                nullable: true
                                description: ID of the user who uploaded the version
                              completed_at:
                                type: string
                                format: date-time
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                        nullable: true
                      thumbnail_url:
                        type: string
                        nullable: true
                        description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                      public_image_url:
                        type: string
                        nullable: true
                        description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                      expires_at:
                        type: string
                        format: date
                        nullable: true
                        description: 'Expiry date of the document, if one is set'
                      expiry_notify_user_ids:
                        type: array
                        items:
                          type: integer
                        description: Users notified before the file expires
                      tags:
                        type: array
                        items:
                          type: object
                          description: A Drive tag.
                          properties:
                            id:
                              type: integer
                              example: 12
                            name:
                              type: string
                              description: 'Tag name (at most 50 characters, unique ignoring case)'
                              example: SS27
                            color:
                              type: string
                              enum:
                                - gray
                                - blue
                                - green
                                - yellow
                                - orange
                                - red
                                - purple
                                - pink
                              description: Tag color. Unknown colors are stored as `gray`.
                              example: green
                      created_by:
                        type: integer
                        nullable: true
                      updated_by:
                        type: integer
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                        nullable: true
                      updated_at:
                        type: string
                        format: date-time
                        nullable: true
                      deleted_at:
                        type: string
                        format: date-time
                        nullable: true
                        description: Set while the file is in the trash
                      can_edit:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner can edit this file
                      is_starred:
                        type: boolean
                        nullable: true
                        description: Whether the token's owner has starred this file
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '412':
          description: |
            Stale edit: the request carried `If-Match`, and another version of the file became
            current after the version you edited.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Someone saved a newer version of this file after you opened it.
                  code:
                    type: string
                    enum:
                      - stale_edit
                  current_version:
                    allOf:
                      - type: object
                        description: One uploaded version of a Drive file.
                        properties:
                          id:
                            type: integer
                            example: 33
                          version_number:
                            type: integer
                            example: 2
                          size_bytes:
                            type: integer
                            example: 482113
                          mime_type:
                            type: string
                            nullable: true
                            example: image/jpeg
                          original_name:
                            type: string
                            nullable: true
                            description: File name as uploaded
                            example: STYLE123_BLK_01.jpg
                          status:
                            type: string
                            description: Upload status. Only `ready` versions can be downloaded.
                            example: ready
                          uploaded_by:
                            type: integer
                            nullable: true
                            description: ID of the user who uploaded the version
                          completed_at:
                            type: string
                            format: date-time
                            nullable: true
                          created_at:
                            type: string
                            format: date-time
                            nullable: true
                    nullable: true
                    description: The version that is current now
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /file-cabinet/references:
    get:
      operationId: listDriveReferences
      tags:
        - Drive
      summary: List files attached to a record
      description: |
        List the Drive files attached to a record.

        Requires the `fileCabinet.read` permission. Records also need the matching read permission (for example `salesOrders.read`).
      security:
        - BearerAuth: []
      parameters:
        - in: query
          name: target_type
          required: true
          schema:
            type: string
            enum:
              - sales_order
              - deal
              - rfq_lot
              - sku
              - sku_image
              - customer
              - invoice
              - purchase_order
              - work_order
              - production_batch
          description: Record type
        - in: query
          name: target_id
          required: true
          schema:
            type: integer
          description: Record ID
      responses:
        '200':
          description: Attached files
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        reference_id:
                          type: integer
                          description: 'Pass to `DELETE /file-cabinet/references/{id}` to detach'
                        attached_at:
                          type: string
                          format: date-time
                          nullable: true
                        file:
                          type: object
                          description: A Drive file.
                          properties:
                            id:
                              type: integer
                              example: 481
                            type:
                              type: string
                              enum:
                                - file
                            name:
                              type: string
                              example: STYLE123_BLK_01.jpg
                            folder_id:
                              type: integer
                              nullable: true
                              description: ID of the folder holding the file
                            extension:
                              type: string
                              nullable: true
                              example: jpg
                            mime_type:
                              type: string
                              nullable: true
                              example: image/jpeg
                            size_bytes:
                              type: integer
                              description: Size of the current version in bytes
                              example: 482113
                            is_restricted:
                              type: boolean
                              description: Restricted files are never visible to API tokens
                            is_image:
                              type: boolean
                            current_version:
                              allOf:
                                - type: object
                                  description: One uploaded version of a Drive file.
                                  properties:
                                    id:
                                      type: integer
                                      example: 33
                                    version_number:
                                      type: integer
                                      example: 2
                                    size_bytes:
                                      type: integer
                                      example: 482113
                                    mime_type:
                                      type: string
                                      nullable: true
                                      example: image/jpeg
                                    original_name:
                                      type: string
                                      nullable: true
                                      description: File name as uploaded
                                      example: STYLE123_BLK_01.jpg
                                    status:
                                      type: string
                                      description: Upload status. Only `ready` versions can be downloaded.
                                      example: ready
                                    uploaded_by:
                                      type: integer
                                      nullable: true
                                      description: ID of the user who uploaded the version
                                    completed_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                                    created_at:
                                      type: string
                                      format: date-time
                                      nullable: true
                              nullable: true
                            thumbnail_url:
                              type: string
                              nullable: true
                              description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                            public_image_url:
                              type: string
                              nullable: true
                              description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                            expires_at:
                              type: string
                              format: date
                              nullable: true
                              description: 'Expiry date of the document, if one is set'
                            expiry_notify_user_ids:
                              type: array
                              items:
                                type: integer
                              description: Users notified before the file expires
                            tags:
                              type: array
                              items:
                                type: object
                                description: A Drive tag.
                                properties:
                                  id:
                                    type: integer
                                    example: 12
                                  name:
                                    type: string
                                    description: 'Tag name (at most 50 characters, unique ignoring case)'
                                    example: SS27
                                  color:
                                    type: string
                                    enum:
                                      - gray
                                      - blue
                                      - green
                                      - yellow
                                      - orange
                                      - red
                                      - purple
                                      - pink
                                    description: Tag color. Unknown colors are stored as `gray`.
                                    example: green
                            created_by:
                              type: integer
                              nullable: true
                            updated_by:
                              type: integer
                              nullable: true
                            created_at:
                              type: string
                              format: date-time
                              nullable: true
                            updated_at:
                              type: string
                              format: date-time
                              nullable: true
                            deleted_at:
                              type: string
                              format: date-time
                              nullable: true
                              description: Set while the file is in the trash
                            can_edit:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner can edit this file
                            is_starred:
                              type: boolean
                              nullable: true
                              description: Whether the token's owner has starred this file
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createDriveReferences
      tags:
        - Drive
      summary: Attach files to a record
      description: |
        Attach up to 100 Drive files to a sales order, deal, lot or SKU.

        Requires the `fileCabinet.write` permission. Sales orders also need `salesOrders.update`; deals need `deals.update`.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - target_type
                - target_id
                - file_ids
              properties:
                target_type:
                  type: string
                  enum:
                    - sales_order
                    - deal
                    - rfq_lot
                    - sku
                target_id:
                  type: integer
                file_ids:
                  type: array
                  minItems: 1
                  maxItems: 100
                  items:
                    type: integer
      responses:
        '201':
          description: Files attached
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      attached:
                        type: integer
                        description: Number of files attached
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/references/{id}':
    delete:
      operationId: deleteDriveReference
      tags:
        - Drive
      summary: Detach a file from a record
      description: |
        Remove an attachment. The file itself stays in Drive.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Reference ID (`reference_id` from `GET /file-cabinet/references`)
      responses:
        '200':
          description: Detached
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      detached:
                        type: boolean
                        example: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /file-cabinet/tags:
    get:
      operationId: listDriveTags
      tags:
        - Drive
      summary: List tags
      description: |
        List every Drive tag with how many items carry it.

        Requires the `fileCabinet.read` permission.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Tags
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      allOf:
                        - type: object
                          description: A Drive tag.
                          properties:
                            id:
                              type: integer
                              example: 12
                            name:
                              type: string
                              description: 'Tag name (at most 50 characters, unique ignoring case)'
                              example: SS27
                            color:
                              type: string
                              enum:
                                - gray
                                - blue
                                - green
                                - yellow
                                - orange
                                - red
                                - purple
                                - pink
                              description: Tag color. Unknown colors are stored as `gray`.
                              example: green
                        - type: object
                          properties:
                            usage_count:
                              type: integer
                              description: Number of folders and files carrying the tag
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    post:
      operationId: createDriveTag
      tags:
        - Drive
      summary: Create a tag
      description: |
        Create a tag. Returns `422` if a tag with the same name (ignoring case) exists.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 50
                  description: Tag name. Trimmed; must be unique ignoring case.
                  example: SS27
                color:
                  type: string
                  maxLength: 20
                  nullable: true
                  description: 'One of `gray`, `blue`, `green`, `yellow`, `orange`, `red`, `purple`, `pink`. Anything else becomes `gray`.'
                  example: green
      responses:
        '201':
          description: Tag created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive tag.
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        description: 'Tag name (at most 50 characters, unique ignoring case)'
                        example: SS27
                      color:
                        type: string
                        enum:
                          - gray
                          - blue
                          - green
                          - yellow
                          - orange
                          - red
                          - purple
                          - pink
                        description: Tag color. Unknown colors are stored as `gray`.
                        example: green
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/tags/{id}':
    patch:
      operationId: updateDriveTag
      tags:
        - Drive
      summary: Update a tag
      description: |
        Rename or recolor a tag. Returns `422` if the new name is taken.

        Requires the `fileCabinet.write` permission. Also requires `fileCabinet.manage`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Tag ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  maxLength: 50
                  description: Tag name. Trimmed; must be unique ignoring case.
                  example: SS27
                color:
                  type: string
                  maxLength: 20
                  nullable: true
                  description: 'One of `gray`, `blue`, `green`, `yellow`, `orange`, `red`, `purple`, `pink`. Anything else becomes `gray`.'
                  example: green
      responses:
        '200':
          description: Tag updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    description: A Drive tag.
                    properties:
                      id:
                        type: integer
                        example: 12
                      name:
                        type: string
                        description: 'Tag name (at most 50 characters, unique ignoring case)'
                        example: SS27
                      color:
                        type: string
                        enum:
                          - gray
                          - blue
                          - green
                          - yellow
                          - orange
                          - red
                          - purple
                          - pink
                        description: Tag color. Unknown colors are stored as `gray`.
                        example: green
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
    delete:
      operationId: deleteDriveTag
      tags:
        - Drive
      summary: Delete a tag
      description: |
        Delete a tag and remove it from every folder and file.

        Requires the `fileCabinet.write` permission. Also requires `fileCabinet.manage`.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Tag ID
      responses:
        '200':
          description: Tag deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      deleted:
                        type: boolean
                        example: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /file-cabinet/trash:
    get:
      operationId: listDriveTrash
      tags:
        - Drive
      summary: List the trash
      description: |
        List what the token's owner deleted, newest first (everyone's deletions, with
        `fileCabinet.manage`). Only the top item of each delete batch is listed: a deleted
        folder appears once, not once per item inside it.

        Items stay in the trash for 30 days, then are deleted forever. Restricted items and
        My Files are never listed.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Trash
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      description: |
                        A folder or file in the trash: the full `Folder` or `File` object (see `type`) plus where it
                        used to live and who deleted it. `can_edit` and `is_starred` are `null` on trash entries.
                      allOf:
                        - oneOf:
                            - type: object
                              description: A Drive folder.
                              properties:
                                id:
                                  type: integer
                                  example: 41
                                type:
                                  type: string
                                  enum:
                                    - folder
                                name:
                                  type: string
                                  example: SS27 Shoot
                                parent_id:
                                  type: integer
                                  nullable: true
                                  description: 'Parent folder ID, or `null` for a top-level folder'
                                is_restricted:
                                  type: boolean
                                  description: Restricted folders are never visible to API tokens
                                is_system:
                                  type: boolean
                                  description: 'System folders (for example the record folders that hold emailed documents) cannot be renamed, moved or deleted'
                                is_my_files:
                                  type: boolean
                                  description: 'Always `false` for API tokens, which only see the shared drive'
                                has_children:
                                  type: boolean
                                  nullable: true
                                  description: Whether the folder has visible sub-folders. Only set on folder listings.
                                tags:
                                  type: array
                                  items:
                                    type: object
                                    description: A Drive tag.
                                    properties:
                                      id:
                                        type: integer
                                        example: 12
                                      name:
                                        type: string
                                        description: 'Tag name (at most 50 characters, unique ignoring case)'
                                        example: SS27
                                      color:
                                        type: string
                                        enum:
                                          - gray
                                          - blue
                                          - green
                                          - yellow
                                          - orange
                                          - red
                                          - purple
                                          - pink
                                        description: Tag color. Unknown colors are stored as `gray`.
                                        example: green
                                created_by:
                                  type: integer
                                  nullable: true
                                  description: ID of the user who created the folder
                                created_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                updated_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                deleted_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                  description: Set while the folder is in the trash
                                can_edit:
                                  type: boolean
                                  nullable: true
                                  description: Whether the token's owner can edit this folder
                                is_starred:
                                  type: boolean
                                  nullable: true
                                  description: Whether the token's owner has starred this folder
                            - type: object
                              description: A Drive file.
                              properties:
                                id:
                                  type: integer
                                  example: 481
                                type:
                                  type: string
                                  enum:
                                    - file
                                name:
                                  type: string
                                  example: STYLE123_BLK_01.jpg
                                folder_id:
                                  type: integer
                                  nullable: true
                                  description: ID of the folder holding the file
                                extension:
                                  type: string
                                  nullable: true
                                  example: jpg
                                mime_type:
                                  type: string
                                  nullable: true
                                  example: image/jpeg
                                size_bytes:
                                  type: integer
                                  description: Size of the current version in bytes
                                  example: 482113
                                is_restricted:
                                  type: boolean
                                  description: Restricted files are never visible to API tokens
                                is_image:
                                  type: boolean
                                current_version:
                                  allOf:
                                    - type: object
                                      description: One uploaded version of a Drive file.
                                      properties:
                                        id:
                                          type: integer
                                          example: 33
                                        version_number:
                                          type: integer
                                          example: 2
                                        size_bytes:
                                          type: integer
                                          example: 482113
                                        mime_type:
                                          type: string
                                          nullable: true
                                          example: image/jpeg
                                        original_name:
                                          type: string
                                          nullable: true
                                          description: File name as uploaded
                                          example: STYLE123_BLK_01.jpg
                                        status:
                                          type: string
                                          description: Upload status. Only `ready` versions can be downloaded.
                                          example: ready
                                        uploaded_by:
                                          type: integer
                                          nullable: true
                                          description: ID of the user who uploaded the version
                                        completed_at:
                                          type: string
                                          format: date-time
                                          nullable: true
                                        created_at:
                                          type: string
                                          format: date-time
                                          nullable: true
                                  nullable: true
                                thumbnail_url:
                                  type: string
                                  nullable: true
                                  description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                                public_image_url:
                                  type: string
                                  nullable: true
                                  description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                                expires_at:
                                  type: string
                                  format: date
                                  nullable: true
                                  description: 'Expiry date of the document, if one is set'
                                expiry_notify_user_ids:
                                  type: array
                                  items:
                                    type: integer
                                  description: Users notified before the file expires
                                tags:
                                  type: array
                                  items:
                                    type: object
                                    description: A Drive tag.
                                    properties:
                                      id:
                                        type: integer
                                        example: 12
                                      name:
                                        type: string
                                        description: 'Tag name (at most 50 characters, unique ignoring case)'
                                        example: SS27
                                      color:
                                        type: string
                                        enum:
                                          - gray
                                          - blue
                                          - green
                                          - yellow
                                          - orange
                                          - red
                                          - purple
                                          - pink
                                        description: Tag color. Unknown colors are stored as `gray`.
                                        example: green
                                created_by:
                                  type: integer
                                  nullable: true
                                updated_by:
                                  type: integer
                                  nullable: true
                                created_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                updated_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                deleted_at:
                                  type: string
                                  format: date-time
                                  nullable: true
                                  description: Set while the file is in the trash
                                can_edit:
                                  type: boolean
                                  nullable: true
                                  description: Whether the token's owner can edit this file
                                is_starred:
                                  type: boolean
                                  nullable: true
                                  description: Whether the token's owner has starred this file
                        - type: object
                          properties:
                            deleted_by:
                              type: integer
                              nullable: true
                              description: ID of the user who deleted the item
                            trash_batch:
                              type: string
                              description: ID of the delete operation. A folder is deleted together with everything under it as one batch.
                              example: 5b0c9c1e-7a8f-4f43-9a52-0b7d0f6f2b11
                            original_location:
                              type: array
                              items:
                                type: string
                              description: 'Names of the folders the item was in, from the top level down'
                              example:
                                - Lookbooks
                                - SS27
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /file-cabinet/trash/restore:
    post:
      operationId: restoreDriveTrash
      tags:
        - Drive
      summary: Restore from the trash
      description: |
        Restore a trashed folder or file. The whole delete batch comes back: restoring a
        folder restores everything that was deleted with it.

        The item returns to its original folder, or to the deleter's My Files if that folder
        is gone. `location` says where it landed.

        Only the person who deleted the item, or a `fileCabinet.manage` owner, can restore it
        (`403` otherwise). An item not in the trash is `404`.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - type
                - id
              properties:
                type:
                  type: string
                  enum:
                    - folder
                    - file
                id:
                  type: integer
                  description: Folder or file ID
      responses:
        '200':
          description: Restored item
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    allOf:
                      - oneOf:
                          - type: object
                            description: A Drive folder.
                            properties:
                              id:
                                type: integer
                                example: 41
                              type:
                                type: string
                                enum:
                                  - folder
                              name:
                                type: string
                                example: SS27 Shoot
                              parent_id:
                                type: integer
                                nullable: true
                                description: 'Parent folder ID, or `null` for a top-level folder'
                              is_restricted:
                                type: boolean
                                description: Restricted folders are never visible to API tokens
                              is_system:
                                type: boolean
                                description: 'System folders (for example the record folders that hold emailed documents) cannot be renamed, moved or deleted'
                              is_my_files:
                                type: boolean
                                description: 'Always `false` for API tokens, which only see the shared drive'
                              has_children:
                                type: boolean
                                nullable: true
                                description: Whether the folder has visible sub-folders. Only set on folder listings.
                              tags:
                                type: array
                                items:
                                  type: object
                                  description: A Drive tag.
                                  properties:
                                    id:
                                      type: integer
                                      example: 12
                                    name:
                                      type: string
                                      description: 'Tag name (at most 50 characters, unique ignoring case)'
                                      example: SS27
                                    color:
                                      type: string
                                      enum:
                                        - gray
                                        - blue
                                        - green
                                        - yellow
                                        - orange
                                        - red
                                        - purple
                                        - pink
                                      description: Tag color. Unknown colors are stored as `gray`.
                                      example: green
                              created_by:
                                type: integer
                                nullable: true
                                description: ID of the user who created the folder
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                              updated_at:
                                type: string
                                format: date-time
                                nullable: true
                              deleted_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: Set while the folder is in the trash
                              can_edit:
                                type: boolean
                                nullable: true
                                description: Whether the token's owner can edit this folder
                              is_starred:
                                type: boolean
                                nullable: true
                                description: Whether the token's owner has starred this folder
                          - type: object
                            description: A Drive file.
                            properties:
                              id:
                                type: integer
                                example: 481
                              type:
                                type: string
                                enum:
                                  - file
                              name:
                                type: string
                                example: STYLE123_BLK_01.jpg
                              folder_id:
                                type: integer
                                nullable: true
                                description: ID of the folder holding the file
                              extension:
                                type: string
                                nullable: true
                                example: jpg
                              mime_type:
                                type: string
                                nullable: true
                                example: image/jpeg
                              size_bytes:
                                type: integer
                                description: Size of the current version in bytes
                                example: 482113
                              is_restricted:
                                type: boolean
                                description: Restricted files are never visible to API tokens
                              is_image:
                                type: boolean
                              current_version:
                                allOf:
                                  - type: object
                                    description: One uploaded version of a Drive file.
                                    properties:
                                      id:
                                        type: integer
                                        example: 33
                                      version_number:
                                        type: integer
                                        example: 2
                                      size_bytes:
                                        type: integer
                                        example: 482113
                                      mime_type:
                                        type: string
                                        nullable: true
                                        example: image/jpeg
                                      original_name:
                                        type: string
                                        nullable: true
                                        description: File name as uploaded
                                        example: STYLE123_BLK_01.jpg
                                      status:
                                        type: string
                                        description: Upload status. Only `ready` versions can be downloaded.
                                        example: ready
                                      uploaded_by:
                                        type: integer
                                        nullable: true
                                        description: ID of the user who uploaded the version
                                      completed_at:
                                        type: string
                                        format: date-time
                                        nullable: true
                                      created_at:
                                        type: string
                                        format: date-time
                                        nullable: true
                                nullable: true
                              thumbnail_url:
                                type: string
                                nullable: true
                                description: 'URL of a 400px JPEG thumbnail, for images. `null` until the thumbnail is generated.'
                              public_image_url:
                                type: string
                                nullable: true
                                description: 'Stable public URL of the image, when the public image URL has been turned on (see `POST /file-cabinet/files/{id}/public-image`)'
                              expires_at:
                                type: string
                                format: date
                                nullable: true
                                description: 'Expiry date of the document, if one is set'
                              expiry_notify_user_ids:
                                type: array
                                items:
                                  type: integer
                                description: Users notified before the file expires
                              tags:
                                type: array
                                items:
                                  type: object
                                  description: A Drive tag.
                                  properties:
                                    id:
                                      type: integer
                                      example: 12
                                    name:
                                      type: string
                                      description: 'Tag name (at most 50 characters, unique ignoring case)'
                                      example: SS27
                                    color:
                                      type: string
                                      enum:
                                        - gray
                                        - blue
                                        - green
                                        - yellow
                                        - orange
                                        - red
                                        - purple
                                        - pink
                                      description: Tag color. Unknown colors are stored as `gray`.
                                      example: green
                              created_by:
                                type: integer
                                nullable: true
                              updated_by:
                                type: integer
                                nullable: true
                              created_at:
                                type: string
                                format: date-time
                                nullable: true
                              updated_at:
                                type: string
                                format: date-time
                                nullable: true
                              deleted_at:
                                type: string
                                format: date-time
                                nullable: true
                                description: Set while the file is in the trash
                              can_edit:
                                type: boolean
                                nullable: true
                                description: Whether the token's owner can edit this file
                              is_starred:
                                type: boolean
                                nullable: true
                                description: Whether the token's owner has starred this file
                      - type: object
                        properties:
                          location:
                            type: array
                            items:
                              type: string
                            description: 'Names of the folders the item is now in, from the top level down'
                            example:
                              - Lookbooks
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/trash/folder/{id}':
    delete:
      operationId: purgeDriveTrashFolder
      tags:
        - Drive
      summary: Delete a folder forever
      description: |
        Permanently delete a trashed folder and everything deleted with it, including the stored bytes. This
        cannot be undone.

        Only the person who deleted the item, or a `fileCabinet.manage` owner, can do this
        (`403` otherwise). An item not in the trash is `404`. Returns `422` while a file is
        a product image on a SKU.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: Folder ID
      responses:
        '200':
          description: Deleted forever
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      purged:
                        type: boolean
                        example: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  '/file-cabinet/trash/file/{id}':
    delete:
      operationId: purgeDriveTrashFile
      tags:
        - Drive
      summary: Delete a file forever
      description: |
        Permanently delete a trashed file, including the stored bytes. This
        cannot be undone.

        Only the person who deleted the item, or a `fileCabinet.manage` owner, can do this
        (`403` otherwise). An item not in the trash is `404`. Returns `422` while a file is
        a product image on a SKU.

        Requires the `fileCabinet.write` permission.
      security:
        - BearerAuth: []
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
          description: File ID
      responses:
        '200':
          description: Deleted forever
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      purged:
                        type: boolean
                        example: true
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '403':
          description: The token's owner lacks the required Drive permission
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '404':
          description: Not found or not visible to API tokens
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
tags:
  - name: Products
    description: Get and manage products
  - name: Pricing
    description: 'Manage price schedules, levels, and customizations'
  - name: BOMs
    description: Manage Bills of Materials (BOMs)
  - name: Labels
    description: Label rendering via Labelary ZPL service
  - name: Companies
    description: Manage business accounts and their associated data
  - name: Contacts
    description: Manage contact information for individuals
  - name: Suppliers
    description: Manage suppliers (factories) — vendors used on purchase orders
  - name: Supplier SKUs
    description: Manage per-supplier SKU and unit-cost overrides for products
  - name: Locations
    description: Manage warehouses and locations
  - name: Inventory
    description: Get and adjust product stock levels
  - name: Lots
    description: 'Create, update, and delete product lots (batches)'
  - name: Transfer Orders
    description: Manage transfer orders
  - name: Fulfillment Orders
    description: Manage fulfillment orders and picklists
  - name: Freight
    description: 'Freightview LTL freight — quotes, booking and documents for fulfillment orders'
  - name: Fulfillment Priority Lists
    description: Configure fulfillment routing priority lists
  - name: Purchase Orders
    description: Get and modify purchase orders
  - name: Supplier Portal
    description: Read a supplier's response to a purchase order and control the one-click portal link
  - name: Receiving Reports
    description: Manage receiving reports
  - name: Defective Reports
    description: Record and list defective units received on purchase orders (Inventory > Defectives)
  - name: Payment Obligations
    description: Manage payment obligations for purchase orders
  - name: Sales Orders
    description: Manage sales orders and sales order shipments
  - name: Purgatory
    description: Inspect and resolve non-posted sales orders in the purgatory staging workflow
  - name: PickFlow Warehouse
    description: 'Warehouse-floor lookups for PickFlow — barcode resolution, bin and product stock, bin search, and receivables'
  - name: PickFlow Shipping
    description: 'Provider-agnostic shipping rates, services, packages, and label purchase for PickFlow'
  - name: Cycle Counts
    description: 'Create, drive, and post PickFlow cycle counts — batches, per-warehouse sessions, and CSV import/export'
  - name: Print Stations
    description: List paired print stations and enqueue print jobs to them
  - name: Invoices
    description: Get and manage invoices
  - name: Work Orders
    description: 'Manage work orders — production lifecycle, steps, materials, links, shipments, and comments'
  - name: Production Batches
    description: Group and manage work orders as production batches
  - name: Bills
    description: 'Accounts payable bill management, payments, attachments, allocations, and variance'
  - name: Prepayments
    description: Manage vendor prepayments and applications
  - name: Vendor Credits
    description: Manage vendor credits and applications
  - name: Vendor Returns
    description: Manage vendor returns and credit generation
  - name: Customer Returns
    description: 'Manage customer returns (sales returns), receiving, and restock behavior'
  - name: Stock Snapshot
    description: Point-in-time stock snapshots with export support
  - name: Consumption
    description: Consumption reports and exports
  - name: Inventory Aging
    description: Cost-layer-based inventory aging reports
  - name: Bills Reports
    description: Accounts payable bills aging reports
  - name: Forecast
    description: Materialized forecast data
  - name: Reports
    description: 'Close the books, inventory discrepancy, transaction COGS, and EDI reports'
  - name: Tags
    description: Add/remove tags across various resources
  - name: Custom Fields
    description: Get and set custom fields across various resources
  - name: Approvals
    description: 'Approval rules that hold sales orders and supplier POs for sign-off, and their approver templates'
  - name: Currency
    description: 'Currency configuration, exchange rates, and conversion'
  - name: Drive
    description: |
      Browse, upload, tag and manage files in your Luminous Drive. An API token sees the shared
      drive only, never My Files or restricted folders and files. Every write and download made
      through the API is recorded in the file's activity log (`GET /file-cabinet/files/{id}/activity`)
      with `actor_kind: api_token`.
  - name: Integration Mappings
    description: Manage integration mappings for external systems
  - name: Integration Field Mappings
    description: Manage field-level mappings between Luminous and external systems
  - name: Automations
    description: 'Create, test, and inspect automation rules and their runs'
