Constraints

Three per-item controls tell the solver what it may do with a cargo line once it is placed: whether other cargo may rest on top of it, whether it may stack only on its own SKU, and which way it may be turned.

When to use this

allowedRotations and allowStackingOnTop, with the box's bottom face hatched so it can be followed

allowedRotations (top): four before-and-after pairs. The box stands on a floor and its bottom face is hatched, so you can follow that one face through the change. Under ["Z"] the box makes a quarter turn and the hatched face stays on the floor; under ["X"] or ["Y"] the box tips about a bottom edge and the hatched face ends up facing sideways; under [] the two poses are identical, because nothing may turn. allowStackingOnTop (bottom): whether other items may rest above this one.

  • You need to stop other cargo from being stacked on a fragile or top-heavy line.
  • You need each product to stack only on itself, without creating a class per product (see Stack only with the same SKU).
  • You need to keep a cargo line upright, restrict it to specific faces, or forbid any rotation at all.

Walkthrough

Stacking & support

allowStackingOnTop is a boolean under constraints on a cargo entry. It controls whether other cargo may be placed directly on top of this one:

{
  "externalId": "TV-55",
  "category": "box",
  "amount": 40,
  "geometry": { "type": "box", "dimensionX": 1300, "dimensionY": 200, "dimensionZ": 800 },
  "weight": 22,
  "constraints": {
    "allowStackingOnTop": false
  }
}
  • allowStackingOnTop: false (the default) means nothing may be placed on top of this cargo line; true allows other items to be stacked on it.

To keep rules between kinds of cargo, see Stacking rules.

Stack only with the same SKU

To let a product stack only on itself, set sameSkuStacking: "upperAndLower" under constraints. Its boxes then stand in columns of their own: the box directly underneath and the box resting directly on top must be the same SKU, or the floor underneath. It needs no cargo classes and no rules, however many products the job has.

Value Meaning
none (the default) No requirement: the box stacks as it would without this member.
upperAndLower Columns of one SKU: the boxes in direct contact above and below must be the same SKU.

The values are accepted in any case and returned as written above. Any other value is a 400 validation_failed at the member. More values may be added later; a client that reads sameSkuStacking back tolerates a value it does not know.

Two rows, one for each value of sameSkuStacking: none and upperAndLower. Each row shows the same three towers, seen from the side and read from the bottom up: SKU A on SKU A, SKU B on SKU A and SKU A on SKU B. SKU A carries the value of its row and SKU B is none; both allow stacking on top. none: all three towers are allowed. upperAndLower: SKU B on SKU A and SKU A on SKU B are both refused, because a box of A touches a box that is not SKU A; only SKU A on SKU A is allowed.

Three lines that each stack only on themselves, so every column holds one product:

[
  { "externalId": "TV-55", "amount": 40, "geometry": { "type": "box", "dimensionX": 1300, "dimensionY": 200, "dimensionZ": 800 }, "weight": 22,
    "constraints": { "allowStackingOnTop": true, "sameSkuStacking": "upperAndLower" } },
  { "externalId": "SOUNDBAR", "amount": 60, "geometry": { "type": "box", "dimensionX": 1000, "dimensionY": 150, "dimensionZ": 200 }, "weight": 6,
    "constraints": { "allowStackingOnTop": true, "sameSkuStacking": "upperAndLower" } },
  { "externalId": "STAND", "amount": 25, "geometry": { "type": "box", "dimensionX": 600, "dimensionY": 600, "dimensionZ": 300 }, "weight": 9,
    "constraints": { "allowStackingOnTop": true, "sameSkuStacking": "upperAndLower" } }
]
  • The same SKU. Cargo lines that reference one SKU with libraryId are that SKU, whatever their overrides. An inline line is a SKU of its own: two inline lines are never the same SKU, even with equal dimensions, so to let several lines stack on each other, reference one SKU from a library. The 40 units of a line with amount: 40 are one SKU and stack on each other.
  • Both lines set it. A box of a line with upperAndLower touches only boxes of the same SKU whose line sets upperAndLower too. This matters when one line of a SKU overrides the SKU's value with none: its boxes stack as usual, but not on or under the boxes of the lines that keep upperAndLower.
  • With allowStackingOnTop. Nothing rests on a box unless its line allows it, and allowStackingOnTop defaults to false. Send allowStackingOnTop: true next to sameSkuStacking; POST /v2/jobs/validate warns with stacking_disabled when no line allows stacking.
  • With cargo classes and stacking rules. They all apply and the strictest wins: a glass line with upperAndLower under a directOn rule for glass on glass does not stack at all, and under a tower limit of 3 for glass on glass its columns are at most 3 high. See Stacking rules.

Orientation

allowedRotations is the only rotation control on a cargo entry (see Not supported). It names which axes ("X", "Y", "Z") the box may be turned 90° about, relative to the orientation you submitted it in:

{
  "externalId": "GLASS-PANEL",
  "category": "box",
  "amount": 60,
  "geometry": { "type": "box", "dimensionX": 1600, "dimensionY": 50, "dimensionZ": 1100 },
  "weight": 35,
  "constraints": {
    "allowedRotations": []
  }
}
Value Meaning
omitted ["Z"]: upright, may spin about the vertical axis
["Z"] the footprint turns; the box stays upright
["X"] or ["Y"] the box tips onto another face
[] no rotation at all, placed exactly as submitted
an unknown token 400

Omitted is not the same as empty. Leaving out allowedRotations falls back to the default: upright, free to spin about Z; sending [] explicitly locks the box in the exact orientation you submitted, with no rotation permitted at all.

Packing the load toward one end or side (consolidation) is a secondary objective, not a per-item constraint. See Optimization objectives.

Key fields

Field Where Type Meaning
constraints.allowStackingOnTop cargo entry boolean Whether other items may rest on top of this one. Default false.
constraints.sameSkuStacking cargo entry string Whether the line stacks only with the same SKU (upperAndLower). Default none.
constraints.allowedRotations cargo entry string[] Axes (X/Y/Z) the box may be turned 90° about. Omitted → ["Z"]; [] → locked in the submitted orientation.

Notes & caveats

  • Constraints are per cargo line only. Carriers in this API have no constraints field; only a cargo entry carries one.
  • These two fields are a line's own rules; rules between kinds of cargo are in Stacking rules. See Not supported for what it does not have.
  • Omitted vs. empty is not the same for allowedRotations. Omitting it defaults to ["Z"] (upright, may spin); sending [] explicitly forbids any rotation.