Shipping Rates
Calculate shipping rates for an order.
Updated
On this page
Overview
Fetch real-time shipping rate quotes from the organization's active shipping provider — a direct UPS or FedEx account, or ShipStation (which brokers rates from whatever carriers are connected in the merchant's ShipStation account).
SDK Usage
import dash from "@/lib/dash"
const { rates } = await dash.shipping.getRates({
to_postal: "78701",
to_state: "TX",
to_country: "US",
weight_oz: 5.0,
})
// rates = [
// { serviceName: "UPS Ground", carrierCode: "ups", shipmentCost: 8.50, transitDays: 5 },
// { serviceName: "FedEx 2Day", carrierCode: "fedex", shipmentCost: 12.99, transitDays: 2 },
// ]
// (carrierCode reflects the org's active provider: "ups", "fedex", or whatever carrier ShipStation used)
Get Cheapest or Fastest Rate
// Cheapest option
const { rate } = await dash.shipping.getCheapestRate({
to_postal: "78701",
weight_oz: 5.0,
})
// Fastest option
const { rate } = await dash.shipping.getFastestRate({
to_postal: "78701",
weight_oz: 5.0,
})
// Single recommended rate (cheapest or fastest)
const rate = await dash.shipping.getRate({
to_postal: "78701",
weight_oz: 5.0,
prefer: "cheapest", // or "fastest"
})
Free Shipping Check
const { qualifies, threshold, remaining } = await dash.shipping.checkFreeShipping("89.99")
// qualifies: true if subtotal meets free shipping threshold
// remaining: amount needed to qualify (e.g., "$10.01")
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
to_postal | string | Yes | Destination postal code |
to_state | string | No | Destination state |
to_country | string | No | Destination country (default: US) |
weight_oz | number | Yes | Package weight in ounces |
dimensions | object | No | Package dimensions { length, width, height } |
REST API
POST /storefront/shipping/rates
X-API-Key: pk_live_your_key
Content-Type: application/json
{
"to_postal": "78701",
"to_state": "TX",
"to_country": "US",
"weight_oz": 5.0
}
Next Steps
- Generate Labels — Creating shipping labels
- Tracking — Package tracking
- Create Order — Using rates in checkout
Rates, labels and carrier setup are covered from the operator's side in shipping and fulfillment.