API DOCUMENTATION
P4 Pack API
Reference
Integrate AI-powered 3D bin packing into your application with a single REST endpoint.
REST API
<200ms
POST
/api/packSubmit items and containers for AI-optimized 3D packing. Returns exact placement coordinates for each item.
Request Headers (commercial tier)
| Header | Required | Description |
|---|---|---|
X-Api-Key | Commercial only | API key issued by P4 Software. Required for commercial tier access. |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
items | array | Yes | Array of item objects to pack |
containers | array | Yes | Array of available container types |
singleSkuPerContainer | boolean | — | If true, each container holds only one item type |
maxContainerWeight | number | — | Maximum weight per container (uses weightUnit) |
weightUnit | string | — | "lb" or "kg" (default: "lb") |
Item Object
| Field | Type | Description |
|---|---|---|
name | string | Descriptive label for the item |
length | number | Length dimension |
width | number | Width dimension |
height | number | Height dimension |
unit | string | "in" or "cm" |
quantity | integer | Number of this item to pack (default: 1) |
uprightOnly | boolean | If true, item won't be rotated on its side |
durability | integer | Stacking durability (1-10). Higher = can support more weight on top |
weight | number | Weight per unit (uses weightUnit from request) |
color | string | Hex color for 3D visualization (e.g. "#FF6B35") |
payload | string | Custom data passed through to the response |
Container Object
| Field | Type | Description |
|---|---|---|
name | string | Descriptive label for the container |
length | number | Interior length |
width | number | Interior width |
height | number | Interior height |
unit | string | "in", "cm", or "ft" |
loadingMode | string | "topDown" (default), "frontLoad", "sideLoad" |
payload | string | Custom data passed through to the response |
Error Codes
| Code | Description |
|---|---|
400 | Invalid request body — check required fields and types |
401 | Invalid or missing API key (commercial tier) |
408 | Packing timed out — reduce item count or complexity |
429 | Rate limit exceeded — wait and retry |
GET
/api/pack/{id}Retrieve a previously stored pack result by ID.
Response fields:
id, createdAt, request, responseError: 404 if the result does not exist or has expired
GET
/api/pack/{id}/container/{index}/svgRender a 2D SVG visualization of a specific container from a pack result.
Response:
image/svg+xmlError: 404 if result or container index not found