Process Batch
Processing a batch means you'll be creating and purchasing the labels for the shipments included in that batch. Once processed, you can then get the batch details by batch ID to download the batch labels and forms as well as check that batch status and the review any errors that may have occurred.
If you are new to batches in ShipEngine, be sure to read the Label Batches overview first.
To use batches successfully, you should also understand how to create a shipment, how to get shipping rates, and the basics around carrier services.
Requirements
- The
batch_id
for the batch you wish to process. - All shipments in a batch, whether added with
shipment_id
orrate_id
must have acarrier_id
andservice_code
. If the shipments included in the batch do not explicitly specify their carrier and service, you'll recieve an error. - All shipments in a batch must be shipped from the same warehouse. This means all shipments in a batch must be assigned the same
warehouse_id
.
Specifying a Label Format & Layout
You may optionally specify a format and layout for all the labels created with a batch. Unless otherwise specified, labels will be generated as 4x6 PDFs.
Example Request
POST /v1/batches/:batch_id/process/labels
In this example request, we specify label layout, format, and ship_date
.
Error Handling
Errors in batches must be handled differently from synchronous requests. You must retrieve the status of your batch by getting a batch and getting an overview of the statuses, or by listing the batch errors.
Invalid or Completed with Errors
If the batch enters an Invalid or Completed with Errors state, you cannot re-use the batch.
- List the batch errors to extract the shipments and the reasons why they failed.
- Correct the errors in the shipments by updating the shipment.
- Create a new batch for the shipments and rates in the invalid or error state.
- Process the new batch.