The API is used mainly for creating shipments and retrieving labels for the shipments. There are a couple of steps you will have to do for each shipment: - Create a shipment resource. - Wait for the status to transition from shipment_concept to shipment_registered. - Download the label. - Hand the physical parcel over to the carrier.

Creating The Shipment

To create a new shipment, you should create a new instance of a MyParcelCom\ApiSdk\Resources\Shipment, set the required properties on the shipment and have it sent to the API by calling the method MyParcelCom\ApiSdk\MyParcelComApi::createShipment().

The minimal required properties to set on a shipment are a sender address and a weight. There are however a lot more properties you can (and should) set on the shipment. These are the shop, sender address and service contract. Whenever these are not set, the SDK will automatically set them for you. The default shop will be chosen and that shop’s return address will be used as a sender address. For the service contract, the cheapest one will be calculated and selected.

This behaviour is not a problem for when you only have one shop and don’t mind what carrier you use. However, when you have more than one shop, have multiple locations you want to send from or want to select the service (and contract) to use, you should set (one or more of) these values.

Downloading The Shipment Label

When you create a shipment, its status will be shipment_concept. The shipment will be registered at the carrier as soon as possible and then transition to shipment_registered. This should normally not take more than a minute, but depending on the carrier, it can take a little bit longer. To check the status of a shipment you can retrieve the shipment through the API and then retrieve the status.

Now that you know that the shipment has successfully been registered. You can retrieve the label through the API. You can find more information about files here.

If the shipment is trackable, it will also have a tracking code and a tracking url set.

Handing Over The Parcel To The Carrier

Depending on what service (or service option) was chosen, you either need to drop the parcel off at one of the carrier’s drop-off location or the carrier will come and collect the parcel at the specified sender address. After you’ve done that, the status will be tracked by the API so you can keep track of your shipments.