
EasyPost is a logistics platform that provides unique tools and a convenient API for automating and optimizing the shipping and tracking processes of shipments. Its history began in 2012, and today EasyPost holds a leading position among providers of efficient logistics solutions, serving numerous business industries.
One of the key advantages of the EasyPost API is the ability for companies to access a diverse range of carriers and choose the best delivery options for their shipments. EasyPost offers comprehensive functionality with a multitude of features, which we will describe below.

The main advantages of using EasyPost are as follows:
- EasyPost provides a convenient API that allows you to get accurate shipping cost calculations right on your website. Now your customers or managers can immediately see the shipping cost and choose the most suitable option.
- With EasyPost, you can easily create and print labels for your shipments. This will save you time and simplify the process of preparing your packages for shipping.
- EasyPost integrates with a variety of popular carriers, including FedEx, DHL, USPS, UPS, APC, and others. You'll have access to various delivery options and can choose the best one for your customers.
- Using EasyPost's tracking API, you and your customers can receive real-time updates on the delivery status. This ensures transparency and builds trust in your business.
- EasyPost provides the option to insure your shipments, protecting you from losses or damages during delivery. This way, you can have confidence in the safety of your shipments.
Example of EasyPost API Integration
For the most widely used programming languages, EasyPost provides SDKs. So, if you are using PHP, you can install the corresponding package with the following command:
EasyPost uses only one parameter - the API key - to sign requests. Before starting to work with the client code, you need to first import EasyPost:
All classes are located within the name space EasyPost, so to set up the API key for signing requests, you need to do the following:
Now you can perform various requests, for example, to create an address. Some systems, like ShipStation, may dynamically accept only the recipient's address, while the sender's address is taken from the account settings. In the case of EasyPost, you need to provide both addresses. Let's assume that your system already has an entity called "order" with fields responsible for the delivery address. In this case, the code for saving the address in EasyPost will look like this:
'verify' => ['delivery'],
'company' => $order->getCompany(),
'street1' => $order->getStreet(),
'street2' => $order->getHouseNumber(),
'city' => $order->getCity(),
'state' => $order->getUserState(),
'zip' => $order->getZip(),
'phone' => $order->getUserPhone(),
'email' => $order->getEmail(),
'country' => $order->getCountryCode(),
]);
As a result, in the response, we will receive the same array with additional fields, including "id" - the address identifier in the EasyPost system, "verifications" - an array of address verification results, and others. Similarly, you need to specify and save the sender's address in the variable $senderAddress.
Now, let's take a look at how to create the shipment itself:
'weight' => $order->getWeight(),
'height' => $order->getHeight(),
'width' => $order->getWidth(),
'length' => $order->getLength(),
]);
We have three variables: $receiverAddress, $senderAddress, and $parcel. They represent instances of the EasyPost\Address and EasyPost\Parcel classes, respectively. The EasyPost package automatically encodes and decodes data into JSON format, so objects can be passed in arrays. For example, when we are ready to create a shipment, we need to pass all the retrieved objects to the method for its creation:
"to_address" => $fromAddress,
"from_address" => $toAddress,
"parcel" => $parcel,
"options" => [
"label_format" => 'PDF'
],
]);
If everything is fine, then in the "rates" field of the $shipment object, there will be an array of objects containing information about various delivery services. Let's assume that one of the carriers suits us, for example, USPS with the lowest shipping cost, and we want to purchase a label for this service and obtain a PDF file for printing. In this case, we need to pass the following value to the "buy" method of the $shipment object:
The "lowest_rate" method will find the cheapest delivery method among all the available ones. By default, the system provides a list of delivery methods for USPS until you connect the corresponding service. However, to create labels, you need to activate this service. Even if you are trying to get a USPS label, you must connect it beforehand.
Since all our objects have unique identifiers in the EasyPost system, we can save these identifiers and later retrieve information about the objects directly from EasyPost using the "retrieve" method for each of the mentioned classes: EasyPost\Shipment, EasyPost\Address, and EasyPost\Parcel. Additionally, EasyPost provides the option to create all four entities in one request by passing a multidimensional array to the create method of the EasyPost\Shipment class. For example, the "to_address" key will contain an array of recipient address data, and so on. However, the method described above allows for more flexible handling of validation errors that may arise.
Regarding validation, the EasyPost SDK handles errors automatically and generates exceptions that the client code developer will need to handle. However, error messages returned by the EasyPost server may not always be clear and may only contain information about invalid data for the entity being saved.
If you need to configure the connection to this API, please leave a request on the page "Integration and API Connection".
Articles You May Also Be Interested In


Ready to start? Let us know!
Ukraine, Zhytomyr
Vitruka Street, 9V
M-F, 9am — 7pm
Poland, Warsaw, 00-842
Łucka street 15/204
M - F, 9am - 7pm