In brief
Integrating with a courier company covers three flows: creating a shipment with a label straight from the ERP or warehouse system, tracking statuses flowing back to your system and the customer, and returns with a return label tied to the order. With several carriers, one middleware layer with a shared status list pays off, instead of separate logic in the store, the ERP and the warehouse. Most errors come from addresses, parcel dimensions and statuses that every carrier names differently.
Three flows and where to store the result
| Flow | Input data | What the carrier returns | Where you store it |
|---|---|---|---|
| shipment | recipient address, phone and email, weight and dimensions from the warehouse, service, cash on delivery, pickup point | tracking number, label, sometimes the cost | the number on the goods issue note and the order, the label sent to the packing station printer |
| tracking | tracking number | events with date and location | shipment history in the ERP or the middleware, status in the store |
| return | order number, lines, reason | return tracking number, label for the customer | a return request linked to the order and invoice |
The most common design mistake is keeping the tracking number only in the carrier's portal. Without the number on the order, customer service cannot answer "where is my parcel" without logging into several portals, and finance cannot check the carrier's invoice.
Shipment and label
Shipping starts in the warehouse, once the parcel is packed and weighed. The warehouse system or the ERP sends the shipment data to the carrier's API and gets a label back.
- Validate the address before sending. The postal code must match the town, the phone number must fit the format, and the street cannot be empty. A rejected shipment at the packing line stops packing.
- Take weight and dimensions from the warehouse, not from the product card. A parcel with two products weighs more than either one, and the carrier will weigh it at the sorting center anyway and bill the difference.
- Choose the label format for the printer. Thermal printers at packing stations usually print in a printer language (such as ZPL), office printers in PDF. Most APIs return both.
- Carry the pickup point over from the store. The customer chose a parcel locker or pickup point at checkout, so its ID has to travel from the store to the ERP and on to the shipment.
- Close the day. Some carriers require shipments to be confirmed with a handover manifest or a pickup request, otherwise the courier does not come.
A complete set of shipping documents, checked against the order and picking, can be prepared by the Shipping documents assistant, with a person approving the shipment.
Tracking: a shared status list instead of dozens of codes
Every carrier has its own event codes, often dozens of them. The store, the ERP and customer service need a handful. The middleware translates one into the other.
| Shared status | What it means | What the system does |
|---|---|---|
| shipped | the carrier accepted the data or the parcel | email to the customer with the number |
| in transit | sorting center, transport between depots | nothing, history only |
| out for delivery | the courier left with the parcel | customer notification |
| waiting at pickup point | the parcel is in a locker or pickup point | a reminder before the pickup deadline |
| delivered | the recipient collected it | close the shipment, start the return window |
| problem | failed delivery, damage, wrong address | a task for customer service |
| returned to sender | the parcel is coming back | a task for the warehouse and customer service |
A new, unknown code from the carrier must not disappear silently. Map it to "problem" and alert the integration team, because carriers add codes without notice.
Statuses arrive by webhook or have to be polled. Webhooks react faster but require handling of duplicates and ordering, as described in Reliable webhooks. Polling for thousands of parcels a day has to be spread over time to stay within API limits. A daily review of problem shipments, with a ready message to the customer and a claim to the carrier, is the job of the Shipment tracker; more on this in Tracking shipments across many carriers.
Returns tied to the order
In distance selling, a consumer in Poland has 14 days to withdraw from the contract without giving a reason (Article 27 of the Polish Consumer Rights Act) and another 14 days to send the goods back (Article 34). The seller refunds the payment within 14 days of receiving the withdrawal, but if it does not collect the goods itself, it may withhold the refund until it receives the goods or proof that they were sent back (Article 32). These rules implement the EU Consumer Rights Directive.
This leads to requirements for the integration:
- a return label generated from the order, with the order number in the shipment data, so the warehouse knows what it is receiving;
- a "return shipped" status stored on the return request, because it is the proof of dispatch that starts the refund clock;
- warehouse receipt compared with the request: lines, quantities, condition, and only then the credit note and the refund.
When a customer sends the parcel back with another carrier, the tracking number has to be entered by hand and the return is matched to the order by the slip inside the parcel. Count such cases: if there are many, a simpler return form in the store pays off quickly. How an AI Worker handles returns from request to credit note is covered in RMA returns with an AI Worker.
Many carriers in one place
With two or three carriers and several sales channels, one middleware layer simplifies every other system. The store, the ERP and the warehouse know one API and one status list, and the middleware knows the carriers.
- Carrier selection rules in one place: weight, size, country, pickup point, collection cut-off time, price from the rate card.
- A plan for a carrier API outage: a shipment queue and retries, and during a longer outage a switch to a second carrier for new parcels.
- The carrier's sandbox in integration tests and separate API keys for each warehouse.
- API version changes tracked like any other dependency, with a test before the old version is switched off.
The tracking number on the order also helps finance. The carrier's invoice lists tracking numbers, weights and surcharges, so it can be compared with what the warehouse actually shipped, as described in Auditing carrier invoices.
At B2Bnetwork, such integrations are built by the team behind our System integration service. Examples include the integration of an online store with marketplaces and a warehouse system and an EDI and API integration platform for a logistics operator.
Questions and answers
A shipping platform or our own integration with each courier?
A shipping platform connects many carriers quickly and comes with a ready status list, but it adds a per-parcel fee and one more vendor to manage. Your own integration pays off at high volume, with unusual services or specific data requirements. Many companies start with a platform and later build a direct connection to their largest carrier.
How long does it take to connect a new carrier?
With middleware in place, most of the time goes into mapping services and statuses and testing labels on the warehouse printers. Without middleware, the store, the ERP and the warehouse each need changes, so the effort grows with every system. That is why the middleware is usually built when the second carrier arrives.
What personal data about the recipient do we pass to the carrier?
Only what is needed for delivery: name or company name, address or pickup point, phone and email for notifications. The data minimization principle in Article 5 of the GDPR means that, for example, the order contents do not go to the carrier unless the service requires them. Review the label content with the same principle in mind.
How do we handle a return when the customer did not use our label?
The warehouse books the parcel as an unassigned return, looks up the order by the sender's details and the slip inside, and customer service confirms the request. Count these returns every month. A high number usually means the return form in the store is hard to find or the return label does not reach the customer.