Add a Box
Cost: 0 credit(s) per call
Endpoint
POST /v1/binpacker/box
The Bin Packer API helps you simulate real-world packaging scenarios by automatically calculating the most efficient way to fit items into shipping cartons or containers. This will be useful for estimating fulfillment needs, testing packaging constraints, or building a custom shipping logic.
You can define your own box types (like “Small Box” or “Oversized Carton”) with size and weight limits, then submit a list of items to see how they’d be packed using the available boxes. The response gives you a breakdown of what fits where, which items don’t fit, and the total weight of each box. It’s a fast, flexible tool for anything from shipping calculators to warehouse logic.
Parameters
| Header | In | Type | Required | Description |
|---|---|---|---|---|
Authorization | header | string | Yes | API Key from your console. |
Content-Type | header | string | Yes | Must be application/json. |
| name | body | string | Yes | Box name (≤ 15 chars, unique) |
| width | body | number (float) | Yes | 0 < width < 10 000 — box inner width |
| height | body | number (float) | Yes | 0 < height < 10 000 |
| depth | body | number (float) | Yes | 0 < depth < 10 000 |
| max_weight | body | number (float) | No | 0 ≤ max_weight < 10 000 (capacity) |
| box_weight | body | number (float) | No | 0 ≤ box_weight < 10 000 (tare) |
| weight_units | body | string | No | e.g. kg, default kg |
| length_units | body | string | No | e.g. cm, default cm |
JSON Response
{
"success": true,
"box_id": 42
}Response Fields
| Field | Type | Constraints / Notes | Example |
|---|---|---|---|
success | boolean | true if successful | true |
box_id | number | The ID of the box | 40 |
Code Snippets
Code ready to go! Select one of your API keys to fill in the code
Note: You can also try it in our API playground
curl -X POST https://api.wyldapi.com/v1/binpacker/box \
-H "Authorization: Bearer <YOUR_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name": "Medium-Carton",
"width": 50,
"height": 33,
"depth": 45,
"max_weight": 100,
"box_weight": 0.3,
"length_units": "cm",
"weight_units": "kg"
}'
import requests
url = "https://api.wyldapi.com/v1/binpacker/box"
headers = {
"Authorization": "Bearer <YOUR_TOKEN>",
"Content-Type": "application/json"
}
payload = {
"name": "Medium-Carton",
"width": 50,
"height": 33,
"depth": 45,
"max_weight": 100,
"box_weight": 0.3,
"length_units": "cm",
"weight_units": "kg"
}
resp = requests.post(url, json=payload, headers=headers)
print(resp.status_code, resp.json())
<?php
$ch = curl_init('https://api.wyldapi.com/v1/binpacker/box');
$body = json_encode([
'name' => 'Medium-Carton',
'width' => 50,
'height' => 33,
'depth' => 45,
'max_weight' => 100,
'box_weight' => 0.3,
'length_units' => 'cm',
'weight_units' => 'kg'
]);
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <YOUR_TOKEN>',
'Content-Type: application/json',
'Content-Length: ' . strlen($body)
],
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP $httpCode\n$response\n";
const url = 'https://api.wyldapi.com/v1/binpacker/box';
const payload = {
name: 'Medium-Carton',
width: 50,
height: 33,
depth: 45,
max_weight: 100,
box_weight: 0.3,
length_units: 'cm',
weight_units: 'kg'
};
fetch(url, {
method: 'POST',
headers: {
'Authorization': 'Bearer <YOUR_TOKEN>',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then(res => res.json().then(data => ({ status: res.status, body: data })))
.then(console.log)
.catch(console.error);
import axios from 'axios';
function addBox() {
axios.post(
'https://api.wyldapi.com/v1/binpacker/box',
{
name: 'Medium-Carton',
width: 50,
height: 33,
depth: 45,
max_weight: 100,
box_weight: 0.3,
length_units: 'cm',
weight_units: 'kg'
},
{
headers: { Authorization: 'Bearer <YOUR_TOKEN>' }
}
)
.then(res => console.log(res.data))
.catch(err => console.error(err.response?.data || err.message));
}
WyldAPI