Batches
Buy labels in bulk asynchronously, with per-shipment results.
A batch buys labels for up to 100 shipments in a single call. Processing is asynchronous: the request returns immediately and you poll progress shipment by shipment.
Buy in bulk
Use a key with both batches:write and labels:write. If you lose the response, retry the same selections with the same Idempotency-Key. If you receive 409 IDEMPOTENCY_KEY_IN_USE, check your existing batches before starting another purchase.
Send each draft shipment with its selected quote using shipmentId and rateId. An expired quote or a shipment that is no longer a draft prevents creation of the entire batch. If a quote expires after creation, only that item fails. Review a new quote before buying it again.
itemsobject[]
1 to 100 items, each with a shipmentId and its chosen rateId. Duplicate selections are rejected; shipments that already have a label or are inaccessible do not count as successes.
object[]curl -X POST https://api.sendit.mx/v1/batches \
-H "X-API-Key: sk_test_..." \
-H "Idempotency-Key: 71de31be-d84f-4ecc-8557-21e02b18cf65" \
-H "Content-Type: application/json" \
-d '{
"items": [
{ "shipmentId": "clxship_aaa", "rateId": "qt_01J8Z9K2M4N6P8Q0R2S4T6" },
{ "shipmentId": "clxship_bbb", "rateId": "qt_01J9A3B5C7D9E1F3G5H7J9K1" },
{ "shipmentId": "clxship_ccc", "rateId": "qt_01J9B4C6D8E0F2G4H6J8K0M2" }
]
}'
Response 201 Created
{
"success": true,
"data": {
"id": "bat_xyz",
"object": "batch",
"status": "PENDING",
"livemode": false,
"totalShipments": 3,
"purchasedCount": 0,
"failedCount": 0,
"items": [
{ "shipmentId": "clxship_aaa", "rateId": "qt_01J8Z9K2M4N6P8Q0R2S4T6", "status": "PENDING", "purchaseAttemptId": null, "errorCode": null },
{ "shipmentId": "clxship_bbb", "rateId": "qt_01J9A3B5C7D9E1F3G5H7J9K1", "status": "PENDING", "purchaseAttemptId": null, "errorCode": null },
{ "shipmentId": "clxship_ccc", "rateId": "qt_01J9B4C6D8E0F2G4H6J8K0M2", "status": "PENDING", "purchaseAttemptId": null, "errorCode": null }
],
"createdAt": "2026-07-17T12:00:00.000Z",
"completedAt": null
}
}
Track progress
| Status | Meaning |
|---|---|
PENDING |
Queued, not started |
PROCESSING |
Buying labels |
ACTION_REQUIRED |
At least one purchase is awaiting confirmation. Keep polling this batch and keep the original purchase reference. |
COMPLETED |
Every label purchased |
PARTIAL |
Some purchased, some failed |
FAILED |
No label purchased |
Poll GET /v1/batches/:id — each item reports its own outcome:
{
"success": true,
"data": {
"id": "bat_xyz",
"object": "batch",
"status": "PARTIAL",
"livemode": false,
"totalShipments": 3,
"purchasedCount": 2,
"failedCount": 1,
"items": [
{ "shipmentId": "clxship_aaa", "rateId": "qt_01J8Z9K2M4N6P8Q0R2S4T6", "status": "SUCCEEDED", "purchaseAttemptId": "lat_550e8400-e29b-41d4-a716-446655440000", "errorCode": null },
{ "shipmentId": "clxship_bbb", "rateId": "qt_01J9A3B5C7D9E1F3G5H7J9K1", "status": "SUCCEEDED", "purchaseAttemptId": "lat_550e8400-e29b-41d4-a716-446655440001", "errorCode": null },
{ "shipmentId": "clxship_ccc", "rateId": "qt_01J9B4C6D8E0F2G4H6J8K0M2", "status": "FAILED", "purchaseAttemptId": null, "errorCode": "INSUFFICIENT_BALANCE" }
],
"createdAt": "2026-07-17T12:00:00.000Z",
"completedAt": "2026-07-17T12:01:04.000Z"
}
}
items[].status can be PENDING, PROCESSING, SUCCEEDED, FAILED, or ACTION_REQUIRED — the last means that purchase’s outcome could not be resolved automatically; keep the purchaseAttemptId instead of retrying blindly.
GET /v1/batches lists your batches in the current mode. Pass meta.nextCursor as cursor to fetch the next page. A null cursor marks the end.
Bulk endpoints
For bulk read and validation operations — not purchases — use the bulk endpoints. They share the same partial-success semantics, accept up to 100 elements, and return one result per element in request order:
| Method | Path | Description |
|---|---|---|
POST |
/v1/bulk/addresses/validate |
Validate up to 100 addresses |
POST |
/v1/bulk/tracking/lookup |
Look up events for up to 100 tracking numbers |
POST |
/v1/bulk/shipments/fetch |
Fetch up to 100 shipments by ID |
POST |
/v1/bulk/orders/fetch |
Fetch up to 100 orders by ID |
curl -X POST https://api.sendit.mx/v1/bulk/shipments/fetch \
-H "X-API-Key: sk_test_..." \
-H "Content-Type: application/json" \
-d '{ "ids": ["clxship_aaa", "clxship_bbb", "clxship_zzz"] }'
{
"success": true,
"data": [
{ "id": "clxship_aaa", "found": true, "data": { "...": "..." } },
{ "id": "clxship_bbb", "found": true, "data": { "...": "..." } },
{ "id": "clxship_zzz", "found": false, "data": null }
]
}
A nonexistent ID — or one from another organization — returns found: false and never fails the whole batch. Deleted resources count as not found.