Connect a Packing Solver to Your Order System via REST API
Every shipment that leaves your warehouse starts with the same small chore: someone copies the order lines into a packing tool, types in dimensions, tries a container, notices it doesn’t fit, and starts over with a bigger one. It takes a few minutes per order — right up until you have two hundred orders a day and the chore becomes a full-time job that still produces inconsistent results.
Connecting a packing solver to your order system via REST API removes that chore entirely. Your order data is already structured; the solver already knows how to place boxes. The only missing piece is a JSON request in between. This article walks through that integration end to end: authentication, mapping order lines to items and containers, reading the response, and keeping the pipeline healthy in production.
Why Automate Packing Plans from Order Data?
The manual workflow is easy to recognise:
- Export or read the order lines, including dimensions and weights.
- Enter them into a packing tool, line by line.
- Guess a container or pallet size, run the pack, inspect the result.
- If not everything fits, change the container and repeat.
- Copy the result somewhere your warehouse team can read it.
The cost isn’t only the minutes it takes. It’s the variance: two people pack the same order differently, fill rates drift downward because nobody has time to try the next container size up, and weight limits get checked by eye until the one time they don’t.
An API integration collapses that loop into one step. Your order system posts a JSON document describing the items and the containers you have available, and gets back a packing plan with coordinates, fill percentages, and a list of anything that didn’t fit. No human in the middle, no re-checking, and the same rules applied to every order.
RSJ 3D Packer is a managed service built for exactly this: a JSON REST endpoint that solves 3D bin packing problems — multiple bins, arbitrary item and container dimensions — using a solver core based on a neural network optimised through neuro-evolution. You don’t install a solver library or tune heuristics; you send a request and get a plan.
One-Time Setup: Authentication and Endpoint Configuration
Everything lives under one base URL:
https://3dpacker.rsj.de
Step 1: Get a session token
Authentication is a two-part handshake. First, log in and obtain the HMAC for your e-mail address, then exchange it for a session:
curl "https://3dpacker.rsj.de/user/you@example.com?hmac=$PACKER_HMAC"
The hmac is an HMAC-SHA256 hash of the e-mail address. It can only be computed on the server while the user is logged in, so a stand-alone client copies it once and stores it as a secret — it is not something you recompute per request. The response contains your user record and a session value.
Step 2: Send the session as a Bearer token
Every subsequent call carries that session:
Authorization: Bearer session-1bc90169-1c83-443e-8ed7-b0328aaf78a5
Sessions are valid for a limited time — about one day — so the correct pattern is to fetch a fresh session when you need one rather than persisting it. A small helper keeps this out of your business logic:
import os
import requests
BASE = "https://3dpacker.rsj.de"
EMAIL = os.environ["PACKER_EMAIL"]
HMAC = os.environ["PACKER_HMAC"]
def get_session() -> str:
response = requests.get(
f"{BASE}/user/{EMAIL}",
params={"hmac": HMAC},
timeout=30,
)
response.raise_for_status()
return response.json()["session"]
def auth_headers(session: str) -> dict:
return {"Authorization": f"Bearer {session}"}
A note on how you authenticate: the browser application uses cookies, which is what the API sandbox relies on. A server-to-server integration has no browser, so it uses the Bearer token path above.
Step 3: Test before you go live
Two resources make the first request cheap:
- The OpenAPI 3.0 specification — machine readable, suitable for generating a typed client.
- The API sandbox — a live request/response playground written in plain JavaScript, with a 3D preview of the result.
Try a real order there first. If the plan looks wrong, you’ll know it’s your data, not your HTTP plumbing.
Building the Automated Pipeline: From Order to Packing Plan
The mapping is mechanical once you see it. Each order line becomes an item; each physical container type you can ship in becomes a container.
| Order data | API field |
|---|---|
| Line dimensions | width, height, depth (map to x/y/z) |
| Line quantity | count |
| Unit weight | weight |
| Stacking category | itemClass |
| “Must stay upright” flag | vertical: false |
| Dangerous goods class and points | riskTypes, riskPoints |
| Your own line reference | id |
Containers take width, height, depth, count, and optionally weight (maximum load), allowedRiskPoints, and itemClass.
def build_request(order) -> dict:
items = []
for line in order.lines:
item = {
"id": line.sku,
"width": line.width_cm,
"height": line.height_cm,
"depth": line.depth_cm,
"count": line.quantity,
"weight": line.unit_weight_kg,
"vertical": not line.must_stay_upright,
"itemClass": line.stack_class,
}
if line.risk_types:
item["riskTypes"] = line.risk_types
item["riskPoints"] = line.risk_points
items.append(item)
containers = [{
"width": 120,
"height": 100,
"depth": 80,
"count": 20,
"weight": 1000,
}]
return {"containers": containers, "items": items}
Post it to /solve:
def solve(payload: dict) -> dict:
session = get_session()
response = requests.post(
f"{BASE}/solve",
json=payload,
headers=auth_headers(session),
timeout=300,
)
response.raise_for_status()
return response.json()
A minimal request body looks like this — note that items and containers are required, risks is optional, and count defaults to one when omitted:
{
"containers": [
{
"width": 48,
"height": 47,
"depth": 46,
"count": 1,
"weight": 2000,
"allowedRiskPoints": 1000
}
],
"items": [
{ "width": 11, "height": 6, "depth": 6, "count": 51 },
{
"width": 7,
"height": 8,
"depth": 9,
"count": 53,
"vertical": false,
"itemClass": 1,
"weight": 12
},
{ "width": 8, "height": 9, "depth": 10, "count": 57, "riskTypes": [1, 2], "riskPoints": 10 }
],
"risks": [{ "type1": 1, "type2": 2 }]
}
Reading the response
The response is the packing plan, and it has three layers you care about:
packedItems— one entry per placed item, with its container index (c) and itsx,y,zposition inside that container. This is what your warehouse instructions are built from.containers— per container type, how many wereusedand thefilledpercentage.unpackedItems— anything that didn’t fit, with counts, so you never silently short-ship.usedContainers— which containers the solver actually used.
{
"containers": [
{ "width": 48, "height": 47, "depth": 46, "count": 1, "used": 1, "filled": 76.77, "first": 0 }
],
"items": [
{ "width": 11, "height": 6, "depth": 6, "count": 51, "vertical": true, "remaining": 0 },
{ "width": 8, "height": 9, "depth": 10, "count": 57, "remaining": 17 }
],
"packedItems": [
{ "id": 0, "c": 0, "width": 11, "height": 6, "depth": 6, "x": 0, "y": 0, "z": 0 }
],
"unpackedItems": [
{ "id": 2, "width": 8, "height": 9, "depth": 10, "weight": 0, "itemClass": 0, "count": 17 }
]
}
Two practical points about the solver itself. It works with a 240-second time budget per request, which applies on every plan — so set your HTTP client timeout above that rather than at a default 30 seconds. And it produces heuristically optimised solutions for the static problem: items may be packed in any order, which is exactly what you want for a fresh order.
The response also carries a viewer URL and an API sandbox URL. Store the viewer URL on the order record and anyone can open an interactive 3D view of the plan in a browser — no extra rendering code needed on your side.
Monitoring and Failure Handling in Production
A packing request can succeed at the HTTP level and still tell you something important. The solver returns a plan even when not all items fit, so a 200 is not the same as “this order is ready to ship”.
The check your integration must make:
def plan_is_complete(plan: dict) -> bool:
return len(plan.get("unpackedItems", [])) == 0
When unpackedItems is non-empty, a human decision is required — typically one of:
- Add more containers and resubmit.
- Split the order into separate shipments.
- Correct item data that was wrong to begin with (a dimension in the wrong unit, a count that doubled).
For HTTP-level failures, keep the retry logic boring:
- Cache the session for its lifetime.
- When a call is rejected because the session expired, fetch a fresh session and retry once.
- If the retry fails, surface the order for manual handling rather than looping.
Log request and response summaries — order reference, item count, containers used, fill percentage, unpacked count — and keep full payloads out of long-term storage. Feed those summaries into whatever monitoring you already run so a spike in incomplete plans is visible before customers notice.
One useful detail: unknown keys in the request objects are ignored. That means you can attach your own metadata — an order reference, a tenant tag, a correlation ID — and the request still works. The caveat is symmetry: a future API field could collide with a key you invented, so prefix your own keys.
Best Practices for a Reliable Integration
- Check dimensions and counts before you send. Unit mix-ups (cm vs. mm) are the most common cause of nonsense plans, and each bad request burns up to 240 seconds of solver time.
- Use
itemClassfor stacking rules. An item is only ever placed on items of a lower or equal class, and every packed item is supported by the item below it — no floating items in the plan. Assign lower class numbers to the things that belong at the bottom. - Use
vertical: falsefor upright-only items. Fragile, liquid, or top-heavy goods should never be rotated out of their upright position. Note that different container sizes, weight limits, and preventing vertical rotation are Standard and Pro features; dangerous goods are Pro. - Model dangerous goods properly. Put
riskTypesandriskPointson items,allowedRiskPointson containers, and declare incompatible pairs inrisks. The full walkthrough is in How to Pack Dangerous Goods With Risk Points in One Container. - Refresh sessions proactively. Don’t wait for an expiry to discover your token handling is wrong.
- Generate a client from the OpenAPI document. Typed request/response models catch field-name mistakes at compile time instead of at 2 a.m.
- Keep order data inside your network if that’s a requirement. Besides the cloud subscription, RSJ 3D Packer is available as an on-premises server (Windows 10/11 64-bit or Ubuntu Linux 64-bit, 16 GB RAM, 4 GB disk) or as a stand-alone program.
Plans and pricing live on the storefront, and every plan can be tested free for 30 days with the Pro feature set exposed — enough time to run your real order history through the API before committing.
Extending the Pipeline: Dynamic Constraints and Exports
Once the basic pipeline is running, three extensions tend to come next.
Dynamic constraints. The solver targets the static problem, but the algorithm can be adapted for dynamic problems — for example a fixed packing order, or a required unpacking order when the receiving end needs items in a specific sequence. If your operation has that constraint, it’s worth raising before you design around a workaround.
GLB export. The solution can be downloaded as a GLB 3D model, which is handy for attaching a visual to a shipping document or dropping the plan into an existing 3D viewer.
Embedded viewer. The viewer is embeddable in an IFRAME, so the packing plan can appear inside your order system next to the order lines it came from, rather than in a separate tab.
If you’d rather not write code at all for a first proof of concept, cloud subscribers can use the Google Sheets add-on as a lightweight integration.
For teams running high order volumes through small facilities, Packing Optimisation for Small E-Commerce Warehouses covers the operational side of the same problem, and How to Pack a Pallet With Weight Limits and No Rotation goes deeper on the constraint fields used above.
FAQ
Q: How do I authenticate my order system against the packing solver API?
A: Log in to obtain an HMAC, call GET /user/{email}?hmac={hmac} to receive a session value, then send that session as a Bearer token in the Authorization header. Sessions expire after about one day, so fetch a fresh one instead of storing it long-term.
Q: What does the API response contain and how do I use it in my order system?
A: The response includes packedItems with container index and x/y/z position, fill percentage per container, usedContainers, unpackedItems with counts, and a viewer URL. Your order system can store the positions for warehouse instructions and check unpackedItems to decide if the order needs more containers.
Q: Can I enforce weight limits and prevent rotation through the API?
A: Yes. Set weight on items and containers to enforce maximum load, and set "vertical": false on items that must not be rotated out of their upright position. These features are available on Standard and Pro plans.
Q: What happens if not all items fit in the available containers?
A: The solver returns a plan with the items that fit and lists the remaining items in unpackedItems with their counts. Your integration should check this list and decide whether to add containers, split the order, or adjust item data.
Conclusion
The integration is genuinely small: one authenticated POST /solve, a mapping function from order lines to items, and a check on unpackedItems. What you get in return is a consistent packing decision for every order, made with the same rules and the same solver, without anyone retyping dimensions.
Start in the API sandbox with one real order, then move the call into your order system and let it run alongside your manual process for a week. The 30-day free test exposes the full Pro feature set, so you can measure fill rates against your current numbers before you decide anything.
Related posts
- How to Pack a Pallet With Weight Limits and No Rotation
- Packing Optimisation for Small E-Commerce Warehouses
- How to Pack Dangerous Goods With Risk Points in One Container