TheDocumentation Index
Fetch the complete documentation index at: https://docs.tybritelabs.com/llms.txt
Use this file to discover all available pages before exploring further.
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.
calculateShipping
Calculate the exact delivery fee for a customer based on their location and order total.
| Field | Description |
|---|---|
fee | The final calculated delivery cost. |
applied_rule | Indicates calculation logic: 'zone', 'distance', or 'default'. |
is_free | Boolean indicating if a free delivery threshold was reached. |
coordinates | Returns the resolved [lat, lng] even if you searched via place_name. |
How Fees Are Calculated
Tybrite uses a priority-based logic to determine the shipping fee:- Custom Zones: If the location falls within a defined polygon, the specific zone fee is applied.
- 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).
- Free Delivery: If the
order_totalexceeds the threshold for that zone/tier, the fee is waived.
Input Flexibility:
calculateShipping accepts either { latitude, longitude, order_total } or { place_name, country_code?, order_total }. When place_name is supplied, the worker geocodes via Nominatim. 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)
| Code | Meaning |
|---|---|
200 | Zones and pricing tiers returned. |
401 | Invalid or missing API key. |
403 | Forbidden (e.g., key disabled or store suspended). |
429 | Rate limit exceeded. |
500 | Internal server error. |
400 because it takes no input to validate.
calculateShipping (POST /v1/shipping/calculate)
| Code | Meaning |
|---|---|
200 | Fee calculated and returned. |
400 | Invalid coordinates (out-of-range lat/lng), missing order_total, or geocoding_failed when a place_name could not be resolved. |
401 | Invalid or missing API key. |
403 | Forbidden (e.g., key disabled or store suspended). |
404 | Store has no shipping configuration (no zones and no distance tiers). |
429 | Rate limit exceeded. |
500 | Internal server error — including upstream Nominatim or PostGIS failure. |

