Skip to main content

Box-on-demand: right-sized cartons

Box-on-demand turns each bin in your catalogue from a fixed shape into a template. The algorithm fits items into the template, then shrinks each carton to the size the contents actually require. Use this for customers who fold cartons from continuous material (corrugate rolls), or who stock a small number of cartons with one or two adjustable dimensions.

This can be used when you produce cartons on a box-making machine that can fold width and/or depth within a roll's range, and the height is set by the items packed inside.

How to enable it

Set one or more of adjust_width_min, adjust_height_min, adjust_depth_min on any bin in the request. The presence of any of these on any bin auto-switches the /pack endpoint to the box-on-demand path. No extra flag, no separate endpoint.

Bin with adjustable height
{
"id": "envelope_4cm",
"width": 30,
"height": 4,
"depth": 20,
"adjust_height_min": 0.5
}

This says: the carton is up to 30 x 4 x 20, and after packing the height shrinks to whatever the contents need, but never below 0.5.

What adjust_X_min actually means

adjust_X_min is the floor for dimension X after shrinking. Read the width / height / depth fields as the ceiling (the maximum size the carton can take for those dimensions). The algorithm intelligently fits items into the range of the floor and ceiling for each dimension. Afterwards, it shirnks shrinks each of the three dimensions down to the larger of either the items' bounding box on that axis, or eitheradjust_X_min. Dimensions where adjust_X_min is unset stay at their ceiling value.

Example

A bin with:

{
"width": 30,
"height": 20,
"depth": 20,
"adjust_width_min": 5,
"adjust_height_min": null,
"adjust_depth_min": 5
}

After packing items with bounding box 12 x 8 x 3:

  • Width: items fit into 12, and adjust_width_min = 5, so final width = max(12, 5) = 12.
  • Height: adjust_height_min is null, so final height = 20 (ceiling unchanged).
  • Depth: items fit into 3, and adjust_depth_min = 5, so final depth = max(3, 5) = 5.

Final carton: 12 x 20 x 5.

What the algorithm optimises for

Box-on-demand does not just shrink the carton, it also picks the spatial layout that scores best against the objective(s) configured for your account. Examples of objectives the algorithm can optimise for include:

  • Fewer cartons (MinBinObjective).
  • Tighter wrapped volume (MaxFillRateObjective and variants): items are placed so the carton ends up as small as possible around the contents.
  • Lower total shipping cost (MinCostObjective and variants): items are placed to avoid shapes that trigger carrier surcharges (girth, oversize, weight thresholds), even when that means a slightly larger carton. See the cost-optimisation guide for how surcharges are configured.

Multiple objectives compose lexicographically: earlier ones dominate later ones. Which objectives are active is part of your account's packer configuration. This can be overwritten using the config parameter in your API request.

Mixing fixed and adjustable bins

You can mix fixed-shape bins and adjustable bins in the same bins list. The algorithm considers both: a fixed 25 x 25 x 25 carton may still beat a shrinkable bin with the same items inside, depending on cost or count.

When all bins are adjustable, the optimiser effectively picks the cheapest shrunken shape per order.

Constraints and gotchas

  • adjust_X_min must be at least 0 and at most the corresponding fixed dimension when provided. A bin with width = 30 and adjust_width_min = 40 is invalid.
  • The adjust_X_min floors are not bin-cost discounts on their own. To get cost-driven shrinking, combine with carrier-cost optimisation (see the cost-optimisation guide).
  • This feature is supported for cartonization (/pack) only. The palletization algorithm (/pack_pallet) ignores this.

End-to-end example

The request belows tries to pack a 12 x 8 x 3 item into a 30 x 20 x 20 box, of which the width and depth can be cut down to 5. The height is not adjustable, so stays 20.

curl -X POST 'https://optiapp.api.optioryx.com/pack' \
-H 'x-api-key: <API_KEY>' \
-d '{
"orders": [
{
"id": "order_1",
"items": [
{"id": "sku_a", "width": 12, "height": 8, "depth": 3, "quantity": 1}
]
}
],
"bins": [
{
"id": "stretchy_carton",
"width": 30,
"height": 20,
"depth": 20,
"adjust_width_min": 5,
"adjust_depth_min": 5
}
]
}'