Cost optimisation: cheapest carton, cheapest carrier
When you give the algorithm carrier cost information, it switches from minimising carton count to minimising total shipping cost: the sum of chargeable-weight pricing plus any surcharges, evaluated per carrier, per candidate packing.
This is a /pack-only feature. /pack_pallet does not evaluate carriers.
Units: read this before you enter a rate card
Every weight and dimension in a carrier preset is interpreted in the units of the items you send in the request. The preset carries no units of its own. By convention that means kilograms and centimetres, matching the item units in your /pack payload.
Get this wrong and nothing raises an error. Your parcels are priced against the wrong numbers, by a factor of 1000.
- A tier covering "0 to 2 kg" is
[0, 2, ...]. It is never[0, 2000, ...]. - A 30 kg surcharge threshold is
max_weight: 30, not30000. rate_per_gramis a legacy field name. It is the cost per unit of billable weight, so with kilogram items it is the cost per kilogram. It does not convert to grams.
One more trap, stated plainly because it is silent: in a StepRate card, a billable weight that falls in no bracket costs zero, and a carrier that prices a parcel at zero wins every comparison. Make sure the last bracket's upper bound is above the heaviest parcel you can produce.
What you can configure
A carrier preset has four parts. Each part is built by a factory with a name and a parameters object.
-
Billable-weight rule (
billable_weight_calculator). How the carrier converts a parcel's dimensions and weight into a chargeable weight.Name Behaviour StandardVolumetricchargeable = max(actual, (W * H * D) / conversion_factor). Optionalrounding_rule(up,down,nearest) androunding_increment.ActualWeightUse only the actual weight; ignore volumetric. -
Transport pricing (
pricing_model).Name Behaviour Linearcost = fixed_cost + rate_per_gram * billable_weight, with optionalmin_charge.StepRateWeight brackets, each with a base rate and an optional per-increment surcharge. CustomCaller-defined function (advanced). -
Packaging cost (
packaging_cost_calculator).Name Behaviour FixedFlat per-bin packaging cost. FillerMaterialCost scales with wasted volume inside the bin. -
Surcharges (
surcharges, list). Each entry triggers a flat extra fee when the parcel exceeds a threshold.Name Triggered when MaxDimAny dimension exceeds max_dimension.MaxVolumeTotal volume exceeds max_volume.MaxWeightTotal weight (item + tare) exceeds max_weight.GirthA2 * (W + H) + D > max_girth.GirthB2 * (W + D) + H > max_girth.
Carrier selection mode
When multiple carrier presets are passed, the algorithm picks among them. Two strategies, switched by config.CARRIER_SELECTION_MODE:
- Per-bin (default). Each packed bin in an order is evaluated against every carrier independently; the cheapest carrier is assigned per bin. An order with three packed bins can ship via three different carriers.
- Per-order (
"per_order"). The full packing run is repeated once per carrier; the carrier whose total order cost is lowest wins. Every packed bin in that order ships via the same carrier. Use this when one waybill per order is required.
Configure via the web app
The web app provides a form-driven editor and a built-in cost spot-check. Open the Carriers page and add or edit a carrier preset.
Carrier overview
When navigating to the Carriers page, an overview of all configured carriers is presented. A new carrier configuration can be created by clicking on the top-right "Create Carrier" button. Editing an existing carrier configuration can be done by clicking on the pencil icon of that corresponding configuration.

Carrier details
The carrier ID and display name. The carrier ID is the short identifier you reference from the API (config.carrier_preset_ids); it must be unique per account.

Weight calculation
Pick how the carrier computes chargeable weight (higher of actual or volumetric, actual only, volumetric only), the conversion factor for the volumetric formula (typical values are 5000 or 6000), and an optional rounding rule. The form shows the resulting formula in plain text, for example Volumetric weight = (L * W * H) / 5000 and Chargeable weight = max(actual, volumetric).

Pricing tiers
Each tier covers a weight range with a base price. Optionally enable step pricing to charge per-weight-increment on top of the base. A Show price curve button visualises how cost scales with chargeable weight.

Surcharges
Add as many surcharges as the carrier requires. Each one has a Condition and a Threshold. Available conditions match the API factories (Overweight maps to MaxWeight, Oversized single dimension to MaxDim, Oversized girth A and B to GirthA / GirthB, Over volume to MaxVolume). The form shows a one-line "Triggered when" summary so you can verify the condition before saving.

Cost spot-check
Enter sample dimensions and a weight; the form computes volumetric weight, chargeable weight, matched tier, transport cost, and total. Use this to sanity-check a preset before sending real traffic at it.

Reference the preset from the API
After saving the preset, reference it from your pack request by carrier ID:
{
"config": {
"carrier_preset_ids": ["DPD"]
},
"orders": [],
"bins": []
}
Multiple IDs in the array means the algorithm picks the cheapest carrier per bin (or per order, depending on CARRIER_SELECTION_MODE).
Configure inline via the API
If you would rather not touch the web app, pass the full carrier config inline. Same schema, different transport.
{
"config": {
"CARRIER_SELECTION_MODE": "per_order",
"CARRIERS": [
{
"carrier_id": "DPD",
"name": "DPD",
"billable_weight_calculator": {
"name": "StandardVolumetric",
"parameters": { "conversion_factor": 5000 }
},
"pricing_model": {
"name": "StepRate",
"parameters": {
"weight_brackets": [[0, 999999, 4.1, 0, 0]]
}
},
"surcharges": [
{ "name": "MaxWeight", "parameters": { "max_weight": 31.5, "surcharge_amount": 34.1 } },
{ "name": "MaxWeight", "parameters": { "max_weight": 20, "surcharge_amount": 1.9 } },
{ "name": "GirthA", "parameters": { "max_girth": 310, "surcharge_amount": 36 } }
]
}
]
},
"orders": [],
"bins": []
}
The web app's API usage panel emits exactly this JSON for any saved preset, so you can copy-paste from a working preset rather than hand-writing the config.
Per-bin cost overrides
For simple cases (no carrier nuance, just "this carton costs 1.20 to ship"), set packaging_cost and transport_cost directly on the bin:
{
"id": "carton_S",
"width": 20, "height": 15, "depth": 10,
"packaging_cost": 0.30,
"transport_cost": 1.20
}
When no carrier presets are attached, the algorithm falls back to these fixed per-bin values.
How the algorithm uses the cost information
In per-order mode (CARRIER_SELECTION_MODE = "per_order"):
- Run the full packing once per carrier.
- For each result, sum per-bin transport, packaging, and surcharges.
- Pick fewest unfitted items, then lowest total cost.
In per-bin mode (default):
- Run the packer once.
- For each packed bin, evaluate every carrier and pick the cheapest one.
Both modes can change which carton the algorithm picks (cost-aware bin selection), not only which carrier: a slightly larger carton may win if shrinking would cross a surcharge threshold. When adjust_*_min is also in play, the cost evaluation takes into account possible shrinking, so the chosen shape is the one that minimises total cost at its shrunk dimensions.
Delivery estimates and dates
A carrier preset can carry an optional top-level delivery block: a transit-time promise that becomes a concrete delivery-date range at pack time. When a preset defines it, every packed order routed to that carrier gets min_delivery_date and max_delivery_date, so a checkout can show a real arrival window.
To offer slower/cheaper against faster/pricier, define two carrier presets (for example "DPD Standard" and "DPD Express"), each with its own rate card and its own delivery block, and pass both ids in carrier_preset_ids. Cost optimisation picks the cheapest carrier per bin as usual, and the winning carrier's delivery window is stamped on the order.
This is additive and backward-compatible. A preset with no delivery behaves exactly as before and returns no delivery dates.
Add a delivery block to a carrier preset
delivery sits at the top level of the preset, alongside the rate-card fields (pricing_model, optional countries, surcharges) and the optional warehouse_code that scopes the carrier to one fulfilment origin (see Fulfillment origins).
The older per-preset origins block (per-origin rate trees nested inside one carrier) is deprecated in favour of warehouse_code plus first-class warehouses. Existing presets that use origins still resolve.
{
"carrier_id": "DPD_STD",
"name": "DPD Standard",
"billable_weight_calculator": { "name": "ActualWeight", "parameters": {} },
"pricing_model": { "name": "StepRate", "parameters": { "weight_brackets": [[0, 999999, 4.10, 0, 0]] } },
"delivery": { "transit_min_days": 2, "transit_max_days": 3, "delivers_saturday": false, "delivers_sunday": false }
}
delivery fields:
| Field | Meaning |
|---|---|
transit_min_days / transit_max_days | Transit time in carrier delivery days from handover. When equal, a single date is shown. |
delivers_saturday | Whether the carrier delivers on Saturdays. |
delivers_sunday | Whether the carrier delivers on Sundays (defaults to false). |
delivery is optional; a preset is valid as long as its rate card resolves. Omit it for carriers that ship with no delivery promise.
Fulfillment settings (per account)
The delivery-date maths also needs the merchant/warehouse calendar, held once per account and read at pack time. Manage it at GET / PUT /settings/fulfillment.
{
"origin_timezone": "Europe/Amsterdam",
"handling_days": 1,
"cutoff_time": "17:00:00",
"working_days": [0, 1, 2, 3, 4],
"holidays": ["2026-12-25", "2027-01-01"]
}
| Field | Meaning |
|---|---|
origin_timezone | IANA timezone of the fulfilment origin. The daily cutoff is evaluated here. Defaults to UTC. |
handling_days | Warehouse working days from order to carrier handover (0 = same-day). Defaults to 1. |
cutoff_time | Origin-local HH:MM:SS; orders placed after it roll to the next dispatch day. Defaults to 17:00:00. |
working_days | Warehouse dispatch weekdays, 0 = Monday ... 6 = Sunday. Defaults to Mon-Fri ([0,1,2,3,4]). |
holidays | Non-working YYYY-MM-DD dates, subtracted from both handling and transit. Defaults to empty. |
GET returns the current settings, creating defaults on first read. A date is computed on two calendars: handling advances on working_days; transit advances on the carrier's delivery days (weekdays plus any Saturday/Sunday the carrier delivers). Both skip holidays.
Fulfillment origins (multiple warehouses)
If you ship from more than one location (say an FR warehouse and a UK warehouse), each origin has its own carrier rates and its own dispatch calendar. Model each as a warehouse: a first-class fulfilment origin that carries the same calendar fields as /settings/fulfillment plus an identity (code, name, country).
A carrier preset is bound to a warehouse by its code through the preset's warehouse_code. At pack time you name the origin with the request-level warehouse field; the algorithm then offers only the carriers that ship from it and uses that warehouse's calendar for delivery dates.
This is optional and backward-compatible. An account with no warehouses configured behaves exactly as before: every carrier applies and /settings/fulfillment drives the dates.
Manage warehouses at /warehouse:
| Method + path | Purpose |
|---|---|
POST /warehouse | Create a warehouse. The first one created is the account default. |
GET /warehouse/all | List warehouses. |
GET /warehouse/id?warehouse_id=... | Fetch one. |
PUT /warehouse | Update one (send the full object including _id). |
POST /warehouse/{id}/set_default | Make this warehouse the default. |
DELETE /warehouse?warehouse_id=... | Delete one. |
{
"code": "FR",
"name": "France DC",
"country": "FR",
"postal_code": "59000",
"origin_timezone": "Europe/Paris",
"handling_days": 1,
"cutoff_time": "17:00:00",
"working_days": [0, 1, 2, 3, 4],
"holidays": ["2026-12-25"]
}
| Field | Meaning |
|---|---|
code | Account-unique short code (e.g. FR, UK). Referenced by warehouse_code on carrier presets and by the warehouse field on a pack request. Stored upper-cased. |
name | Display name. |
country | ISO-3166-1 alpha-2 country the warehouse ships from. |
postal_code | Optional origin postal code. |
is_default | The origin used when a pack request names none. Exactly one per account; managed via POST /warehouse/{id}/set_default. |
origin_timezone, handling_days, cutoff_time, working_days, holidays | The dispatch calendar, same meaning as /settings/fulfillment above. |
Scope a carrier to a warehouse. Set warehouse_code on the preset to the warehouse's code. A preset with no warehouse_code is origin-agnostic and applies to every warehouse.
{
"carrier_id": "CHRONOPOST_FR",
"name": "Chronopost (FR)",
"billable_weight_calculator": { "name": "ActualWeight", "parameters": {} },
"pricing_model": { "name": "StepRate", "parameters": { "weight_brackets": [[0, 999999, 6.50, 0, 0]] } },
"warehouse_code": "FR"
}
Select the origin on a pack request with the warehouse field (the warehouse code). It is optional: with a single warehouse it defaults to that one, with several it defaults to the account default, and with none configured behaviour is unchanged.
{
"warehouse": "FR",
"config": { "carrier_preset_ids": ["CHRONOPOST_FR", "DPD_STD"] },
"destination": { "country": "FR", "postal_code": "75001" },
"orders": [],
"bins": []
}
Carriers scoped to a different warehouse are dropped; a named warehouse that does not exist for the account returns 422.
Delivery dates at pack time
Pass the carrier preset ids in config.carrier_preset_ids as usual; there is no separate service selector. Each packed order routed to a carrier that has a delivery block carries min_delivery_date and max_delivery_date.
{
"config": {
"carrier_preset_ids": ["DPD_STD", "DPD_EXP"]
},
"destination": { "country": "NL", "postal_code": "1016 GV" },
"orders": [],
"bins": []
}
The delivery dates are returned on each packed order:
{
"orders": [
{
"order_id": "ORDER123",
"min_delivery_date": "2026-07-10",
"max_delivery_date": "2026-07-13",
"bins": []
}
]
}
min_delivery_date / max_delivery_date are offset-free calendar dates (YYYY-MM-DD), reflecting the carrier that actually won the order's bins. They appear only when the winning carrier has a delivery block; otherwise the fields are omitted and behaviour is unchanged.
Preview a delivery estimate
To show a delivery-date range without running a full pack (for example while editing a carrier), call:
GET /carrier_preset/{id}/delivery_estimate
{id} is the preset's document id. An optional as_of query parameter (an ISO-8601 instant) previews a hypothetical order time; it defaults to now in the origin timezone. The endpoint returns 404 if the preset has no delivery block.
{
"carrier_id": "DPD_STD",
"min_delivery_date": "2026-07-10",
"max_delivery_date": "2026-07-13"
}