Function pack

  • Finds the optimal way to pack a shipment.

    Parameters

    • body: {
          allowableOverhang?: number;
          boxTypeChoiceGoal?: "lowest-cost" | "most-items";
          boxTypeChoiceLookahead?: number;
          boxTypeChoiceLookback?: number;
          boxTypeChoiceStyle?: "actual" | "estimated";
          boxTypeDefaults?: {
              centerOfMass?: {
                  x?: number;
                  y?: number;
                  z?: number;
              };
              dimensions: {
                  x?: number;
                  y?: number;
                  z?: number;
              };
              itemSetsPerBoxMax?: number;
              itemsInlineMax?: number[];
              itemsPerBoxMax?: number;
              name?: string;
              price?: number;
              rateTable?: {
                  basePrice?: number;
                  carrier?: string;
                  dimFactor?: number;
                  priceIncreaseRate?: number;
                  rates?: number[];
                  service?: string;
                  weights?: number[];
                  zone?: string;
              };
              refId?: number;
              reservedSpace?: number;
              weightMax: number;
              weightTare?: number;
          };
          boxTypeGenerators?: {
              boxTypeDefaults?: {
                  centerOfMass?: {
                      x?: number;
                      y?: number;
                      z?: number;
                  };
                  dimensions: {
                      x?: number;
                      y?: number;
                      z?: number;
                  };
                  itemSetsPerBoxMax?: number;
                  itemsInlineMax?: number[];
                  itemsPerBoxMax?: number;
                  name?: string;
                  price?: number;
                  rateTable?: {
                      basePrice?: number;
                      carrier?: string;
                      dimFactor?: number;
                      priceIncreaseRate?: number;
                      rates?: number[];
                      service?: string;
                      weights?: number[];
                      zone?: string;
                  };
                  refId?: number;
                  reservedSpace?: number;
                  weightMax: number;
                  weightTare?: number;
              };
              operation?: "cartesian" | "pack-as-is";
              options?: {
                  limits?: {
                      max?: number;
                      metric?: "longest-dimension" | "shortest-dimension" | "volume" | "surface-area" | "surface-area-rsc" | "middle-dimension" | "length-plus-girth" | "girth";
                      min?: number;
                  }[];
                  noTrimToMaxExtent?: unknown;
                  priceComponents?: {
                      key?: string;
                      metric?: "longest-dimension" | "shortest-dimension" | "volume" | "surface-area" | "surface-area-rsc" | "middle-dimension" | "length-plus-girth" | "girth";
                      prices?: (...)[];
                      thresholds?: (...)[];
                  }[];
                  xList?: number[];
                  xRange?: {
                      deriveFromItems?: boolean;
                      fitForFirstItem?: boolean;
                      max?: number;
                      min?: number;
                      step?: number;
                  };
                  yList?: number[];
                  yRange?: {
                      deriveFromItems?: boolean;
                      fitForFirstItem?: boolean;
                      max?: number;
                      min?: number;
                      step?: number;
                  };
                  zList?: number[];
                  zRange?: {
                      deriveFromItems?: boolean;
                      fitForFirstItem?: boolean;
                      max?: number;
                      min?: number;
                      step?: number;
                  };
              };
          }[];
          boxTypeSets?: ("usps" | "fedex" | "pallet" | "customer")[];
          boxTypes?: {
              centerOfMass?: {
                  x?: number;
                  y?: number;
                  z?: number;
              };
              dimensions: {
                  x?: number;
                  y?: number;
                  z?: number;
              };
              itemSetsPerBoxMax?: number;
              itemsInlineMax?: number[];
              itemsPerBoxMax?: number;
              name?: string;
              price?: number;
              rateTable?: {
                  basePrice?: number;
                  carrier?: string;
                  dimFactor?: number;
                  priceIncreaseRate?: number;
                  rates?: number[];
                  service?: string;
                  weights?: number[];
                  zone?: string;
              };
              refId?: number;
              reservedSpace?: number;
              weightMax: number;
              weightTare?: number;
          }[];
          boxes?: ({
              centerOfMass?: {
                  x?: number;
                  y?: number;
                  z?: number;
              };
              dimensions: {
                  x?: number;
                  y?: number;
                  z?: number;
              };
              itemSetsPerBoxMax?: number;
              itemsInlineMax?: number[];
              itemsPerBoxMax?: number;
              name?: string;
              price?: number;
              rateTable?: {
                  basePrice?: number;
                  carrier?: string;
                  dimFactor?: number;
                  priceIncreaseRate?: number;
                  rates?: number[];
                  service?: string;
                  weights?: number[];
                  zone?: string;
              };
              refId?: number;
              reservedSpace?: number;
              weightMax: number;
              weightTare?: number;
          } & {
              boxType?: {
                  centerOfMass?: {
                      x?: number;
                      y?: number;
                      z?: number;
                  };
                  dimensions: {
                      x?: number;
                      y?: number;
                      z?: number;
                  };
                  itemSetsPerBoxMax?: number;
                  itemsInlineMax?: number[];
                  itemsPerBoxMax?: number;
                  name?: string;
                  price?: number;
                  rateTable?: {
                      basePrice?: number;
                      carrier?: string;
                      dimFactor?: number;
                      priceIncreaseRate?: number;
                      rates?: (...)[];
                      service?: string;
                      weights?: (...)[];
                      zone?: string;
                  };
                  refId?: number;
                  reservedSpace?: number;
                  weightMax: number;
                  weightTare?: number;
              };
              centerOfMassString?: string;
              depthOrder?: number[];
              depthOrderString?: string;
              dimensionalWeight?: number;
              dimensionalWeightUsed?: boolean;
              id?: number;
              items?: {
                  item?: {
                      centerOfMass?: ...;
                      color?: ...;
                      dimensions: ...;
                      name?: ...;
                      refId?: ...;
                      sequence?: ...;
                      virtual?: ...;
                      weight: ...;
                  } & {
                      deltaCost?: ...;
                      dimensionSet?: ...;
                      groupPackParent?: ...;
                      index?: ...;
                      message?: ...;
                      origin?: ...;
                      quantity?: ...;
                      uniqueId?: ...;
                      unitOfMeasure?: ...;
                  };
              }[];
              lenItems?: number;
              subspace?: {
                  originInParent?: {
                      x?: number;
                      y?: number;
                      z?: number;
                  };
                  parentBoxIndex?: number;
                  parentItemIndex?: number;
              };
              svg?: string;
              volumeMax?: number;
              volumeNet?: number;
              volumeRemaining?: number;
              volumeReserved?: number;
              volumeUsed?: number;
              volumeUtilization?: number;
              weightNet?: number;
              weightRemaining?: number;
              weightUsed?: number;
              weightUtilization?: number;
          })[];
          boxesMax?: number;
          boxesPerItemSetMax?: number;
          boxesPerSequenceMax?: number;
          cohortMax?: number;
          cohortPacking?: boolean;
          coordOrder?: number[];
          corners?: boolean;
          eye?: {
              x?: number;
              y?: number;
              z?: number;
          };
          generatedBoxTypesMax?: number;
          imageFormat?: "svg" | "png";
          imgSize?: number;
          includeImages?: boolean;
          includeScripts?: boolean;
          interlock?: boolean;
          itemInitialOrientationBestForBox?: boolean;
          itemInitialOrientationPreferred?: boolean;
          itemOrientationSearchDepth?: number;
          itemSets?: ({
              centerOfMass?: {
                  x?: number;
                  y?: number;
                  z?: number;
              };
              color?: string;
              dimensions: {
                  x?: number;
                  y?: number;
                  z?: number;
              };
              name?: string;
              refId?: number;
              sequence?: string;
              virtual?: boolean;
              weight: number;
          } & {
              dimensionSets?: {
                  axisMultipliers?: {
                      x?: (...) | (...);
                      y?: (...) | (...);
                      z?: (...) | (...);
                  };
                  dimensions?: {
                      x?: (...) | (...);
                      y?: (...) | (...);
                      z?: (...) | (...);
                  };
                  quantityDivisor?: number;
                  unitOfMeasure?: string;
                  weight?: number;
              }[];
              quantity?: number;
          } & {
              quantity: unknown;
          })[];
          itemSetsPerBoxMax?: number;
          itemSort?: "default" | "largest-box-needed" | "largest-girth" | "largest-length-plus-girth" | "longest-dimension" | "shortest-dimension" | "largest-cross-section" | "set-volume" | "density" | "weight" | "combined" | "all";
          itemSortDualDirection?: boolean;
          itemSortReverse?: boolean;
          itemsInlineMax?: number[];
          itemsPerBoxMax?: number;
          key?: string;
          layFlat?: boolean;
          maxSequenceDistance?: number;
          n?: number;
          orderId?: string;
          packOrigin?: {
              x?: number;
              y?: number;
              z?: number;
          };
          placementStyle?: "default" | "corner" | "wedge" | "mound" | "orb";
          random?: boolean;
          randomMaxDimension?: number;
          randomMaxQuantity?: number;
          randomMaxWeight?: number;
          requestId?: string;
          reservedSpace?: number;
          rules?: {
              itemMatch?: {
                  all?: boolean;
                  expression?: string;
                  expressions?: string[];
                  negate?: boolean;
                  property?: "name" | "sequence";
              };
              itemRefId?: number;
              itemSequence?: string;
              operation: "pack-as-is" | "exclude" | "exclude-all" | "irregular" | "lock-orientation" | "internal-space" | "alternate-dimensions" | "fragile";
              options?: {
                  [key: string]: unknown;
              };
              parameters?: string[];
              targetBoxRefIds?: number[];
              targetItemRefIds?: number[];
              targetItemSequences?: string[];
          }[];
          seed?: boolean;
          seedValue?: number;
          sequenceHeatMap?: boolean;
          sequenceSort?: boolean;
          template?: "demo.tmpl" | "shipapp.tmpl" | "boat.tmpl";
          timeout?: number;
          usableSpace?: number;
          valueTiebreaker?: "weight" | "volume";
          zone?: number;
      }

      Packing configuration.

      • Optional allowableOverhang?: number

        Description

        The amount an item can overhang lower items that it is placed upon. The units are whatever units the box and item dimensions are given in. By convention, inches.

        Default

        -1
        
      • Optional boxTypeChoiceGoal?: "lowest-cost" | "most-items"

        Description

        The objective to evaluate boxTypeChoices by. 'lowest-cost' minimizes price or volume cost of boxTypes selected, 'most-items' maximizes item count per box opened, i.e., fewest total boxes used.

        Default

        lowest-cost
        @enum {string}
      • Optional boxTypeChoiceLookahead?: number

        Description

        When selecting the next available boxType, we must consider how far to look ahead.

        Consider we have 8 items of identical dimensions, and two flat rate boxTypes. It is found that Box A can fit 6 items, and costs $12. Box B can fit 4 items, and costs $10.

        If we consider only the next box, i.e., 'boxTypeChoiceLookahead' set to 0, we would select Box A. It costs $2 per item, whereas Box B is $2.50 per item. Box A is opened, 6 items are placed inside, and now 2 remain. To pack the last 2, Box B would be selected, as 2 items for $10 is $5 per item, and Box A's $12 is $6 per item.

        Alternatively, if 'boxTypeChoiceLookahead' is set to 1, the boxType that provides the lowest cost per item including the lookahead boxType(s) would be selected. In this case, we find we need 2 of Box B, for $20 total, to fit all 8 items, or $2.50 per item, and would need 1 of Box A and 1 of Box B if Box A is selected first, for $22 total or $2.75 per item. Box B would be used.

        Please note that 'boxTypeChoiceLookahead', especially when combined with the 'actual' 'boxTypeChoiceStyle' can have significant performance impacts. 0 is recommended for real-time use cases.

        Default

        0
        
      • Optional boxTypeChoiceLookback?: number

        Description

        Control the ability for partially-filled boxes to allow packing of later-sorted items. A value of null or -1 means unlimited lookback is permitted, i.e., every box can be used to pack any allowable item that fits regardless of its pack sequence, and all boxes will remain "opened" or available for packing until the last item in the pack sequence is attempted. A value of 0 means lookback is not allowed, and as soon as the next item in the pack sequence does not fit into a partially filled box, that box is "closed" or locked and will not permit any additional items (i.e., out-of-sequence items) to be packed in it.

        Default

        -1
        
      • Optional boxTypeChoiceStyle?: "actual" | "estimated"

        Description

        Defines how available boxTypes are selected when a new box must be created to pack additional items. The 'estimated' style uses 'usableSpace' to estimate how quickly each valid boxType will be filled by both weight and volume, and estimated cost is calculated. 'actual' attempts real placement of subsequent items in each available boxType and selects the one with the lowest actual cost. 'actual' is much slower than 'estimated', but will often return superior cost optimizations.

        Default

        actual
        @enum {string}
      • Optional boxTypeDefaults?: {
            centerOfMass?: {
                x?: number;
                y?: number;
                z?: number;
            };
            dimensions: {
                x?: number;
                y?: number;
                z?: number;
            };
            itemSetsPerBoxMax?: number;
            itemsInlineMax?: number[];
            itemsPerBoxMax?: number;
            name?: string;
            price?: number;
            rateTable?: {
                basePrice?: number;
                carrier?: string;
                dimFactor?: number;
                priceIncreaseRate?: number;
                rates?: number[];
                service?: string;
                weights?: number[];
                zone?: string;
            };
            refId?: number;
            reservedSpace?: number;
            weightMax: number;
            weightTare?: number;
        }

        Description

        default attributes for all "boxTypes", to be overridden by any individual "boxType" attributes specified.

        Example

        {
        * "weightMax": 50,
        * "rateTable": {
        * "dimFactor": 166
        * }
        * }
        • Optional centerOfMass?: {
              x?: number;
              y?: number;
              z?: number;
          }

          Description

          the coordinates of the center of mass of the box.

          • Optional x?: number

            Description

            x coordinate, used as height.

            Default

            0
            
          • Optional y?: number

            Description

            y coordinate, used as width.

            Default

            0
            
          • Optional z?: number

            Description

            z coordinate, used as length.

            Default

            0
            
        • dimensions: {
              x?: number;
              y?: number;
              z?: number;
          }

          Description

          the [height,length,width] of the box.

          • Optional x?: number

            Description

            x coordinate, used as height.

            Default

            0
            
          • Optional y?: number

            Description

            y coordinate, used as width.

            Default

            0
            
          • Optional z?: number

            Description

            z coordinate, used as length.

            Default

            0
            
        • Optional itemSetsPerBoxMax?: number

          Description

          The maximum quantity of unique 'item.refId' values that a single box can contain. The default setting of 0, a negative number, and null are all equivalent and indicate no maximum limit, overriding top-level 'itemSetsPerBoxMax' settings.

          Default

          0
          
        • Optional itemsInlineMax?: number[]

          Description

          Limit the item count that can share a placement on a specific line parallel to the placement axis, e.g., '[1,2,1]' means items can be placed 1 high, 2 wide, and 1 deep within the box. A value of '0' is equivalent to no limit along that axis.

          Example

          [
          1,
          2,
          1
          ]
        • Optional itemsPerBoxMax?: number

          Description

          The maximum quantity of discrete items that a single box can contain. The default setting of 0, a negative number, and null are all equivalent and indicate no maximum limit, overriding top-level 'itemsPerBoxMax'.

          Default

          0
          
        • Optional name?: string

          Description

          name for the type of box.

        • Optional price?: number

          Description

          Fixed price of the container, in whole units of currency, default USD cents. This can represent the cost of a flat rate carton, the cost of the actual carton materials, or it can include any other flat fees that may need to be added on a per-carton basis, such as handling, accessorial surchages, oversize fees, etc. This value is added to any rate table rates defined for the carton.

        • Optional rateTable?: {
              basePrice?: number;
              carrier?: string;
              dimFactor?: number;
              priceIncreaseRate?: number;
              rates?: number[];
              service?: string;
              weights?: number[];
              zone?: string;
          }

          Description

          An optional rate table definition for improved carton selection and pricing optimization. Defaults are included using retail rates for FedEx and UPS if carrier and service is provided, but optimization can be improved with more data passed in a carton's specific rate table. Methods are

          1. Provide carrier, service, and zone.
          2. Provide all acceptable weights and prices to use for the carton, similar to actual carrier rate tables.
          3. Provide the coefficients required for a simple linear weight-dependent pricing model.

          • Optional basePrice?: number

            Description

            The basePrice can be found by estimating the lowest weight-based rate available for a given service, in the example above, solving for basePrice for a $10, 1lb package with the already-solved priceIncreaseRate yields

            $10 = $5/lb * 1lb + basePrice
            $10 = $5 + basePrice
            basePrice = $5

          • Optional carrier?: string

            Description

            carrier name for rate table to use

          • Optional dimFactor?: number

            Description

            This is the Dimensional Weight divisor. It is given in units of volume per unit weight, e.g., the standard of "139" represents 139 cubic inches per pound, and is used to convert the total volume of a carton into a functional minimum weight to be used when rating the carton. E.g., a carton with dimensions 10" x 10" x 13.9" would yield a volume of 1390 cubic inches. This yields

            cartonEffectiveMinimumWeight = 1390in³ / 139in³/lb
            cartonEffectiveMinimumWeight = 10lbs
            . To disable when using a preset carrier and zone, set to -1 or a very big number.

          • Optional priceIncreaseRate?: number

            Description

            Instead of providing the full rate table, you can list a carton "basePrice" and a carton "priceIncreaseRate". These two values will be used in a simple linear model to guess carton price, i.e.,

            cartonPrice = priceIncreaseRate * cartonWeight + basePrice
            Oftentimes, this will be enough to get accurate carton selections without needing to send complete customer-based rates. It's worth considering, as the prices are only estimates to be used in carton selection, with final rating of cartons happening outside of paccurate. This is the predicted rate of increase for a weight-based pricing model. The simplest way to find a serviceable value is to take
            priceIncreaseRate = (maximumPrice - minimumPrice)/(maximumWeight - minimumWeight)
            In the example above, this would yield
            priceIncreaseRate = ($20-$10)/(3lbs-1lb)
            priceIncreaseRate = $10/2lbs
            priceIncreaseRate = $5/lb

          • Optional rates?: number[]

            Description

            list of prices to use for the weight that corresponds to its index, e.g., [10, 15, 20] would be $10 for 1lb, $15 for 2lbs, $20 for 3lbs.

          • Optional service?: string

            Description

            service name for rate table to use

          • Optional weights?: number[]

            Description

            list of weights to use for the rate that corresponds to its index, e.g., [1, 2, 3] would mean 1lb for the minimum rate ($10), 2lbs for the second rate ($15), and 3lbs for the highest rate ($20). Note that if the highest value from this list is less than the weightMax of the carton, all carton weights exceeding the maximum from this list up to the carton weightMax will not pro-rate but will be estimated at the maximum value in the rate table.

          • Optional zone?: string

            Description

            zone of rate table to use

        • Optional refId?: number

          Description

          box type reference identifier passed backed from request.

        • Optional reservedSpace?: number

          Description

          space in boxes that is reserved, i.e., for packing material, overriding top-level 'reservedSpace'.

          Default

          0
          

          Example

          0.2
          
        • weightMax: number

          Description

          maximum allowable gross weight for the box, i.e., all packed item weights plus the weightTare.

        • Optional weightTare?: number

          Description

          weight of the container when empty or otherwise unladen, i.e., of the box itself.

          Default

          0
          
      • Optional boxTypeGenerators?: {
            boxTypeDefaults?: {
                centerOfMass?: {
                    x?: number;
                    y?: number;
                    z?: number;
                };
                dimensions: {
                    x?: number;
                    y?: number;
                    z?: number;
                };
                itemSetsPerBoxMax?: number;
                itemsInlineMax?: number[];
                itemsPerBoxMax?: number;
                name?: string;
                price?: number;
                rateTable?: {
                    basePrice?: number;
                    carrier?: string;
                    dimFactor?: number;
                    priceIncreaseRate?: number;
                    rates?: number[];
                    service?: string;
                    weights?: number[];
                    zone?: string;
                };
                refId?: number;
                reservedSpace?: number;
                weightMax: number;
                weightTare?: number;
            };
            operation?: "cartesian" | "pack-as-is";
            options?: {
                limits?: {
                    max?: number;
                    metric?: "longest-dimension" | "shortest-dimension" | "volume" | "surface-area" | "surface-area-rsc" | "middle-dimension" | "length-plus-girth" | "girth";
                    min?: number;
                }[];
                noTrimToMaxExtent?: unknown;
                priceComponents?: {
                    key?: string;
                    metric?: "longest-dimension" | "shortest-dimension" | "volume" | "surface-area" | "surface-area-rsc" | "middle-dimension" | "length-plus-girth" | "girth";
                    prices?: (...)[];
                    thresholds?: (...)[];
                }[];
                xList?: number[];
                xRange?: {
                    deriveFromItems?: boolean;
                    fitForFirstItem?: boolean;
                    max?: number;
                    min?: number;
                    step?: number;
                };
                yList?: number[];
                yRange?: {
                    deriveFromItems?: boolean;
                    fitForFirstItem?: boolean;
                    max?: number;
                    min?: number;
                    step?: number;
                };
                zList?: number[];
                zRange?: {
                    deriveFromItems?: boolean;
                    fitForFirstItem?: boolean;
                    max?: number;
                    min?: number;
                    step?: number;
                };
            };
        }[]

        Description

        list of dynamic boxTypeGenerators to use, in combination with boxTypes

      • Optional boxTypeSets?: ("usps" | "fedex" | "pallet" | "customer")[]

        Description

        predefined box types to be used, separated by commas. Will be overridden by boxTypes. Acceptable values are

        • "fedex"--FedEx OneRate
        • "usps"--USPS Priority Flat Rate
        • "pallet"--full-, half-, and quarter-sized 48"x40" pallets.

          Example

          []
          
      • Optional boxTypes?: {
            centerOfMass?: {
                x?: number;
                y?: number;
                z?: number;
            };
            dimensions: {
                x?: number;
                y?: number;
                z?: number;
            };
            itemSetsPerBoxMax?: number;
            itemsInlineMax?: number[];
            itemsPerBoxMax?: number;
            name?: string;
            price?: number;
            rateTable?: {
                basePrice?: number;
                carrier?: string;
                dimFactor?: number;
                priceIncreaseRate?: number;
                rates?: number[];
                service?: string;
                weights?: number[];
                zone?: string;
            };
            refId?: number;
            reservedSpace?: number;
            weightMax: number;
            weightTare?: number;
        }[]

        Description

        box type definitions for packing, will override boxTypeSets defined.

      • Optional boxes?: ({
            centerOfMass?: {
                x?: number;
                y?: number;
                z?: number;
            };
            dimensions: {
                x?: number;
                y?: number;
                z?: number;
            };
            itemSetsPerBoxMax?: number;
            itemsInlineMax?: number[];
            itemsPerBoxMax?: number;
            name?: string;
            price?: number;
            rateTable?: {
                basePrice?: number;
                carrier?: string;
                dimFactor?: number;
                priceIncreaseRate?: number;
                rates?: number[];
                service?: string;
                weights?: number[];
                zone?: string;
            };
            refId?: number;
            reservedSpace?: number;
            weightMax: number;
            weightTare?: number;
        } & {
            boxType?: {
                centerOfMass?: {
                    x?: number;
                    y?: number;
                    z?: number;
                };
                dimensions: {
                    x?: number;
                    y?: number;
                    z?: number;
                };
                itemSetsPerBoxMax?: number;
                itemsInlineMax?: number[];
                itemsPerBoxMax?: number;
                name?: string;
                price?: number;
                rateTable?: {
                    basePrice?: number;
                    carrier?: string;
                    dimFactor?: number;
                    priceIncreaseRate?: number;
                    rates?: (...)[];
                    service?: string;
                    weights?: (...)[];
                    zone?: string;
                };
                refId?: number;
                reservedSpace?: number;
                weightMax: number;
                weightTare?: number;
            };
            centerOfMassString?: string;
            depthOrder?: number[];
            depthOrderString?: string;
            dimensionalWeight?: number;
            dimensionalWeightUsed?: boolean;
            id?: number;
            items?: {
                item?: {
                    centerOfMass?: ...;
                    color?: ...;
                    dimensions: ...;
                    name?: ...;
                    refId?: ...;
                    sequence?: ...;
                    virtual?: ...;
                    weight: ...;
                } & {
                    deltaCost?: ...;
                    dimensionSet?: ...;
                    groupPackParent?: ...;
                    index?: ...;
                    message?: ...;
                    origin?: ...;
                    quantity?: ...;
                    uniqueId?: ...;
                    unitOfMeasure?: ...;
                };
            }[];
            lenItems?: number;
            subspace?: {
                originInParent?: {
                    x?: number;
                    y?: number;
                    z?: number;
                };
                parentBoxIndex?: number;
                parentItemIndex?: number;
            };
            svg?: string;
            volumeMax?: number;
            volumeNet?: number;
            volumeRemaining?: number;
            volumeReserved?: number;
            volumeUsed?: number;
            volumeUtilization?: number;
            weightNet?: number;
            weightRemaining?: number;
            weightUsed?: number;
            weightUtilization?: number;
        })[]

        Description

        pre-packed boxes, including any items specified that will be packed and excess space used before any new boxes are created.

        Example

        []
        
      • Optional boxesMax?: number

        Description

        The maximum number of boxes to be used to pack the items in the request, potentially leaving items in 'leftovers' if there is insufficient space, determined by item 'sequence' or selected 'itemSort'. If existing 'boxes' are passed to the pack request, they count towards this total, but will not be excluded, allowing for situations where 'lenBoxes' may be greater than 'boxesMax'. However, no 'boxTypes' will be used to create additional boxes unless doing so would not exceed 'boxesMax'.

        Default

        0
        
      • Optional boxesPerItemSetMax?: number

        Description

        The maximum number of boxes that a single ItemSet's member items (i.e., all that share the same refId) can be spread across. Any items that do not fit within this number of boxes will be precluded from packing and returned in the leftovers array. The default setting of 0, a negative number, and null are all equivalent and indicate no maximum limit.

        Default

        0
        
      • Optional boxesPerSequenceMax?: number

        Description

        The maximum number of boxes that a single non-empty sequence's member items (i.e., all that share the same non-empty sequence) can be spread across. Any items that do not fit within this number of boxes will be precluded from packing and returned in the leftovers array. The default setting of 0, a negative number, and null are all equivalent and indicate no maximum limit.

        Default

        0
        
      • Optional cohortMax?: number

        Description

        the maximum number of contiguous cohorts for a given item type within a single container. E.g., if you pack 40 chairs in a single container, a cohortMax of 2 could yield one (all 40 chairs in a single block if space is availabe) or two (say, 25 chairs in one corner and 15 in the other) contiguous cohorts.

        Default

        2
        
      • Optional cohortPacking?: boolean

        Description

        if selected, will ensure that all like items will be packed together, in no more than [cohortMax] different groups within a single container.

        Default

        false
        
      • Optional coordOrder?: number[]

        Description

        If placementStyle is set to "default", coordOrder sets the placement priority of axes ascendingly. "0,1,2" would search for placement points along the Z(length,"2"), then Y(width,"1"), and finally X(height"0"). Keep in mind that in the default rendering the "up" direction is X and the other axes follow the right-hand rule. This is useful for different packing methods. E.g., Utilizing "2,0,1" would pack a shipping container first in the Y(width) direction, then in the X(height) direction, and finally in the Z(length) direction, replication a floor-to-ceiling, front-to-back loading method.

        Example

        [
        0,
        1,
        2
        ]
      • Optional corners?: boolean

        Description

        only pack items at valid corner points of other items (optimal)

        Default

        true
        
      • Optional eye?: {
            x?: number;
            y?: number;
            z?: number;
        }

        Description

        The x,y,z coordinates of the virtual eye looking at the package for visualization purposes. Default is isometric, "1,1,1". To generate a side view, one could use "0.001,1.0,0.001".

        Example

        {
        * "x": 1,
        * "y": 1,
        * "z": 1
        * }
        • Optional x?: number

          Description

          x coordinate, used as height.

          Default

          0
          
        • Optional y?: number

          Description

          y coordinate, used as width.

          Default

          0
          
        • Optional z?: number

          Description

          z coordinate, used as length.

          Default

          0
          
      • Optional generatedBoxTypesMax?: number

        Description

        The maximum number of generated box sizes to randomly sampled when generating box types. Default of 0 is unlimited, and in some cases may never return without a limit.

        Default

        0
        
      • Optional imageFormat?: "svg" | "png"

        Description

        case-insensitive format to render images in, either 'SVG' or 'PNG', if includeImages is enabled.

        Default

        svg
        @enum {string}
      • Optional imgSize?: number

        Description

        width of rendered SVGs in pixels.

        Default

        400
        
      • Optional includeImages?: boolean

        Description

        include inline images, default is always on

        Default

        true
        

        Example

        true
        
      • Optional includeScripts?: boolean

        Description

        include inline javascripts and styles for base template

        Default

        false
        

        Example

        false
        
      • Optional interlock?: boolean

        Description

        alternates layFlat orientation by layer, so as to create an interlocked placement pattern and improve item stability.

        Default

        false
        
      • Optional itemInitialOrientationBestForBox?: boolean

        Description

        For all items where orientation flipping is used, the orientation producing the highest multiple of items fit per remaining dimension is used as the first orientation. This option should be enabled when packing high quantities of single item types, but may produce inconsistent results in other cases. Defers to item orientation locking and itemOrientationSearchDepth > 0 if a superior result is found.

        Default

        false
        
      • Optional itemInitialOrientationPreferred?: boolean

        Description

        Whether to attempt packing by either greedily placing items or placing all allowable combinations of initial item orientations and selecting the most performant. When true, items will be placed immediately using the orientation reflected by their dimensions definition and will only be flipped if a placement cannot be found and the item rules allow orientation changes. When false, all allowable initial orientation combinations will be attempted for each item in each box.

        Default

        true
        
      • Optional itemOrientationSearchDepth?: number

        Description

        When itemInitialOrientationPreferred is set to false, the itemOrientationSearchDepth is the number of unique, sorted, groups of Items sharing the same ItemSet definition that will be have every combination of initial orientation attempted. A value of 1 signifies that only the first item (and others still unpacked from its ItemSet) will have every orientation attempted and the engine subsequently selecting the most performant. A value of 2 signifies that the first groups of unpacked items, each sharing an ItemSet, will have every combination of orientation attempted. Increasing this value from 1 can very rapidly result in excessive complexity and a timeout error instead of a result, so discretion is advised.

        Default

        1
        
      • Optional itemSets?: ({
            centerOfMass?: {
                x?: number;
                y?: number;
                z?: number;
            };
            color?: string;
            dimensions: {
                x?: number;
                y?: number;
                z?: number;
            };
            name?: string;
            refId?: number;
            sequence?: string;
            virtual?: boolean;
            weight: number;
        } & {
            dimensionSets?: {
                axisMultipliers?: {
                    x?: (...) | (...);
                    y?: (...) | (...);
                    z?: (...) | (...);
                };
                dimensions?: {
                    x?: (...) | (...);
                    y?: (...) | (...);
                    z?: (...) | (...);
                };
                quantityDivisor?: number;
                unitOfMeasure?: string;
                weight?: number;
            }[];
            quantity?: number;
        } & {
            quantity: unknown;
        })[]

        Description

        item set definitions if not creating random items.

        Example

        [
        {
        "refId": 0,
        "color": "tomato",
        "dimensions": {
        "x": 4.2,
        "y": 7,
        "z": 8
        },
        "weight": 4.5,
        "quantity": 10
        },
        {
        "refId": 1,
        "color": "cornflowerblue",
        "dimensions": {
        "x": 3,
        "y": 3,
        "z": 5
        },
        "weight": 2,
        "quantity": 13
        }
        ]
      • Optional itemSetsPerBoxMax?: number

        Description

        The maximum quantity of unique 'item.refId' values that a single box can contain. The default setting of 0, a negative number, and null are all equivalent and indicate no maximum limit, optionally overridden by 'boxType' settings.

        Default

        0
        
      • Optional itemSort?: "default" | "largest-box-needed" | "largest-girth" | "largest-length-plus-girth" | "longest-dimension" | "shortest-dimension" | "largest-cross-section" | "set-volume" | "density" | "weight" | "combined" | "all"

        Description

        Method to use to sort items for placement. Default is item volume descending. 'largest-box-needed' is by the volume of the smallest box type specified that will fit the item, descending, 'largest-girth' is 2*(width + height), descending, 'longest-dimension' is by longest single item dimension, descending, 'shortest-dimension' is by shortest single dimension, ascending, 'largest-cross-section' is by largest product of the two greatest dimensions, descending, 'set-volume' is by total 'itemSet' volume, descending. 'weight' is by weight, descending. 'density' is by item weight per unit volume, descending. It can often be worth attempting packs with competing itemSorts and picking the lowest cost option. 'all' uses all available item sorts, whereas 'combined' uses a recommended set of item sorts, both returning the lowest 'totalCost' option.

        Default

        combined
        @enum {string}
      • Optional itemSortDualDirection?: boolean

        Description

        Whether or not to use both normal and reversed itemSorts.

        Default

        false
        
      • Optional itemSortReverse?: boolean

        Description

        Whether or not to reverse the itemSort utilized.

        Default

        false
        
      • Optional itemsInlineMax?: number[]

        Description

        Limit the item count that can share a placement on a specific line parallel to the placement axis, e.g., '[1,2,1]' means items can be placed 1 high, 2 wide, and 1 deep within the box. A value of '0' is equivalent to no limit along that axis. Overridden by 'boxType' settings.

        Example

        [
        1,
        2,
        1
        ]
      • Optional itemsPerBoxMax?: number

        Description

        The maximum quantity of discrete items that a single box can contain. The default setting of 0, a negative number, and null are all equivalent and indicate no maximum limit, optionally overridden by 'boxType' settings.

        Default

        0
        
      • Optional key?: string

        Description

        issued API key.

      • Optional layFlat?: boolean

        Description

        aligns all items laying flat. If possible, it may create a "brick-laying" pattern to increase stability.

        Default

        false
        
      • Optional maxSequenceDistance?: number

        Description

        This is the maximum distance allowable between two sequence values of items packed in a common box. E.g., "Distance" for an item sequence composed of aisle/bin combinations of "0401" and "1228" has a sequence distance of |1228 - 401| = 827

      • Optional n?: number

        Description

        number of random items to generate and the quantity of each if "random" is set to true. a value of 5 would create 5 different items with a quantity of 5 each, making the total item quantity equal to n²

        Default

        5
        
      • Optional orderId?: string

        Description

        a client-provided string identifier for the order this pack corresponds to.

      • Optional packOrigin?: {
            x?: number;
            y?: number;
            z?: number;
        }

        Description

        the x,y,z coordinates of an optional packing origin. A packing origin is used to create more balanced packing for situations where load needs to be considered. E.g., for a 40"x48" pallet, a packOrigin representing the middle of the pallet, "0,20,24", would cause placement to minimize the distance of the packed items from the center of the pallet.

        Example

        {
        * "x": 0,
        * "y": 0,
        * "z": 0
        * }
        • Optional x?: number

          Description

          x coordinate, used as height.

          Default

          0
          
        • Optional y?: number

          Description

          y coordinate, used as width.

          Default

          0
          
        • Optional z?: number

          Description

          z coordinate, used as length.

          Default

          0
          
      • Optional placementStyle?: "default" | "corner" | "wedge" | "mound" | "orb"

        Description

        How to place items. 'default' will defer to coordOrder, 'corner' minimizes distance to rear, bottom corner, 'wedge' minimizes distance to middle of bottom, back edge, 'mound' minimizes distance to center of carton bottom.

        Default

        default
        @enum {string}
      • Optional random?: boolean

        Description

        create random items

        Default

        false
        
      • Optional randomMaxDimension?: number

        Description

        maximum item dimension along a single axis for randomly generated items.

        Default

        10
        
      • Optional randomMaxQuantity?: number

        Description

        maximum quantity for randomly generated items.

      • Optional randomMaxWeight?: number

        Description

        maximum item weight for randomly generated items.

        Default

        10
        
      • Optional requestId?: string

        Description

        a client-provided string identifier for the pack request being made.

      • Optional reservedSpace?: number

        Description

        space in boxes that is reserved, i.e., for packing material.

        Default

        0
        

        Example

        0.2
        
      • Optional rules?: {
            itemMatch?: {
                all?: boolean;
                expression?: string;
                expressions?: string[];
                negate?: boolean;
                property?: "name" | "sequence";
            };
            itemRefId?: number;
            itemSequence?: string;
            operation: "pack-as-is" | "exclude" | "exclude-all" | "irregular" | "lock-orientation" | "internal-space" | "alternate-dimensions" | "fragile";
            options?: {
                [key: string]: unknown;
            };
            parameters?: string[];
            targetBoxRefIds?: number[];
            targetItemRefIds?: number[];
            targetItemSequences?: string[];
        }[]

        Description

        Array of packing rules.

        Example

        []
        
      • Optional seed?: boolean

        Description

        if random is selected, seed the random number generator to deterministically generate random items to pack.

        Default

        true
        

        Example

        false
        
      • Optional seedValue?: number

        Description

        if seed is set to true, specifies a non-default seed for the random number generator.

        Default

        1
        
      • Optional sequenceHeatMap?: boolean

        Description

        Colorize items solely by their sequence value, light when sequence is high, dark when it is low. Useful for indicating item bin location, weight, or other sequence property that may not be apparent from the default visualization.

        Default

        false
        
      • Optional sequenceSort?: boolean

        Description

        Whether or not the items should be initially sorted by their sequence value instead of by the specified itemSort. This is not always useful, as the default "biggest-first" volume sort is very effective for items, and constraining by maxSequenceDistance is applied regardless of this field. That said, for doing custom pre-sorts such as weight-based instead of volume based, this value should be set to true.

        Default

        false
        
      • Optional template?: "demo.tmpl" | "shipapp.tmpl" | "boat.tmpl"

        Description

        template name for markup generation.

        Example

        @enum {string}
        
      • Optional timeout?: number

        Description

        Optional timeout for request computation, will be reduced to endpoint maximum if in excess of published timeout.

        Example

        30
        
      • Optional usableSpace?: number

        Description

        an estimate of typical box utilization for the quick "estimated" boxTypeChoiceStyle, which will be used to ensure "estimated" box type choices are not overly optimistic regarding potential volume utilization.

        Default

        0.85
        

        Example

        0.85
        
      • Optional valueTiebreaker?: "weight" | "volume"

        Description

        The tiebreaker to use in the event to box type choices are otherwise completely equal. Default is "volume", alternative is "weight".

        Default

        volume
        @enum {string}
      • Optional zone?: number

        Description

        [deprecated] the shipping zone in order to use basic zone-based price optimization.

        Example

        null
        
    • url: string = 'https://api.paccurate.io/'

      Paccurate API endpoint.

    Returns Promise<{
        boxTypeChoiceGoalUsed?: string;
        boxes?: {
            box?: {
                centerOfMass?: {
                    x?: (...) | (...);
                    y?: (...) | (...);
                    z?: (...) | (...);
                };
                dimensions: {
                    x?: number;
                    y?: number;
                    z?: number;
                };
                itemSetsPerBoxMax?: number;
                itemsInlineMax?: number[];
                itemsPerBoxMax?: number;
                name?: string;
                price?: number;
                rateTable?: {
                    basePrice?: (...) | (...);
                    carrier?: (...) | (...);
                    dimFactor?: (...) | (...);
                    priceIncreaseRate?: (...) | (...);
                    rates?: (...) | (...);
                    service?: (...) | (...);
                    weights?: (...) | (...);
                    zone?: (...) | (...);
                };
                refId?: number;
                reservedSpace?: number;
                weightMax: number;
                weightTare?: number;
            } & {
                boxType?: {
                    centerOfMass?: (...) | (...);
                    dimensions: {
                        x?: ...;
                        y?: ...;
                        z?: ...;
                    };
                    itemSetsPerBoxMax?: (...) | (...);
                    itemsInlineMax?: (...) | (...);
                    itemsPerBoxMax?: (...) | (...);
                    name?: (...) | (...);
                    price?: (...) | (...);
                    rateTable?: (...) | (...);
                    refId?: (...) | (...);
                    reservedSpace?: (...) | (...);
                    weightMax: number;
                    weightTare?: (...) | (...);
                };
                centerOfMassString?: string;
                depthOrder?: number[];
                depthOrderString?: string;
                dimensionalWeight?: number;
                dimensionalWeightUsed?: boolean;
                id?: number;
                items?: {
                    item?: ...;
                }[];
                lenItems?: number;
                subspace?: {
                    originInParent?: (...) | (...);
                    parentBoxIndex?: (...) | (...);
                    parentItemIndex?: (...) | (...);
                };
                svg?: string;
                volumeMax?: number;
                volumeNet?: number;
                volumeRemaining?: number;
                volumeReserved?: number;
                volumeUsed?: number;
                volumeUtilization?: number;
                weightNet?: number;
                weightRemaining?: number;
                weightUsed?: number;
                weightUtilization?: number;
            };
        }[];
        built?: string;
        images?: {
            boxIndex?: number;
            data?: string;
            format?: "svg" | "png";
        }[];
        itemSortReverseUsed?: boolean;
        itemSortUsed?: string;
        leftovers?: ({
            centerOfMass?: {
                x?: number;
                y?: number;
                z?: number;
            };
            color?: string;
            dimensions: {
                x?: number;
                y?: number;
                z?: number;
            };
            name?: string;
            refId?: number;
            sequence?: string;
            virtual?: boolean;
            weight: number;
        } & {
            deltaCost?: number;
            dimensionSet?: {
                axisMultipliers?: {
                    x?: (...) | (...);
                    y?: (...) | (...);
                    z?: (...) | (...);
                };
                dimensions?: {
                    x?: (...) | (...);
                    y?: (...) | (...);
                    z?: (...) | (...);
                };
                quantityDivisor?: number;
                unitOfMeasure?: string;
                weight?: number;
            };
            groupPackParent?: string;
            index?: number;
            message?: string;
            origin?: {
                x?: number;
                y?: number;
                z?: number;
            };
            quantity?: number;
            uniqueId?: string;
            unitOfMeasure?: string;
        })[];
        lenBoxes?: number;
        lenItems?: number;
        lenLeftovers?: number;
        lenUnits?: number;
        orderId?: string;
        packTime?: number;
        packUuid?: string;
        renderTime?: number;
        requestFingerprint?: string;
        requestId?: string;
        responseFingerprint?: string;
        scripts?: string;
        startedAt?: string;
        styles?: string;
        svgs?: string[];
        title?: string;
        totalCost?: number;
        totalTime?: number;
        totalVolume?: number;
        totalVolumeNet?: number;
        totalVolumeUsed?: number;
        totalVolumeUtilization?: number;
        totalWeight?: number;
        usedKeyStem?: string;
        version?: string;
        warnings?: string[];
    }>

    • Pack response.