Libraries
Save the carriers you use over and over, your trailers, containers and pallets, and the cargo units you ship, your SKUs, once, and reference them from a job by id instead of repeating their dimensions in every request. This guide shows how to find your libraries, save and browse carriers, use them in a job, and what the result tells you back; SKU libraries then does the same for cargo. Company libraries come per type: a type is available when the plan includes company libraries and its own size limit is not 0 (see Plans and limits).
When to use this
- You load the same fleet every day and do not want to send its dimensions with each job.
- Several of your systems submit jobs and should agree on one definition of each carrier.
- You want the result to say which of your carriers each loaded unit is, without matching on labels.
- Your own system holds the cartons and products you ship, and a job line should say only which one and how many.
The model
Your account has one company library for carriers, and one for SKUs, which SKU libraries covers. Each entry in the carrier library is a complete carrier definition: a name, a category, box dimensions in the entry's own units, and optionally an externalId label, a region, a tare weight, a weight limit and a note. An entry has an id, and a job carrier puts that id in its libraryId field instead of spelling out the dimensions.
Your account can also read a second library, the system catalogue: standard carriers we maintain, which you browse and reference without the company-library entitlement; see The system catalogue below.
A reference is resolved when you submit the job and copied into it. Deleting the entry afterwards changes nothing for jobs you already submitted. GET /jobs/{id}/input returns that copy: every line comes back inline, a referenced one with the entry's definition as frozen into the job, and sources names each entry with the revision the job used and the lines it resolved. See Reading back the request.
A library id and an entry id are different ids. The path
/libraries/{id}takes the id of a library, asGET /librarieslists it; thelibraryIdfield of a job carrier or cargo line takes the id of an entry in it. A line that names one of your libraries instead is rejected with400, field codelibrary_entry_not_found, and a message that says it got a library's id.
Find your library
curl https://api.loadoptimizer.ai/v2/libraries \
-H "X-Api-Key: ck_live_..."
{
"items": [
{
"id": "carrier_system_default",
"name": "Standard carriers",
"type": "carrier",
"scope": "system",
"overridable": true,
"entryCount": 49,
"access": "reference"
},
{
"id": "5f0c6a8e-3b1d-5e2a-9c47-81d2f6a0b3e4",
"name": "Company carriers",
"type": "carrier",
"scope": "company",
"overridable": true,
"entryCount": 0,
"access": "edit"
},
{
"id": "9b3d7e21-4c6a-5f18-8e2b-6a0d4c9f1e73",
"name": "Company SKUs",
"type": "sku",
"scope": "company",
"overridable": true,
"entryCount": 0,
"access": "edit"
}
]
}
The system catalogue, carrier_system_default, is first when your key can read carrier libraries. It needs no company-library entitlement: any plan that can use the customer API can read and reference it, with a key that can read carrier libraries. Your company libraries follow it, carriers first and then SKUs, each one when it is available: a type is available when the plan includes company libraries and its own size limit is not 0, and a type that is not is left out. Without company libraries the list holds only the system catalogue. A company library's id is stable for your account and exists before you save anything, so you can look it up once and keep it. ?scope=company, ?scope=system, ?type=carrier and ?type=sku narrow the list; any other value is a 400.
The system catalogue
Alongside your company library, you can read carrier_system_default ("Standard carriers"): a maintained catalogue of standard carriers, ISO containers, trailers, trucks and vans, and pallets. It reads like any other library; only we add to or change it.
curl "https://api.loadoptimizer.ai/v2/libraries/carrier_system_default/entries?q=EUR%201" \
-H "X-Api-Key: ck_live_..."
{
"items": [
{
"id": "carrier_eur_pallet",
"type": "carrier",
"scope": "system",
"externalId": null,
"name": "EPAL / EUR 1",
"note": null,
"category": "pallet",
"region": "europe",
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 1200, "dimensionY": 800, "dimensionZ": 1800 },
"tareWeight": null,
"maxWeight": null,
"revision": 1,
"createdAt": "2026-09-25T00:00:00.001+00:00",
"createdBy": null,
"updatedBy": null,
"updatedAt": "2026-09-25T00:00:00.001+00:00"
}
],
"nextCursor": null
}
You browse and search it exactly like a company library: GET /libraries/carrier_system_default/entries, with the same q, category, region, limit and cursor described below, and one entry by slug at GET /libraries/carrier_system_default/entries/{slug}. Archived entries never appear in either. To browse by kind, ?category=trailer lists the trailers. A job carrier references an entry the same way too, by putting the slug in libraryId. Neither needs the company-library entitlement: libraries_not_entitled never applies to a slug, only to a UUID.
region groups entries by where they are typically used (europe, north_america, asia, oceania); it is optional on an entry of either scope and may be null.
Slugs are permanent. An entry we retire stops being listed and stops being usable as a reference, and its slug is never reused for a different carrier: a job that referenced it before keeps its own frozen copy, unaffected, exactly as when a company entry is deleted.
Only we change this catalogue: POST, PUT or DELETE on carrier_system_default answers 403 library_read_only, checked before the request body or an Idempotency-Key is read at all.
Save a carrier
curl -X POST https://api.loadoptimizer.ai/v2/libraries/5f0c6a8e-3b1d-5e2a-9c47-81d2f6a0b3e4/entries \
-H "X-Api-Key: ck_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 8d2f4b1e-trailer-136" \
-d '{
"externalId": "TRL-136",
"name": "Trailer 13.6",
"note": "Tail lift for the northern route",
"category": "trailer",
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 13600, "dimensionY": 2480, "dimensionZ": 2700 },
"tareWeight": 7200,
"maxWeight": 24000
}'
The answer is 201 with the entry, its Location header pointing at it:
{
"id": "0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1",
"type": "carrier",
"scope": "company",
"externalId": "TRL-136",
"name": "Trailer 13.6",
"note": "Tail lift for the northern route",
"category": "trailer",
"region": null,
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 13600, "dimensionY": 2480, "dimensionZ": 2700 },
"tareWeight": 7200,
"maxWeight": 24000,
"revision": 1,
"createdAt": "2026-09-24T08:12:33.412+00:00",
"createdBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedAt": "2026-09-24T08:12:33.412+00:00"
}
| Field | Rule |
|---|---|
name |
Required, up to 256 characters. |
category |
Required: container, pallet, truck or trailer. Optional on an inline carrier, but a saved carrier must not change kind with the job that uses it. |
geometry |
Required, box. The same size rules as an inline carrier: every dimension above 0, at least 1 mm after rounding, at most 100 m. |
units |
Optional; m and kg when omitted. The entry keeps them and echoes every value in them. |
externalId |
Optional label from your own system, 1 to 128 characters. Not a key: duplicates are allowed. |
note |
Optional note about the entry, 1 to 1000 characters; null when not set. It stays in the library: a job that references the entry does not copy it, and it is not the description label of a cargo line. |
region |
Optional: europe, north_america, asia or oceania. Groups the entry for display; null when not set. |
tareWeight |
Optional, 0 to 100000 kg after conversion. Stored and echoed; not used in solving yet. |
maxWeight |
Optional, above 0 and at most 100000 kg after conversion, in the entry's units. The most cargo the carrier may carry, not counting tareWeight. Every job that uses the entry respects it; null when not set. |
The Idempotency-Key header makes a retry safe: the same key with the same body returns the entry the first request created, and the same key with a different body is a 409 with an empty body. The key holds as long as the entry exists: a retry after the entry was deleted creates a new entry rather than returning the old one.
Browse and search
curl "https://api.loadoptimizer.ai/v2/libraries/5f0c6a8e-3b1d-5e2a-9c47-81d2f6a0b3e4/entries?q=trailer&limit=50" \
-H "X-Api-Key: ck_live_..."
Entries come back in the order you saved them, as full definitions, in items. q keeps the entries whose name or externalId contains the text, ignoring case (not note); % and _ are ordinary characters. category keeps the entries of the categories you name, and region the carriers of the regions you name; repeat either for several (?category=trailer&category=truck), and every filter you pass must match. A value the library cannot hold, such as box on a carrier library or any region on the SKU library, is rejected with 400, so a typo never looks like an empty library. Pass the same filters with every cursor. A page holds limit entries (1 to 200, default 100); when nextCursor is a string, pass it back as cursor for the next page, and when it is null you have the last one. The cursor is opaque: do not build or parse it. externalId keeps only the entries whose label is exactly that value, case-sensitive; see Look a SKU up by its code. cargoClass lists only the SKUs with one of the cargo classes you name, and is repeatable like the others (?cargoClass=glass&cargoClass=heavy). A key is as you saved it: 1 to 64 lowercase characters, and one outside that syntax is a 400. A well-formed key your account has no class for is not an error, it keeps no SKU. A carrier library has no classes, so cargoClass on it is a 400, as region is on the SKU library. Every invalid filter is reported in one 400.
A body you fetched can be posted back as a new entry: the read-only fields (id, type, scope, revision, createdAt, createdBy, updatedAt, updatedBy) are ignored. That is how you make a variant of a carrier you already saved.
Use it in a job
{
"units": { "length": "m", "weight": "kg" },
"carriers": [
{ "libraryId": "0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1", "quantity": 2 },
{ "libraryId": "0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1", "externalId": "route-north", "quantity": 1 },
{ "externalId": "SPOT-HIRE", "geometry": { "type": "box", "dimensionX": 6, "dimensionY": 2.4, "dimensionZ": 2.6 } }
],
"cargo": [
{ "externalId": "BOX-A", "amount": 120, "weight": 18, "geometry": { "type": "box", "dimensionX": 0.6, "dimensionY": 0.4, "dimensionZ": 0.4 } }
]
}
| A reference takes | From |
|---|---|
name, category, dimensions, tareWeight, maxWeight |
The entry, in the entry's own units: a trailer saved in millimetres keeps its real size in a job that speaks inches. |
externalId |
The job line when you set it, otherwise the entry. |
quantity |
The job line, as for an inline carrier. |
A reference carries libraryId and, if you like, externalId, quantity and overrides (see Load height for one job and Weight limit for one job below). Sending geometry, name, category, tareWeight or maxWeight next to libraryId is rejected with 400, field code ambiguous_source: nothing is silently overruled. A job may mix references and inline carriers, and plan limits count both alike.
An id you cannot use, unknown, deleted, another account's or malformed, is rejected with 400, field code library_entry_not_found, one error per carrier and all in one response. A MixedPalletizing job accepts only entries whose category is pallet: container, truck and trailer entries are rejected with 400 against /carriers/{i}/libraryId. POST /jobs/validate applies the same checks.
Load height for one job
A reference can adjust the referenced entry's load height for that one job, without saving a new entry, with overrides.maxStackHeight. It is in the job's units.length, the job's own unit, not the entry's.
{ "libraryId": "carrier_eur_pallet", "overrides": { "maxStackHeight": 1.2 } }
On a pallet, maxStackHeight replaces the entry's dimensionZ, the default load height above the deck (1.8 m for every pallet in the system catalogue): it may be higher or lower. On a container, truck or trailer it can only lower the usable height, never raise it past the entry's own interior:
{ "libraryId": "carrier_iso_40hc", "overrides": { "maxStackHeight": 2.4 } }
carrier_iso_40hc's interior is 2.7 m tall, so 2.4 m is accepted. A height above the interior is rejected with 400 against /carriers/{i}/overrides/maxStackHeight, and the message names the interior height in your job's units.
overrides is reference-only: an inline carrier that sends it is rejected with 400 against /carriers/{i}/overrides, one error, nothing underneath it checked separately. Any member other than maxStackHeight and maxWeight is rejected with field code override_field_not_allowed, against /carriers/{i}/overrides/<member>, the member spelled exactly as you sent it; sending it as JSON null counts as absent, like everywhere else on this surface. POST /jobs/validate applies every one of these checks the same way submit does.
Weight limit for one job
A system-catalogue carrier has no weight limit: Loadoptimizer does not know what your vehicle may carry. Set one for a job with overrides.maxWeight, in the job's units.weight; it also replaces the limit stored on your own entry, higher or lower. The limit is on the cargo and does not count the carrier's own tareWeight. A value above 100000 kg after conversion is rejected with 400 against /carriers/{i}/overrides/maxWeight.
{ "libraryId": "carrier_iso_40hc", "overrides": { "maxWeight": 26000 } }
The result then reports how much of the limit each carrier uses, in kpis.weightUtilization:
"kpis": { "volumeUtilization": 78.4, "loadedWeight": 23712, "loadedVolume": 59.1, "itemCount": 312, "weightUtilization": 91.2 }
Cargo that would take a carrier past its limit moves on to the next carrier (another of the same entry while its quantity allows, then the next entry), or is left in unplacedItems when no carrier takes it. weightUtilization is null for a carrier without a limit.
In the result
"carriers": [
{ "libraryId": "0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1", "externalId": "TRL-136", "name": "Trailer 13.6", "instance": 1, ... },
{ "libraryId": "0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1", "externalId": "route-north", "name": "Trailer 13.6", "instance": 1, ... },
{ "libraryId": null, "externalId": "SPOT-HIRE", "name": null, "instance": 1, ... }
]
Every result carrier has libraryId: the entry it referenced, or null for an inline carrier. externalId is the label, the line's or else the entry's; when neither has one, it is null, and libraryId is what tells the carriers apart. When one entry appears on two lines of a job, give each line its own externalId, as above.
Remove a carrier
curl -X DELETE https://api.loadoptimizer.ai/v2/libraries/5f0c6a8e-3b1d-5e2a-9c47-81d2f6a0b3e4/entries/0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1 \
-H "X-Api-Key: ck_live_..."
The answer is 204. The entry is gone for good; jobs submitted before keep their own copy, and a job submitted afterwards with its id gets library_entry_not_found. To change an entry rather than remove it, change part of it with PATCH (Change part of an entry) or replace it with PUT (Replace an entry). A DELETE takes If-Match too, and answers 412 when the entry changed since you read it.
SKU libraries
A SKU is one of the cargo units you ship, a carton, a crate, a product, saved once with its box dimensions, its weight per unit and its constraints. A cargo line in a job then names it by id and says how many, instead of repeating its dimensions and weight. Your account has one company SKU library, "Company SKUs", with type: "sku": GET /libraries lists it after your carrier library, and ?type=sku lists only it. Like the carrier library, its id is a UUID that is stable for your account and exists before you save anything. It is managed on the same routes, with the same q, limit and cursor, the same Idempotency-Key on a create and the same DELETE.
Save a SKU
curl -X POST https://api.loadoptimizer.ai/v2/libraries/9b3d7e21-4c6a-5f18-8e2b-6a0d4c9f1e73/entries \
-H "X-Api-Key: ck_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 5c1e9a7d-sku-4711" \
-d '{
"externalId": "SKU-4711",
"name": "Carton 60x40",
"category": "box",
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 600, "dimensionY": 400, "dimensionZ": 400 },
"weight": 18,
"constraints": { "allowStackingOnTop": true },
"classes": ["glass"]
}'
The answer is 201 with the SKU, its Location header pointing at it:
{
"id": "0197d1e4-2a6b-7f3c-8d15-4b9e0c7a2f68",
"type": "sku",
"scope": "company",
"externalId": "SKU-4711",
"name": "Carton 60x40",
"note": null,
"category": "box",
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 600, "dimensionY": 400, "dimensionZ": 400 },
"weight": 18,
"constraints": { "allowStackingOnTop": true, "sameSkuStacking": "none", "allowedRotations": ["Z"] },
"classes": ["glass"],
"revision": 1,
"createdAt": "2026-09-30T09:41:07.226+00:00",
"createdBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedAt": "2026-09-30T09:41:07.226+00:00"
}
| Field | Rule |
|---|---|
name |
Required, up to 256 characters. A cargo line that references the SKU and sends no description label is labelled with this name. |
geometry |
Required, box. The same size rules as an inline cargo line: every dimension above 0, at least 1 mm after rounding, at most 100 m. |
weight |
Required, per unit, 0 to 100000 kg after conversion. |
units |
Optional; m and kg when omitted, each member on its own. The SKU keeps them and echoes every value in them. |
externalId |
Optional, 1 to 128 characters: your code for the SKU. Unique within the library when set, and case-sensitive; see The SKU code. |
category |
Optional: box, as on a cargo line, matched in any case. Omit it and box is stored. |
note |
Optional note about the SKU, 1 to 1000 characters; null when not set. It stays in the library: a job that references the SKU does not copy it, and it is not the description label of a cargo line. |
constraints |
Optional: allowStackingOnTop, sameSkuStacking and allowedRotations, with the same rules as on an inline cargo line (see Constraints). Stored filled in, see below. |
classes |
Optional. The SKU's cargo class: a list of at most one key your account has (see Cargo classes). Absent or null stores an empty list. Saving a class needs cargo_classes.read as well. A job that references the SKU takes its class. |
Constraints are stored filled in. A member of constraints you leave out is stored with the default an inline cargo line gets: allowStackingOnTop: false, sameSkuStacking: "none", and allowedRotations: ["Z"], upright and free to spin about Z. The SKU above sent only allowStackingOnTop, so it reads back with sameSkuStacking: "none" and allowedRotations: ["Z"]. What you read is exactly what a job that references the SKU gets, and a SKU you saved keeps the values it was saved with. allowedRotations comes back in X, Y, Z order, whatever order you sent.
geometry.type and the fields of constraints may grow; tolerate values and fields you do not know. box is the only geometry today, on a SKU as on a cargo line.
The SKU code
On a SKU, externalId is your code for it, and unlike a carrier's label it is unique: no two SKUs in the library have the same one. The match is case-sensitive, so SKU-1 and sku-1 are two codes. Saving a SKU, or replacing one, with a code another SKU already has answers 409:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.10",
"title": "An entry with this externalId already exists.",
"status": 409,
"code": "external_id_taken",
"detail": "externalId is unique within a SKU library. Update that entry, or use another code.",
"resource": { "type": "library_entry", "id": "0197c3b1-2d4e-7f10-8a3b-5c6d7e8f9a01" }
}
resource.id is the SKU that has the code: PUT your SKU there to replace it, or pick another code.
A SKU without a code never collides with another. A retry with the same Idempotency-Key and body is checked before the code, so it still answers 201 with the SKU the first request created, as long as that SKU exists. Posting a fetched SKU back as a new one, as you can with a carrier, needs a new code, or none.
Look a SKU up by its code
curl "https://api.loadoptimizer.ai/v2/libraries/9b3d7e21-4c6a-5f18-8e2b-6a0d4c9f1e73/entries?externalId=SKU-4711" \
-H "X-Api-Key: ck_live_..."
{
"items": [
{
"id": "0197d1e4-2a6b-7f3c-8d15-4b9e0c7a2f68",
"type": "sku",
"scope": "company",
"externalId": "SKU-4711",
"name": "Carton 60x40",
"note": null,
"category": "box",
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 600, "dimensionY": 400, "dimensionZ": 400 },
"weight": 18,
"constraints": { "allowStackingOnTop": true, "sameSkuStacking": "none", "allowedRotations": ["Z"] },
"classes": ["glass"],
"revision": 1,
"createdAt": "2026-09-30T09:41:07.226+00:00",
"createdBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedAt": "2026-09-30T09:41:07.226+00:00"
}
],
"nextCursor": null
}
?externalId= keeps only the entries whose externalId is exactly this value, case-sensitive. On the SKU library that is at most one, so items holds the SKU or is empty: the lookup to use when your own system knows the code but not our id. It works on a carrier library too, where labels may repeat and it can return several. cargoClass lists only the SKUs with one of the cargo classes you name (repeatable); it combines with q and externalId, and on a carrier library it is a 400. q is the looser search, a case-insensitive substring of name or externalId; send both and an entry must match both.
Change part of an entry
PATCH /libraries/{id}/entries/{entryId} changes only the members you send, for both types. The body is a JSON merge patch (RFC 7396): send it as application/merge-patch+json, or as application/json with the same meaning. Use it whenever you do not hold the whole definition, or do not want to send it again: a client that only knows some members of an entry cannot drop the others by accident, as it can with a PUT.
- A member you send replaces the stored one; a member you leave out keeps its value.
- An object member (
units,geometry,constraints) merges member by member:{ "geometry": { "dimensionZ": 2800 } }changes the height and leaves the other two dimensions alone. - A member sent as
nullis cleared. That is the opposite ofPOSTandPUT, where an optional member sent asnullcounts as absent. A member the entry cannot be without (name,categoryandgeometryon a carrier;name,geometryandweighton a SKU) answers400against it. - An array replaces the stored one whole:
classesandconstraints.allowedRotationsare never merged item by item. id,type,scope,revision,createdAt,createdBy,updatedAtandupdatedByin the body are ignored, so a body you fetched can be edited and sent back.
Rename a trailer and nothing else:
curl -X PATCH https://api.loadoptimizer.ai/v2/libraries/5f0c6a8e-3b1d-5e2a-9c47-81d2f6a0b3e4/entries/0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1 \
-H "X-Api-Key: ck_live_..." \
-H "Content-Type: application/merge-patch+json" \
-d '{ "name": "Trailer 13.6 north" }'
The answer is 200 with the whole entry as it is now stored, and its ETag. maxWeight, region, units and every other member are as they were:
{
"id": "0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1",
"type": "carrier",
"scope": "company",
"externalId": "TRL-136",
"name": "Trailer 13.6 north",
"note": "Tail lift for the northern route",
"category": "trailer",
"region": null,
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 13600, "dimensionY": 2480, "dimensionZ": 2700 },
"tareWeight": 7200,
"maxWeight": 24000,
"revision": 2,
"createdAt": "2026-09-24T08:12:33.412+00:00",
"createdBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedAt": "2026-10-22T09:30:12.118+00:00"
}
To clear the note, send { "note": null }. To take a SKU out of its cargo class, send { "classes": [] }. A patch without classes leaves the stored classes as they are, and needs no permission for them: only a patch whose classes holds a key needs cargo_classes.read as well, as a PUT does, and that 403 comes before the 404 for an unknown entry, as PUT does. revision goes up by 1 and updatedAt changes on every PATCH, an empty {} included. A job you already submitted keeps its own copy, so a PATCH never changes it.
A change of unit needs its numbers
An entry keeps the units it was written in, and the API never converts a stored number. So a patch that changes a unit has to say what the numbers become in the new one. If it does not, it answers 400 validation_failed and nothing changes:
units.weight: the patch must also carry every weight number the entry stores. On a carrier that ismaxWeightandtareWeight, each one that is notnullin the stored entry; on a SKU it isweight. The error points at/units/weight.units.length: the patch must also carrygeometry.dimensionX,dimensionYanddimensionZ. The error points at/units/length.
The unit the entry has now is the stored one, or the default (kg, m) when it stores none. Sending the unit the entry already has is no change, and clearing a unit with null is one when the default differs from the stored unit. PUT has no such rule: it carries every number in the unit it names.
curl -X PATCH https://api.loadoptimizer.ai/v2/libraries/5f0c6a8e-3b1d-5e2a-9c47-81d2f6a0b3e4/entries/0197c3a0-5b1e-7c2d-9a41-2f6e8d0b11a1 \
-H "X-Api-Key: ck_live_..." \
-H "Content-Type: application/merge-patch+json" \
-d '{ "units": { "weight": "t" } }'
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "Validation failed.",
"status": 400,
"code": "validation_failed",
"errors": [
{ "pointer": "/units/weight", "code": "validation_failed", "message": "Changing units.weight needs the weights in the same patch: send maxWeight and tareWeight in the new unit." }
]
}
Send the unit with its numbers, and it is accepted: { "units": { "weight": "t" }, "tareWeight": 7.2, "maxWeight": 24 }.
Change it only if it is unchanged
Every entry answers with an ETag: its revision in quotes, such as "2", on every read and write: GET, POST, PUT and PATCH. Send it back as If-Match with a PATCH, PUT or DELETE, and the change applies only while the entry still has that revision. If someone changed it in between, the answer is 412 revision_mismatch with currentRevision, and nothing changes: read the entry again and reapply your change. * matches any revision, and a value that is not the current ETag is a 412, never a 400.
Without If-Match the change applies to whatever is stored, and a patch never loses a change someone else made to another member in the meantime. If concurrent writes to the entry keep colliding with yours, the answer is 503 entry_write_conflict; nothing changed, and the same request can be sent again.
The order of the checks
The patch's own shape is checked before the entry is looked up; the merged entry is checked after it. A request that fails more than one check gets the first of these:
415for a media type other thanapplication/merge-patch+jsonorapplication/json(application/json-patch+jsonis a different format and is refused; theAccept-Patchheader names what is accepted), and400for malformed JSON, anullon a member the entry cannot be without, or a member of the wrong JSON type.403 permission_deniedfor a non-emptyclasseswithoutcargo_classes.read. The patch itself shows it, so it is answered before the entry is looked up, asPUTdoes.404 library_entry_not_foundfor an entry that does not exist.412 revision_mismatchfor a staleIf-Match.400on the merged entry: every rule aPUTapplies to its body, and the unit rule above.409 external_id_takenfor a SKU code another SKU has.
The permission for the operation itself, carrier_libraries.entries.update or sku_libraries.entries.update, is checked before all of these, as everywhere. On carrier_system_default, PATCH answers 403 library_read_only, like PUT.
Replace an entry
PUT /libraries/{id}/entries/{entryId} replaces an entry's whole definition, for both types: a carrier in your carrier library, a SKU in your SKU library. The body is the one POST takes on that library, under the same rules. It is a full replacement, not a patch: a member you leave out gets what it would get on a create (null, the default units, the default constraints), not the value it had, so send the whole definition every time. To change only some members, use PATCH instead: see Change part of an entry.
curl -X PUT https://api.loadoptimizer.ai/v2/libraries/9b3d7e21-4c6a-5f18-8e2b-6a0d4c9f1e73/entries/0197d1e4-2a6b-7f3c-8d15-4b9e0c7a2f68 \
-H "X-Api-Key: ck_live_..." \
-H "Content-Type: application/json" \
-d '{
"externalId": "SKU-4711",
"name": "Carton 60x40",
"category": "box",
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 600, "dimensionY": 400, "dimensionZ": 400 },
"weight": 21,
"constraints": { "allowStackingOnTop": true },
"classes": []
}'
The answer is 200 with the entry as it is now stored:
{
"id": "0197d1e4-2a6b-7f3c-8d15-4b9e0c7a2f68",
"type": "sku",
"scope": "company",
"externalId": "SKU-4711",
"name": "Carton 60x40",
"note": null,
"category": "box",
"units": { "length": "mm", "weight": "kg" },
"geometry": { "type": "box", "dimensionX": 600, "dimensionY": 400, "dimensionZ": 400 },
"weight": 21,
"constraints": { "allowStackingOnTop": true, "sameSkuStacking": "none", "allowedRotations": ["Z"] },
"classes": [],
"revision": 2,
"createdAt": "2026-09-30T09:41:07.226+00:00",
"createdBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedBy": { "type": "apiKey", "id": "0192f3a4-7e8f-7a9b-8c0d-1e2f3a4b5c6d", "via": null },
"updatedAt": "2026-09-30T14:05:51.903+00:00"
}
revision goes up by 1 and updatedAt changes on every PUT or PATCH; the id and the entry's place in the list stay. The read-only members (id, type, scope, revision, createdAt, createdBy, updatedAt and updatedBy) in the body are ignored, so a body you fetched can be edited and sent back. There is no Idempotency-Key on a PUT: sending the same body again stores the same definition, and raises revision once more. A job you already submitted keeps its own copy, so a PUT never changes it; only jobs submitted afterwards see the new definition. A SKU's own current code is no conflict; another SKU's code answers 409 external_id_taken; resource names the SKU that has the code. The body is checked before the entry is looked up, so an invalid body answers 400 even for an id that does not exist, and an unknown id with a valid body answers 404 library_entry_not_found. On carrier_system_default, PUT answers 403 library_read_only, like POST, PATCH and DELETE. A PUT takes If-Match too, with the ETag of the entry: see Change it only if it is unchanged.
Use a SKU in a job
{
"libraryId": "0197d1e4-2a6b-7f3c-8d15-4b9e0c7a2f68",
"amount": 24,
"overrides": { "constraints": { "allowStackingOnTop": true } }
}
A cargo line that carries libraryId is a reference: the SKU supplies the geometry, weight, category and constraints, in the SKU's own units, and the line adds amount and what varies per shipment: groups, color, its own description label and externalId, and per-field overrides.constraints. The SKU is copied into the job at submit, exactly like a carrier. Every placement and unplaced item in the result carries the SKU's id in libraryId, null for an inline line. The full rules, the errors and the result are in Anatomy of a job.
Names and notes
A line in a job has a display name that the result echoes; an entry in a library also has a note that stays in the library. Which field is which:
| Display name, echoed on the result | Note, kept in the library | |
|---|---|---|
| Carrier line in a job | name | none |
| Cargo line in a job | description | none |
| Carrier entry | name, which a referencing line takes | note |
| SKU | name, which becomes the line's description unless the line sends its own | note |
Lines and entries also carry externalId, your own code for them, which the result echoes as well.
Plans and limits
The system catalogue needs no company-library entitlement: any plan that can use the customer API can read and reference it, and libraries_not_entitled never applies to a slug. A plan without the customer API is refused on every call, the catalogue included, with 403 customer_api_not_entitled; see Authentication. Company libraries need an entitlement of their own, and they come per type: a type is available when the plan includes company libraries and its own size limit is not 0. A type that is not available is left out of GET /libraries, and every call on it, like every job carrier or cargo line that references it with a UUID libraryId, answers 403 libraries_not_entitled. That answer comes before any lookup, so it never tells you whether an id exists. The free plan, for example, includes a SKU library of two SKUs and no company carrier library; it has no customer-API access, so it uses its SKUs in the web app. The size limit caps how many entries that type's library holds: saving past it answers 422 max_library_entries, whose detail names the limit. A PUT or PATCH changes an entry rather than adding one, so it never counts against the limit. There is no such cap on the system catalogue, since only we add to it.
Key fields
| Field | Where | Notes |
|---|---|---|
libraryId |
job carrier | The id of an entry: a company entry's UUID, or a system catalogue slug such as carrier_iso_40hc, which needs no company-library entitlement. Mutually exclusive with geometry, name, category, tareWeight, maxWeight. |
externalId |
entry, job carrier or cargo line, result | On a carrier, a label, never a key: required on an inline carrier; optional on an entry and on a reference, which inherits it. On a SKU, the SKU code: unique within the library and case-sensitive; see The SKU code. |
units |
entry | The entry's own units, m and kg by default. A job never reinterprets them. |
category |
carrier entry | Required on a carrier entry: container, pallet, truck or trailer. The set may grow; tolerate values you do not know. |
category |
SKU | The kind the SKU is drawn as: box. Always set, box when the entry was written without one. A cargo line that references the SKU takes it from there. |
region |
carrier entry | Optional, on a carrier entry of either scope: europe, north_america, asia or oceania, or null. The set may grow; tolerate values you do not know. A SKU has no region; one sent is ignored. |
overrides.maxStackHeight |
job carrier (reference only) | Adjusts the referenced entry's load height for this job, in units.length. See Load height for one job. |
overrides.maxWeight |
job carrier (reference only) | The most cargo this carrier may carry in this job, in units.weight; replaces the entry's own maxWeight. See Weight limit for one job. |
libraryId |
result carrier | The entry a carrier referenced; null for an inline carrier. |
libraryId |
job cargo line | The id of a SKU in your company SKU library. Not together with geometry, weight, category, constraints or classes. See Anatomy of a job. |
overrides.constraints |
job cargo line (reference only) | Adjusts the referenced SKU's constraints for this job, per field. |
libraryId |
result placement, unplaced item | The SKU the cargo line referenced; null for an inline line. |
externalId (query) |
entry list | An exact, case-sensitive match: at most one SKU, possibly several carriers. |
cargoClass (query) |
entry list | Only the SKUs with one of these cargo class keys; repeatable. A carrier library has no classes: the filter is a 400 there. |
createdBy / updatedBy |
entry | Who created the entry, and who made the change updatedAt records (on a new entry, its creator), each as an actor: a user, with via: agent through an AI agent, or an API key. null on an entry of a system library, which Loadoptimizer maintains. createdAt says when. See Users, API keys and who did what. |
nextCursor |
entry list | Pass back as cursor; null on the last page. |
Notes & caveats
- A library or entry of another account answers exactly like one that does not exist.
- A company entry's id is a UUID, and any notation of one names the same entry, uppercase or with braces included. A system-catalogue entry's id is a permanent, case-sensitive slug, never a UUID.
- Deleting, replacing or patching an entry never changes a job you already submitted: the job holds its own copy.
- The
type,categoryandregionvocabularies may grow; tolerate values you do not know.geometry.typeand the fields ofconstraintsmay grow; tolerate values and fields you do not know.
Related
- Anatomy of a job: the two forms of a carrier entry, and a cargo line that references a SKU.
- Building load units: carriers and cargo.
- Units: how an entry's units relate to a job's.
- Errors & troubleshooting: the codes above.
- API reference: every field of the library endpoints.