SHIPPING SOFTWARE · .NET ARCHITECTURE

Designing Multi-Carrier Shipping Software in .NET

A practical architecture for connecting ERP and order data to carrier shipment, label and tracking workflows.

10 min read By Kshitij Mehta

A multi-carrier shipping application becomes difficult to maintain when order processing has to know each carrier’s authentication, request format, label response and tracking codes. A more manageable design keeps a stable shipment workflow in the application and places carrier-specific communication behind separate adapters.

This guide outlines that design for a .NET application. It focuses on boundaries between systems, data mapping, retries, status history and the questions to settle before connecting an ERP or order platform. Carrier APIs differ, so the shared model should simplify common work without pretending every carrier supports the same operation.

Design checklist
  • Keep order and shipment records separate from carrier request models.
  • Use one adapter per carrier and map capabilities explicitly.
  • Persist the carrier reference and label before acknowledging a successful booking.
  • Make retries safe against duplicate shipment creation.
  • Retain raw carrier codes alongside normalized tracking statuses.

1. Define the boundary between systems

Start by deciding which application owns each part of the transaction. An ERP or order system may own the order number, customer, items and delivery address. A shipping application may own parcel packaging, carrier selection and the shipment lifecycle. A carrier returns its own shipment identifiers, labels and tracking events.

Write down the source of truth for each field before mapping data. If both systems can edit an address or shipping status, define which value wins and when it can change. This prevents a carrier response from silently overwriting an order record or a retry from booking a shipment with stale package data.

For an order-to-delivery flow, a useful boundary is: receive an eligible order, validate the ship-to and package details, select a supported carrier service, book the shipment, save the carrier response, and send the resulting references back to the system that needs them.

2. Create a shared shipment model

Use an application-level shipment request for fields that are genuinely common to the workflow: an internal order reference, sender and recipient addresses, parcels, weights and the requested service preference. Keep provider-specific product codes, customs fields and authentication values inside the relevant adapter.

A small contract can make the boundary clear:

public interface ICarrierAdapter
{
    string CarrierCode { get; }

    Task<ShipmentResult> CreateShipmentAsync(
        ShipmentRequest request,
        CancellationToken cancellationToken);

    Task<TrackingResult> GetTrackingAsync(
        string trackingNumber,
        CancellationToken cancellationToken);
}

The shared types should represent the application’s needs, not mirror one carrier’s XML or JSON. Each adapter converts the common request into the provider’s format and converts the response back into a result the rest of the application can use.

Do not flatten away meaningful differences. A carrier may offer multiple parcels, a specific label format, optional customs data or a service-specific delivery option. Model such differences as declared capabilities or optional, validated fields rather than adding undocumented values to every request.

3. Isolate carrier adapters

A carrier adapter should own authentication, request construction, transport, response parsing and translation of provider errors. The order workflow should ask for a shipment result; it should not construct carrier SOAP envelopes, set provider headers or parse a carrier-specific response document.

Keep carrier selection explicit. A registry or factory can resolve the adapter by a configured carrier code. Avoid a large conditional block that combines every provider’s authentication and payload rules into one service; that makes a change to one carrier more likely to affect the others.

  • Use typed HTTP clients or an equivalent transport boundary for each provider.
  • Keep credentials in secret storage or protected configuration, and renew tokens according to the provider’s rules.
  • Validate the carrier response before treating a booking as successful.
  • Return a stable application error category while retaining a sanitized provider code for support.
  • Represent unsupported operations explicitly instead of returning fake rates or labels.

Services such as shipment creation, rate retrieval, tracking and label generation are not guaranteed to be available for every account or carrier API. Check the carrier documentation, account permissions and destination rules during project scoping.

4. Make booking and retries safe

Shipment creation is a write operation. If a network timeout occurs after a carrier has accepted the request, blindly retrying may create a second shipment. Create an internal booking operation with a stable identifier, store its state, and use a provider idempotency key or reference where the carrier supports one.

A resilient flow commonly moves through explicit states such as Ready, Submitting, Booked, NeedsReview and Failed. Store the internal order reference, the booking attempt, the carrier response reference and any returned label together so support staff can determine what happened before a retry.

Retry only failures that are safe to retry. A transient connection problem may be retried with bounded backoff after checking whether the carrier accepted the request. Validation errors, invalid credentials and unsupported services need correction, not repeated requests. If the provider cannot confirm the result, route the transaction for reconciliation instead of assuming it failed.

When the ERP and shipping application use separate databases, a queued job or outbox pattern can help keep the handoff recoverable. The design should make it possible to resume a failed step without losing the order or booking history.

5. Normalize tracking without losing detail

Different carriers describe similar events with different codes and labels. Map those events into a small set of application statuses such as LabelCreated, InTransit, OutForDelivery, Delivered and Exception, but keep the original carrier code, description, event time and location as well.

Store tracking history as events rather than overwriting a single status field. That preserves the sequence needed to explain a delivery exception and allows the display status to be recalculated when a carrier sends a late or corrected event. Treat event times and time zones deliberately; a date without its source time zone can be misleading.

Use webhooks where the carrier supports them and polling where it does not. Polling should be bounded and scheduled according to shipment state and the provider’s limits. Stop or slow requests after delivery, and avoid querying the same tracking number concurrently without a reason.

6. Plan security and day-to-day operations

Shipping requests contain personal and operational data. Log an internal correlation ID, order reference and sanitized error category rather than full addresses, credentials, tokens or complete request bodies. If support needs provider payloads, define what can be retained, who can access it and how long it remains available.

Set connection and response timeouts, observe provider rate limits, and make concurrency configurable. Track booking success, response latency, rejected requests and tracking update age by carrier. These measures help distinguish an application defect from a provider outage or an account configuration issue.

Labels should be handled as documents with explicit media type and storage rules. Validate that a returned document can be opened, associate it with the correct parcel or shipment, and make reprint behavior clear to the user. Do not assume every carrier returns the same file format or one label per shipment.

7. Test the adapter contract and failure paths

Use sanitized response fixtures to test each adapter’s parsing and mapping. Add contract tests for required fields, provider error responses, expired authentication, timeouts, duplicate booking attempts, missing labels and empty tracking results. A happy-path test alone will not show whether a failed carrier call leaves the order in a safe state.

Where a carrier offers a sandbox, verify account-specific services and document output there. Keep test credentials and sample personal data separate from production. Also test the shared workflow with a fake adapter so order processing can be exercised without calling an external carrier.

Before enabling a carrier in production, confirm its enabled services, ship-from locations, destinations, label formats, customs requirements and support process. These vary by provider, account and contract.

8. Scope the work before choosing an architecture

Collect the operational details that change the integration design:

  • Which ERP or order system sends orders, and what interfaces are available?
  • Which carriers, ship-from locations, destinations and account services are in scope?
  • Does the workflow need rating, booking, cancellation, labels, tracking, returns or customs documents?
  • How many parcels are processed normally and at peak, and what happens when a carrier is unavailable?
  • Where should shipment references, labels, tracking events and errors appear?
  • Which system owns customer, address, parcel and shipment-status data?

These answers help determine whether an existing application needs a new adapter, a shared shipping service or a larger platform. They also surface carrier-account requirements before implementation begins.