Skip to main content
The ShippingService class (accessed via client.shipping) handles delivery fee calculations, zone checking, and shipping configuration retrieval for your commerce storefront.

Methods

getShippingZones

Retrieve all active delivery zones and distance-based pricing tiers. This is useful for displaying delivery availability or potential costs to users early in the shopping journey.
A store configured with distance tiers returns them ordered by priority:

calculateShipping

Calculate the exact delivery fee for a customer based on their location and order total.
order_total is the order subtotal in the store’s currency (e.g. 50 = $50.00), not a minor-unit (cents) value. It is used only to decide whether the order reaches a tier’s or zone’s free-delivery threshold.
Response Fields:

Live carrier rates (multi-carrier)

When the store has multi-carrier shipping connected, pass a destination address_to and a parcel to calculateShipping to ALSO get live carrier rates alongside the zone/tier fee. The response gains a rates[] array (real quotes from USPS, UPS, FedEx, DHL…) and rate_source becomes shippo. If the store has connected its own custom carrier (a Custom Extension shipping provider), its rates are appended too and rate_source becomes custom. When neither is connected, rates[] is simply absent and the zone/tier fee applies as before — the manual rates always work.
Show rates[] to the shopper, let them pick, and carry the chosen rate_id into checkout (pass it as shippo_rate_id on createOrder so the order’s shipping is validated against that real quote).
Buying a shipping label is done by the merchant from their admin — it charges the merchant’s carrier account, marks the order shipped, and emits order.shipped — so there is no SDK method for it. From a storefront you quote rates (calculateShipping) and track parcels (trackShipment).

trackShipment

Returns live tracking status for a parcel by carrier + tracking number — use this when you want to render the status timeline inside your own UI.
The lightest way to let a shopper track is to link to the carrier’s own tracking page — no API call. When the label is bought, the carrier tracking URL is saved on the order at shipping_metadata.shippo.tracking_url; render it as a “Track your package” link. Use trackShipment only when you want the status shown natively in your storefront.

How Fees Are Calculated

Tybrite uses a priority-based logic to determine the shipping fee:
  1. Custom Zones: If the location falls within a defined polygon, the specific zone fee is applied.
  2. Distance Tiers: If the customer is outside all zones, the system calculates the distance from your store and matches it to a pricing tier (e.g., 5-10km).
  3. Free Delivery: If the order_total exceeds the threshold for that zone/tier, the fee is waived.

Precision Tip: For the best user experience, use the browser’s Geolocation API to get high-precision coordinates for the calculateShipping method.

Input Flexibility: calculateShipping accepts either { latitude, longitude, order_total } or { place_name, country_code?, order_total }. When you supply a place_name, Galactic Core resolves it to coordinates for you. The response shape is identical regardless of input mode: { fee, zone_name, tier_name, distance_meters, is_free, reason, applied_rule, coordinates }.

Response Codes

Both methods accept publishable and secret keys. calculateShipping uses POST purely to carry a structured request body — it is read-only.

getShippingZones (GET /v1/shipping/zones)

This method has no 400 because it takes no input to validate.

calculateShipping (POST /v1/shipping/calculate)