Rates & Labels
To ship an order, get rates for it, then buy the recommended rate with the purchaseToken that comes with it. Only the rate ShipWave recommends carries a token, so it is the only rate you can buy through this API. The other rates are returned for comparison.
ShipWave packs each order into one box or several. A single-box order is bought from rates[]. A multi-box order is bought from aggregatedRates[], which totals one rate per box.
Every price is what your account is charged. Each rate, totalRate and recommendation.rate in the rates response, and the rate on each purchased label, is the amount ShipWave charges your account for that label, in USD. Buying the recommended rate charges exactly the price it was quoted at. A multi-box price is the sum of each box's label price.
Both endpoints need the write:orders scope. Getting rates is a POST, so it counts as a write call. See Authentication.
Get Shipping Rates
POST /api/v1/orders/:id/rates
Packs the order, fetches carrier rates for each package, and marks one rate as recommended. Only that rate includes a purchaseToken.
By default, ShipWave recommends the lowest-priced eligible rate. Your automation rules can change that: a rule that sets a carrier or service, or a rule that prefers one carrier over another. recommendation.source says which kind of rule applied.
Requirements
- An assigned warehouse. Otherwise you get
400(No warehouse assigned to this order). - No active shipment. An order with a label that hasn't been voided returns
409. To rate the remaining quantities of a partly shipped order, sendfulfillmentItems(see Partial Fulfillment). - Stock at the assigned warehouse for the items being rated. If the warehouse can't fulfill them, you get
400with each short SKU's needed and available quantity. - Product catalog data for every shippable line item. The item's SKU must match a product variant in the store's catalog. The variant needs a length and width greater than 0, a height (0 is accepted for letters and flats), and a weight. If any are missing, you get
400listing the SKUs, for exampleCannot generate label. Missing dimensions: SKU-123. Please set product defaults before shipping.A missing weight returns the same kind of message. A line item with no SKU is reported as missing. Variants marked as not requiring shipping are skipped.- To skip the catalog for a whole-order quote, set all four package overrides on the order with
PUT /orders/:id:lengthOverride,widthOverride,heightOverrideandweightOverrideOz. The three dimension overrides alone skip the dimension check, but each SKU still needs a catalog weight. Overrides are ignored when you sendfulfillmentItems. - For a partial shipment, you can skip the catalog by sending exact cartons in
packages.
- To skip the catalog for a whole-order quote, set all four package overrides on the order with
- Customs data for international orders. When the destination country differs from the warehouse country, each line item needs a SKU, and its catalog variant needs an HS code and a country of origin. Otherwise you get
400listing what is missing. A US address with a territory or military state code (for examplePR,GUorAE) also gets customs information, but the HS code and country of origin are not required for it. When a line item has a SKU override, customs data comes from the override SKU's variant, the same variant used for its dimensions. - A phone number for the label. Carriers such as FedEx require a phone on the label. When the order's shipping address has no phone, ShipWave puts your warehouse address's phone on the label instead. If neither has one, you get
400asking you to add a phone to the order's shipping address or to the warehouse address. - A billing account that can pay for labels. If the account can't be billed, you get
402 PAYMENT_REQUIREDbefore any carrier rates are fetched.
Request Body (optional)
You can send no body at all to rate the whole order.
| Field | Type | Required | Description |
|---|---|---|---|
fulfillmentItems | array | no | Rate only these items and quantities. See Partial Fulfillment |
packages | array | no | Exact cartons to rate instead of letting ShipWave estimate boxes. Requires fulfillmentItems |
customsValues | object | no | Per-unit declared customs value in USD, keyed by SKU, e.g. {"SKU-123": 45.00}. Use the SKU shown in customsItems[].code: the line item's SKU override when it has one. Only allowed on shipments that require customs. Each SKU must be in this shipment, and each value must be at least 0.01 with no more than two decimal places |
enforceDgCompliance | boolean | no | When true, rates that fail ShipWave's dangerous-goods checks cannot be recommended. Defaults to false, which reports findings in dgCompliance without changing the recommendation |
Fulfillment item object:
| Field | Type | Required | Description |
|---|---|---|---|
orderItemId | string | yes | Line item ID from the order |
quantity | integer | no | Units to ship, 1 or more (default 1). It cannot exceed the item's unfulfilled quantity |
Package object:
| Field | Type | Required | Description |
|---|---|---|---|
weightOz | integer | yes | Carton weight in ounces, 1–2400 |
length | number | yes | Inches, greater than 0 and at most 200 |
width | number | yes | Inches, greater than 0 and at most 200 |
height | number | yes | Inches, greater than 0 and at most 200 |
itemIds | string[] | yes | Order item IDs in this carton, listed once per unit |
Send 1 to 100 packages. Taken together, the packages' itemIds must exactly match the units in fulfillmentItems. ShipWave puts each carton's dimensions in longest-first order and raises them to at least 6 × 3 × 0.25 inches.
Example
curl -X POST https://shipwave.app/api/v1/orders/clx1abc2d3efg/rates \
-H "Authorization: Bearer sw_live_abc123..."
const res = await fetch(
"https://shipwave.app/api/v1/orders/clx1abc2d3efg/rates",
{
method: "POST",
headers: { Authorization: "Bearer sw_live_abc123..." },
}
);
const { data } = await res.json();
Response (Single-Box)
When the order packs into one box, buy from rates[]. Rate objects are abridged here; see Rate Object. Purchase tokens are shown as placeholders.
{
"data": {
"orderId": "clx1abc2d3efg",
"customsItems": [],
"easypostShipmentId": "shp_abc123",
"rates": [
{
"easypostId": "rate_abc456",
"carrier": "UPS",
"service": "Ground",
"rate": 9.75,
"deliveryDays": 5,
"deliveryDate": "2026-10-27T00:00:00Z",
"is_regional": false,
"recommended": true,
"purchaseToken": "<purchaseToken for rate_abc456>"
},
{
"easypostId": "rate_xyz789",
"carrier": "USPS",
"service": "Priority",
"rate": 12.5,
"deliveryDays": 2,
"deliveryDate": "2026-10-23T00:00:00Z",
"is_regional": false,
"recommended": false
}
],
"isMultiBox": false,
"packageCount": 1,
"aggregatedRates": [
{
"carrier": "UPS",
"service": "Ground",
"totalRate": 9.75,
"perBoxRateIds": ["rate_abc456"],
"perBoxShipmentIds": ["shp_abc123"],
"deliveryDays": 5,
"is_regional": false,
"recommended": true,
"purchaseToken": "<separate multi-box token; use rates[] instead>"
},
{
"carrier": "USPS",
"service": "Priority",
"totalRate": 12.5,
"perBoxRateIds": ["rate_xyz789"],
"perBoxShipmentIds": ["shp_abc123"],
"deliveryDays": 2,
"is_regional": false,
"recommended": false
}
],
"recommendation": {
"singleRateId": "rate_abc456",
"aggregatedRateKey": "shp_abc123|rate_abc456",
"carrier": "UPS",
"service": "Ground",
"rate": 9.75,
"source": "cheapest"
},
"perBoxShipments": [
{
"packageIndex": 0,
"easypostShipmentId": "shp_abc123",
"weightLbs": 4.2,
"dimensions": { "length": 12, "width": 10, "height": 6 },
"rates": [
{ "easypostId": "rate_abc456", "carrier": "UPS", "service": "Ground", "rate": 9.75, "deliveryDays": 5, "is_regional": false },
{ "easypostId": "rate_xyz789", "carrier": "USPS", "service": "Priority", "rate": 12.5, "deliveryDays": 2, "is_regional": false }
],
"itemIds": ["clx1item1", "clx1item1"]
}
],
"fulfillmentScope": null,
"addressVerification": {
"deliverySuccess": true,
"deliveryErrors": [],
"correctedAddress": null,
"hasCorrectedFields": false,
"correctedFields": []
},
"dgCompliance": {
"checked": false,
"enforced": false,
"hasRestrictions": false,
"messages": [],
"restrictions": []
},
"purchaseTokenTtlSeconds": 900
}
}
A single-box response also lists every rate in aggregatedRates, and the recommended entry there carries its own token. Buying with that token works, but it returns the multi-box response shape. For single-box orders, use the token from rates[].
Response (Multi-Box)
When the order needs several boxes, rates is empty and easypostShipmentId is box 1's shipment. Buy from aggregatedRates[]. Each aggregated rate combines one rate per box.
{
"data": {
"orderId": "clx1abc2d3efg",
"customsItems": [],
"easypostShipmentId": "shp_box1",
"rates": [],
"isMultiBox": true,
"packageCount": 2,
"aggregatedRates": [
{
"carrier": "UPS",
"service": "Ground",
"totalRate": 45.95,
"perBoxRateIds": ["rate_a1", "rate_a2"],
"perBoxShipmentIds": ["shp_box1", "shp_box2"],
"deliveryDays": 4,
"is_regional": false,
"recommended": true,
"purchaseToken": "<purchaseToken for UPS Ground, both boxes>"
},
{
"carrier": "FedEx",
"service": "FEDEX_GROUND",
"totalRate": 50.3,
"perBoxRateIds": ["rate_b1", "rate_b2"],
"perBoxShipmentIds": ["shp_box1", "shp_box2"],
"deliveryDays": 5,
"is_regional": false,
"recommended": false
}
],
"recommendation": {
"singleRateId": null,
"aggregatedRateKey": "shp_box1|rate_a1,shp_box2|rate_a2",
"carrier": "UPS",
"service": "Ground",
"rate": 45.95,
"source": "cheapest"
},
"perBoxShipments": [
{
"packageIndex": 0,
"easypostShipmentId": "shp_box1",
"weightLbs": 35,
"dimensions": { "length": 24, "width": 16, "height": 14 },
"rates": [
{ "easypostId": "rate_a1", "carrier": "UPS", "service": "Ground", "rate": 24.1, "deliveryDays": 4, "is_regional": false },
{ "easypostId": "rate_b1", "carrier": "FedEx", "service": "FEDEX_GROUND", "rate": 26.4, "deliveryDays": 5, "is_regional": false }
],
"itemIds": ["clx1item1", "clx1item2"]
},
{
"packageIndex": 1,
"easypostShipmentId": "shp_box2",
"weightLbs": 30,
"dimensions": { "length": 24, "width": 16, "height": 12 },
"rates": [
{ "easypostId": "rate_a2", "carrier": "UPS", "service": "Ground", "rate": 21.85, "deliveryDays": 4, "is_regional": false },
{ "easypostId": "rate_b2", "carrier": "FedEx", "service": "FEDEX_GROUND", "rate": 23.9, "deliveryDays": 5, "is_regional": false }
],
"itemIds": ["clx1item1"]
}
],
"fulfillmentScope": null,
"addressVerification": {
"deliverySuccess": true,
"deliveryErrors": [],
"correctedAddress": null,
"hasCorrectedFields": false,
"correctedFields": []
},
"dgCompliance": {
"checked": false,
"enforced": false,
"hasRestrictions": false,
"messages": [],
"restrictions": []
},
"purchaseTokenTtlSeconds": 900
}
}
In this example, line item clx1item1 has quantity 2, so it appears in both boxes.
Response Fields
| Field | Type | Description |
|---|---|---|
orderId | string | The order ID |
customsItems | array | Customs lines ShipWave will declare. Empty when the shipment doesn't need customs. See Customs Item Object |
easypostShipmentId | string | The shipment to buy for a single-box order. For a multi-box order, box 1's shipment |
rates | array | Single-box rates, lowest price first, each priced at what your account is charged. Empty for multi-box orders. See Rate Object |
isMultiBox | boolean | true when the order needs more than one box |
packageCount | number | Number of boxes |
aggregatedRates | array | One entry per combined option across all boxes. See Aggregated Rate Object |
recommendation | object | Summary of the rate to buy. See Recommendation Object |
perBoxShipments | array | One entry per box, also for single-box orders. See Per-Box Shipment Object |
fulfillmentScope | object | null | The items being rated when you sent fulfillmentItems, otherwise null |
addressVerification | object | null | The carrier's delivery-address check. null when no verification result came back |
dgCompliance | object | Dangerous-goods findings. See Dangerous Goods |
purchaseTokenTtlSeconds | number | Token lifetime in seconds (900, 15 minutes) |
Rate Object
Entries in rates[].
| Field | Type | Description |
|---|---|---|
easypostId | string | Rate ID (rate_...) |
carrier | string | Carrier name, e.g. USPS, UPS, FedEx |
service | string | Service level, e.g. Priority, Ground |
rate | number | Price in USD your account is charged for this label |
deliveryDays | number | null | Estimated transit days |
deliveryDate | string | null | Estimated delivery date (ISO 8601) |
recommended | boolean | true for the one rate ShipWave recommends |
purchaseToken | string | Present only on the recommended rate |
Rate objects can also include informational fields such as is_regional, programs, timeInTransitP85, predictedDeliveryDate and deliveryAccuracy. Which ones appear varies. They are not needed to buy a label.
Aggregated Rate Object
Entries in aggregatedRates[].
| Field | Type | Description |
|---|---|---|
carrier | string | Carrier name, or Mixed when the least-rate combination uses different carriers or services per box |
service | string | Service level, or LeastRate for a Mixed combination |
totalRate | number | Price in USD your account is charged for all the boxes: the sum of each box's label price |
perBoxShipmentIds | string[] | Shipment ID for each box |
perBoxRateIds | string[] | Rate ID for each box, in the same order as perBoxShipmentIds |
deliveryDays | number | null | Estimated transit days |
is_regional | boolean | Whether the option relies on a regional carrier |
isMixedCarrier | boolean | Present on the least-rate combination; true when its boxes use different carriers or services |
perBoxRates | array | Present on the least-rate combination: carrier, service, rate (the price you are charged for that box), deliveryDays and is_regional for each box |
recommended | boolean | true for the one aggregated rate ShipWave recommends |
purchaseToken | string | Present only on the recommended aggregated rate |
Recommendation Object
| Field | Type | Description |
|---|---|---|
singleRateId | string | null | ID of the recommended entry in rates[]. null for multi-box orders |
aggregatedRateKey | string | null | Shipment and rate pairs of the recommended aggregated rate, as shp_...|rate_... joined by commas |
carrier | string | null | Carrier of the rate to buy |
service | string | null | Service of the rate to buy |
rate | number | null | Price your account is charged for the rate to buy: the rates[] entry's rate for single-box, the aggregated totalRate for multi-box |
source | string | cheapest, carrier_service_rule (one of your rules sets a carrier or service for this order) or carrier_preference (one of your rules prefers one carrier over another). A rule that sets only a service limits the recommendation to that service on single-box and multi-box orders alike, when the service was quoted |
For a single-box order, carrier, service and rate describe the rate named by singleRateId, the rates[] entry with recommended: true. In rare cases aggregatedRateKey points to a different rate. Use singleRateId. For a multi-box order, the fields describe the recommended aggregated rate.
If no rate can be recommended, both IDs are null and no rate has a token. This can happen when enforceDgCompliance excludes every rate.
Per-Box Shipment Object
| Field | Type | Description |
|---|---|---|
packageIndex | number | Zero-based box index |
easypostShipmentId | string | Shipment ID for this box (shp_...) |
weightLbs | number | Estimated box weight in pounds (0 when no estimate was made) |
dimensions | object | Box length, width and height in inches |
rates | array | This box's rates: easypostId, carrier, service, rate (the price you are charged for this box's label), deliveryDays, is_regional, plus informational fields |
itemIds | string[] | Order item IDs packed in this box, listed once per unit. Can be empty when ShipWave did not allocate items to boxes, for example when it used order-level overrides |
Customs Item Object
| Field | Type | Description |
|---|---|---|
code | string | SKU |
description | string | Customs description from the product, or the SKU |
quantity | number | Units |
weight | number | Weight per unit in ounces |
value | number | Declared value per unit in USD. It is derived from the order line price unless you send customsValues |
hs_tariff_number | string | HS code from the product |
origin_country | string | Country of origin from the product |
Dangerous Goods
dgCompliance reports ShipWave's dangerous-goods checks for the rated carriers and services.
| Field | Type | Description |
|---|---|---|
checked | boolean | true when at least one item has dangerous-goods data to check |
enforced | boolean | Echoes enforceDgCompliance |
hasRestrictions | boolean | true when any rated carrier or service is restricted |
messages | string[] | Unique restriction reasons |
restrictions | array | One { carrier, service, reason } entry per restricted carrier and service |
With enforceDgCompliance: true, restricted rates are still listed but cannot be recommended. Send enforceDgCompliance: true on the label purchase as well, and ShipWave rechecks the bought carrier and service before buying.
Purchase Token
A purchaseToken authorizes the purchase of one recommended rate.
- It is an opaque string. Pass it back exactly as you received it, and don't parse, store long-term, or change it.
- It expires after
purchaseTokenTtlSeconds(900 seconds, 15 minutes). After that, request new rates. - It works only for the order it was issued for and the API key that fetched the rates. Using it on another of your orders, or with another of your API keys, returns
403. - It fixes the shipment and rate to buy, and, for partial fulfillment, the items covered.
If no rate has a token, fix the cause first: stock, warehouse, catalog data, dangerous-goods restrictions, or your automation rules.
Errors
| Status | Code | Cause |
|---|---|---|
| 400 | VALIDATION_ERROR | No warehouse is assigned to the order |
| 400 | VALIDATION_ERROR | The assigned warehouse can't fulfill the items being rated: not enough stock, or the warehouse isn't eligible for this order |
| 400 | VALIDATION_ERROR | A SKU has no catalog match, or its variant is missing dimensions or weight |
| 400 | VALIDATION_ERROR | International order is missing a SKU, HS code or country of origin |
| 400 | VALIDATION_ERROR | Neither the order's shipping address nor the warehouse address has a phone number |
| 400 | VALIDATION_ERROR | Invalid fulfillmentItems (empty, an item not on this order, a non-shippable item, or more than the unfulfilled quantity), packages or customsValues |
| 402 | PAYMENT_REQUIRED | The account has no business billing account that can pay for labels. details.reason names the cause |
| 403 | FORBIDDEN | The API key lacks the write:orders scope |
| 403 | FORBIDDEN | The API key can't use raw fulfillment endpoints (it carries the deny:raw_fulfillment permission) |
| 404 | NOT_FOUND | The order doesn't exist or belongs to another account |
| 409 | CONFLICT | The order already has an active shipment and the request has no fulfillmentItems |
| 500 | INTERNAL_ERROR | Rates could not be fetched, for example because the warehouse address is incomplete or the carrier request failed |
Authentication and rate-limit errors (401, 429) are described in Errors.
Purchase a Label (Single-Box)
POST /api/v1/orders/:id/labels
Buys the recommended single-box rate. The token decides what is bought. Any IDs you also send must match it.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
purchaseToken | string | yes | Token from the recommended entry in rates[] |
easypostShipmentId | string | no | If sent, must equal the token's shipment (the rates response's easypostShipmentId). Otherwise 400 |
rateId | string | no | If sent, must equal the token's rate (the recommended entry's easypostId). Otherwise 400 |
fulfillmentItems | array | no | Only for tokens from a partial-fulfillment quote. If sent, must match the token's items. You can send itemIds (one order item ID per unit) instead |
print | boolean | no | true queues the label to your configured label printer. Defaults to false |
enforceDgCompliance | boolean | no | true rechecks dangerous-goods restrictions for the carrier and service before buying. If the check fails, the purchase fails |
Example
These IDs and the token come from the recommended rate in the single-box rates response.
curl -X POST https://shipwave.app/api/v1/orders/clx1abc2d3efg/labels \
-H "Authorization: Bearer sw_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"purchaseToken": "<purchaseToken for rate_abc456>",
"easypostShipmentId": "shp_abc123",
"rateId": "rate_abc456"
}'
// rateData is the `data` object from POST /orders/:id/rates
const recommended = rateData.rates.find((rate) => rate.recommended && rate.purchaseToken);
const res = await fetch(
"https://shipwave.app/api/v1/orders/clx1abc2d3efg/labels",
{
method: "POST",
headers: {
Authorization: "Bearer sw_live_abc123...",
"Content-Type": "application/json",
},
body: JSON.stringify({
purchaseToken: recommended.purchaseToken,
easypostShipmentId: rateData.easypostShipmentId, // "shp_abc123"
rateId: recommended.easypostId, // "rate_abc456"
}),
}
);
const { data } = await res.json(); // 201 Created
Response (201 Created)
{
"data": {
"shipment": {
"id": "clx2ship1",
"trackingCode": "1Z999AA10123456784",
"labelUrl": "https://easypost-files.s3.amazonaws.com/files/postage_label/20261020/label.png",
"carrier": "UPS",
"service": "Ground",
"rate": 9.75
},
"orderStatus": "shipped",
"trackingPushResult": null,
"print": {
"requested": false,
"jobs": [],
"skippedReason": "print not requested"
}
}
}
| Field | Type | Description |
|---|---|---|
shipment | object | The new label: ShipWave shipment id, trackingCode, labelUrl, carrier, service and rate, the price in USD your account was charged for it |
orderStatus | string | null | The order's shipping status after this label: pending, partially_shipped or shipped |
trackingPushResult | object | null | For a partial-fulfillment purchase on a Shopify store, the result of pushing the scoped fulfillment and tracking to Shopify (success, plus error on failure). Otherwise null |
print | object | See Print Object |
The charge is taken from your shipping balance when the label is bought. ShipWave also sends a shipment.created webhook for the label, with the same rate.
Print Object
| Field | Type | Description |
|---|---|---|
requested | boolean | Whether you sent print: true |
jobs | array | Queued print jobs: id, status, shipmentId, trackingCode |
skippedReason | string | null | print not requested, printer settings not configured, or null when jobs were queued |
Purchase Labels (Multi-Box)
POST /api/v1/orders/:id/labels
Buys one label per box for the recommended aggregated rate. ShipWave buys the boxes one at a time, in box order.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
purchaseToken | string | yes | Token from the recommended entry in aggregatedRates[] |
purchases | array | no | Per-box entries, used to attach itemIds to each box. If omitted, the token's boxes are bought as they are |
print | boolean | no | true queues every label to your configured label printer |
enforceDgCompliance | boolean | no | true rechecks dangerous-goods restrictions for each box before buying it |
Per-box purchase object:
| Field | Type | Required | Description |
|---|---|---|---|
easypostShipmentId | string | yes | The box's shipment ID |
rateId | string | yes | The box's rate ID |
itemIds | string[] | no | Order item IDs in this box, listed once per unit. Use perBoxShipments[].itemIds from the rates response |
If you send purchases, it must contain exactly the shipment and rate pairs in the token: perBoxShipmentIds[i] with perBoxRateIds[i]. If any box has itemIds, every box must. When the token comes from a partial-fulfillment quote, it already holds each box's items, and any itemIds you send must match them.
Example
These IDs and the token come from the recommended aggregated rate in the multi-box rates response.
curl -X POST https://shipwave.app/api/v1/orders/clx1abc2d3efg/labels \
-H "Authorization: Bearer sw_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"purchaseToken": "<purchaseToken for UPS Ground, both boxes>",
"purchases": [
{
"easypostShipmentId": "shp_box1",
"rateId": "rate_a1",
"itemIds": ["clx1item1", "clx1item2"]
},
{
"easypostShipmentId": "shp_box2",
"rateId": "rate_a2",
"itemIds": ["clx1item1"]
}
]
}'
Response (201 Created)
{
"data": {
"isMultiBox": true,
"shipments": [
{
"id": "clx2ship1",
"trackingCode": "1Z999AA10123456784",
"labelUrl": "https://easypost-files.s3.amazonaws.com/files/postage_label/20261020/box1.png",
"carrier": "UPS",
"service": "Ground",
"rate": 24.1,
"boxIndex": 0
},
{
"id": "clx2ship2",
"trackingCode": "1Z999AA10123456785",
"labelUrl": "https://easypost-files.s3.amazonaws.com/files/postage_label/20261020/box2.png",
"carrier": "UPS",
"service": "Ground",
"rate": 21.85,
"boxIndex": 1
}
],
"orderStatus": "shipped",
"trackingPushResults": [
{ "orderId": "clx1abc2d3efg", "orderNumber": "#1042", "success": true },
{ "orderId": "clx1abc2d3efg", "orderNumber": "#1042", "success": true }
],
"print": {
"requested": false,
"jobs": [],
"skippedReason": "print not requested"
}
}
}
When the purchase carries itemIds and the store is a Shopify store, trackingPushResults has up to one entry per box: the result of pushing that box's fulfillment and tracking to Shopify. Otherwise it is empty. ShipWave sends a shipment.created webhook for each label.
If a Box Fails
ShipWave does not buy the boxes as one unit. If a box fails, the request stops, and ShipWave voids each label it already bought in that request with the carrier, the same way POST /shipments/:id/void does. A label counts as voided only when the carrier accepts the void. The response says what happened to each one:
{
"error": {
"code": "INTERNAL_ERROR",
"message": "Failed on box 2 of 2: <reason>. The label already bought in this request was voided.",
"details": {
"failedBoxIndex": 1,
"rolledBack": true,
"voidedShipmentCount": 1,
"voidFailedShipmentCount": 0,
"labels": [
{
"shipmentId": "clx2ship1",
"boxIndex": 0,
"trackingCode": "1Z999AA10123456784",
"voidStatus": "voided",
"refundStatus": "submitted"
}
]
}
}
}
The status and code follow the failed box's cause, as for a single-box purchase: 402 PAYMENT_REQUIRED for a funding problem, 409 CONFLICT for a voided label or a missing Shopify order, 502 when the carrier rejected the box, 503 while a purchase is being reconciled, and 500 for anything else. details.reason is set for the first four.
| Field | Type | Description |
|---|---|---|
failedBoxIndex | number | Zero-based index of the box that failed |
rolledBack | boolean | true when every label bought in this request was voided (also true when none had been bought) |
voidedShipmentCount | number | Labels the carrier accepted a void for |
voidFailedShipmentCount | number | Labels that were not voided and are still active |
labels | array | One entry per label bought in this request: shipmentId, boxIndex, trackingCode, voidStatus, refundStatus, and message when the void did not go through |
voidStatus is one of:
voided: the carrier accepted the void.refundStatusis the carrier's refund state (submittedorrefunded). Any balance credit follows the void refund rules.void_failed: the carrier refused the void. The label is still active and is recorded with statusvoid_failed.not_voided: the void could not be confirmed (for example the carrier could not be reached, or the label was already scanned). The label is still active.
When a label is still active, the message says so, for example 0 of 1 labels already bought in this request were voided; 1 could not be voided and is still active.
To recover:
- Don't retry with the same token.
- Void any label whose
voidStatusis notvoided, if you don't want it, withPOST /shipments/:id/void. You can also check the order withGET /orders/:id: a shipment withvoidedAt: nullis still active. - Request new rates and buy with the new token.
Partial Fulfillment
To ship part of an order, send fulfillmentItems when you request rates:
curl -X POST https://shipwave.app/api/v1/orders/clx1abc2d3efg/rates \
-H "Authorization: Bearer sw_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"fulfillmentItems": [
{ "orderItemId": "clx1item1", "quantity": 1 }
]
}'
- Each quantity can't be more than the item's unfulfilled quantity, which excludes units already on an active label.
- An order that already has active shipments can be rated this way for its remaining quantities.
- ShipWave packs the selected items from product catalog data. Order-level weight and dimension overrides don't apply. To set exact cartons, add
packages. - The response's
fulfillmentScopelists the items being rated:
"fulfillmentScope": {
"itemIds": ["clx1item1"],
"items": [
{ "orderItemId": "clx1item1", "sku": "SKU-123", "name": "Widget", "quantity": 1 }
]
}
The purchase token covers exactly these items, so buy the label with the token alone. On a Shopify store, ShipWave then pushes a fulfillment for just those line items, and the label response reports the result in trackingPushResult (trackingPushResults for multi-box). orderStatus is partially_shipped until every shippable unit is on an active label.
With exact cartons:
{
"fulfillmentItems": [{ "orderItemId": "clx1item1", "quantity": 2 }],
"packages": [
{ "weightOz": 480, "length": 18, "width": 14, "height": 10, "itemIds": ["clx1item1"] },
{ "weightOz": 480, "length": 18, "width": 14, "height": 10, "itemIds": ["clx1item1"] }
]
}
Retries and Idempotency
Replaying a successful purchase. If you POST again with the same token, while it is still valid, after the purchase succeeded, you get 200 OK with the existing labels instead of a new purchase:
- Single-box:
{ "shipment": { ... }, "print": { ... } } - Multi-box:
{ "isMultiBox": true, "shipments": [ ... ], "print": { ... } }
A replay doesn't include orderStatus or tracking push results. If the replay sends print: true, ShipWave queues another print job.
A purchase already in progress. Only one label purchase can run for an order at a time, whether it comes from the API, the dashboard or auto-ship. The same applies while ShipWave is changing the order's address or items. During that time, you get 409 CONFLICT with A label is already being bought for this order (auto-ship or another buy). Refresh the order in a few seconds before buying another label. Wait a few seconds and retry.
Timeouts, 500s and 503s (single-box). Retry the same request with the same token while it is still valid. If the first attempt bought the label, you get it back. ShipWave won't buy a second label for the same shipment.
Timeouts (multi-box). Give the first request time to finish, since each box is bought separately. Then call GET /orders/:id. If every box has an active shipment, the purchase succeeded. Otherwise, follow If a Box Fails.
After the token expires. A retry after 15 minutes returns 400 VALIDATION_ERROR with Invalid purchaseToken: Token expired. Requesting new rates won't help if the label was bought: the order now has an active shipment, so rates return 409 CONFLICT. To recover, call GET /orders/:id and read its shipments. An entry whose shipment.voidedAt is null is the active label, with its trackingCode and labelUrl.
After voiding a label. Request new rates before buying again. Reusing a still-valid token from the voided purchase returns 409 CONFLICT with details.reason: "label_refunded", because a voided label can't be bought again.
End-to-End Example
const API = "https://shipwave.app/api/v1";
const headers = {
Authorization: `Bearer ${process.env.SHIPWAVE_API_KEY}`,
"Content-Type": "application/json",
};
async function shipOrder(orderId: string) {
// 1. Get rates
const ratesRes = await fetch(`${API}/orders/${orderId}/rates`, {
method: "POST",
headers,
});
const ratesBody = await ratesRes.json();
if (!ratesRes.ok) {
throw new Error(`${ratesRes.status} ${ratesBody.error.code}: ${ratesBody.error.message}`);
}
const rateData = ratesBody.data;
// 2. Build the purchase from the recommended rate
let purchase: Record<string, unknown>;
if (rateData.isMultiBox) {
const chosen = rateData.aggregatedRates.find((r) => r.recommended && r.purchaseToken);
if (!chosen) throw new Error("No purchasable rate. Check dgCompliance and the order setup.");
const boxes = chosen.perBoxShipmentIds.map((shipmentId: string, i: number) => ({
easypostShipmentId: shipmentId,
rateId: chosen.perBoxRateIds[i],
itemIds:
rateData.perBoxShipments.find((b) => b.easypostShipmentId === shipmentId)?.itemIds ?? [],
}));
const everyBoxHasItems = boxes.every((b) => b.itemIds.length > 0);
purchase = {
purchaseToken: chosen.purchaseToken,
// Optional: link each box's label to the items packed in it
...(everyBoxHasItems && { purchases: boxes }),
};
} else {
const chosen = rateData.rates.find((r) => r.recommended && r.purchaseToken);
if (!chosen) throw new Error("No purchasable rate. Check dgCompliance and the order setup.");
purchase = {
purchaseToken: chosen.purchaseToken,
easypostShipmentId: rateData.easypostShipmentId,
rateId: chosen.easypostId,
};
}
// 3. Buy the label(s): 201 for a new purchase, 200 for a replay
const labelRes = await fetch(`${API}/orders/${orderId}/labels`, {
method: "POST",
headers,
body: JSON.stringify(purchase),
});
const labelBody = await labelRes.json();
if (!labelRes.ok) {
throw new Error(`${labelRes.status} ${labelBody.error.code}: ${labelBody.error.message}`);
}
const labels = labelBody.data.isMultiBox ? labelBody.data.shipments : [labelBody.data.shipment];
for (const label of labels) {
console.log(`${label.carrier} ${label.service}: ${label.trackingCode} ${label.labelUrl}`);
}
}
Errors
| Status | Code | Cause |
|---|---|---|
| 400 | VALIDATION_ERROR | The request body isn't valid JSON |
| 400 | VALIDATION_ERROR | The order is blocked from fulfillment by a hold (Order … is blocked from fulfillment: …) |
| 400 | VALIDATION_ERROR | No warehouse is assigned to the order |
| 400 | VALIDATION_ERROR | Invalid purchaseToken: …: missing, malformed, invalid signature, or Token expired |
| 400 | VALIDATION_ERROR | easypostShipmentId, rateId, purchases, itemIds or fulfillmentItems don't match the token. Also returned when item IDs are sent with a token that has no item scope, or include items not on this order |
| 400 | VALIDATION_ERROR | Not enough stock at the assigned warehouse, or the items are no longer unfulfilled |
| 402 | PAYMENT_REQUIRED | The account can't pay for the label: the shipping balance is too low, funding is past due or not approved, a payment method is missing or needs confirmation, or the plan's label limit is reached. The message says what to fix, and details.reason names the cause (for example insufficient_balance) |
| 403 | FORBIDDEN | purchaseToken does not match this order/API key |
| 403 | FORBIDDEN | The API key lacks the write:orders scope, or carries the deny:raw_fulfillment permission |
| 404 | NOT_FOUND | The order doesn't exist or belongs to another account |
| 409 | CONFLICT | Another label purchase for this order is in progress |
| 409 | CONFLICT | The order already has an active shipment that this token didn't buy, and the purchase isn't limited to specific items |
| 409 | CONFLICT | The token's label was voided (details.reason: "label_refunded"). Request new rates and buy with the new token |
| 409 | CONFLICT | The linked Shopify order can't be found |
| 502 | INTERNAL_ERROR | The carrier rejected the purchase (details.reason: "carrier_rejected"). When the carrier explained why, for example a missing phone or an invalid address, the message includes it. Fix the order and request new rates |
| 503 | INTERNAL_ERROR | The carrier has not confirmed whether the label was bought (details.reason: "purchase_reconciliation_required"). Retry the same request with the same token in a minute |
| 500 | INTERNAL_ERROR | Any other failure, for example a pre-purchase check. Single-box returns Internal server error. Multi-box returns Failed on box N of M: … (see If a Box Fails) |