Shipments
Create Shipments
Creating a shipment follows a two-step process: first generating shipping rates, then selecting and purchasing one of those rates.
Get Rates
This endpoint requires three essential components:
- sender information
- recipient information
- parcel details.
Additional options can be provided to configure the shipment.
Request Body Structure
Sender & Recipient Information
Both sender and recipient require specific identification information. This can be provided in several ways:
For convenience, if you have a contact ID, you can use these shortened formats:
OR
If you don't have a contact ID, in that case:
Addresses can be specified in three different formats:
- Single String Format (with optional second line):
- Structured Object Format:
- Address ID Reference:
- Location ID Reference:
Parcel Information
Parcels can be specified using either:
- Custom Dimensions
- Predefined package types
You don't need to provide dimensions if using a predefined package. In fact, you don't strictly need to provide the weight either, but there are situations like with on-demand providers where not defaulting to the predefined package's max weight will result in better rates, so include this value if you have it.
Other optional properties you can pass in parcel object.
If you want to let us know about specific inventory you are shipping, you can also pass
contents
array to describe the items that are inside of the parcel. This is done automatically for you if you are creating a shipment via a fulfillment_id, but you can do so manually if you would like. The reasons that you would want to include the inventory items in each parcel are:- You are shipping something internationally and need to include customs information.
- Something you are shipping in this parcel needs additional care due to the item attributes like alcohol, hazardous materials, or pharmaceuticals.
- You want to include additional information for your records later.
Optional fields in get shipment rates request body
Any omitted options will be defaulted to the values set in your settings.
Example Request
Applying multiple filter options simultaneously may create conflicting criteria, potentially eliminating all available rates from the results.
In the event that all shipping rates are eliminated by the filtering criteria, the system will default to displaying all available rates, with the exception of those marked as offline_delivery
. This safeguard prevents inadvertent exposure of restricted delivery options to customers.
Type
Typically, the shipment is always outbound
but you have the option of creating an inbound
shipment by specifying whether it is inbound or outbound by adding the following optional property in the request body (defaults to outbound
):
- type
"outbound" | "inbound"
Multi-piece shipments
When shipping multiple packages within a single shipment, you may include all parcels in an array. The rates returned will reflect the total cost for all parcels in the shipment.
Tracking number assignment varies by carrier. Some carriers will assign the same tracking number to all parcels in a shipment, while others will provide unique tracking numbers for each parcel. In cases where multiple tracking numbers are generated, the system will:
- Assign individual tracking numbers to each parcel's
tracking_number
property. - Designate one tracking number for the shipment's
tracking_number
property.
Purchase Shipment
After generating shipping rates, you can purchase a shipment using either of these endpoints:
This endpoint requires a valid shipment ID and rate ID. The system will process the payment and create tracking information.
Required Parameters
Optional Parameters
In this instance, we'll select the cheapest shipping rate from the response we received in the previous step. To purchase the shipment, we'll need the shipment_id
from the response and the rate ID that we want to purchase. Everything else is optional.
Request Example
Refetch Rates
After you already fetched rates, you can also fetch new rates. You'll want to do this if:
- Your rate has expired because the
rates_generated_at
is more than 15 minutes from now. - You want to update your options that you added into the shipment.
All of the options that are passed in for getting rates can also be passed in to refetch rates.