Skip to main content

Get Shipping Rates

POST/api/v1/shipments/{shipmentId}/rates Open shipping rates in the API Reference.

Request Rates for a Shipment created by Create an Order. This call has no request body and no Order-status precondition for a Shipment of its own — it works as soon as the Shipment exists, regardless of the Order's current status.

A merged Shipment is rated on its own shipmentId like any other, with one addition: it is refused while another of its Orders is Cancelled, OnHold, Fulfilled or Returned, or fails a pre-purchase check of its own (closed at the store, shipped in scheduled deliveries, or still missing details), because the one Label would ship that Order too. See Errors below.

See Rates for the public Rate-result model and its bounded identifier handoff.

curl -s -X POST "${MAILHUB_API_BASE_URL}/api/v1/shipments/${SHIPMENT_ID}/rates" \
-H "Authorization: Bearer ${MAILHUB_ACCESS_TOKEN}"

Response​

{
"success": true,
"data": {
"totalCount": 2,
"carrierCount": 2,
"rates": [
{
"id": "c4a1b2d3-...",
"carrier": "USPS",
"serviceCode": "<carrier-specific service code>",
"serviceName": "USPS Priority Mail",
"rate": 8.42,
"currency": "USD",
"deliveryDays": 2,
"estDeliveryDays": 2,
"deliveryDateGuaranteed": false
},
{
"id": "d5b2c3e4-...",
"carrier": "UPS",
"serviceCode": "<carrier-specific service code>",
"serviceName": "UPS Ground",
"rate": 11.15,
"currency": "USD",
"deliveryDays": 4,
"estDeliveryDays": 4,
"deliveryDateGuaranteed": false
}
],
"carrierResponses": [
{"carrier": "USPS", "success": true, "errorCode": null, "errorMessage": null, "errorField": null},
{"carrier": "UPS", "success": true, "errorCode": null, "errorMessage": null, "errorField": null}
]
},
"errors": null
}

carrier, serviceCode, and serviceName above are illustrative example values, not a fixed enum — exact carriers/services depend on your account, sub-account, and environment configuration. serviceCode is carrier-specific and its shape is not part of the public contract: pass it through, and do not parse, hard-code, or switch on it. Select a service by matching serviceName where you need to, and keep the returned Rate id for the purchase. listRate, retailRate, billingType, mailClass, zone, and estimatedDeliveryDate are also present on each rate when the carrier returns them; see the API Reference for the complete field list.

The two arrays answer different questions, and a 200 can carry both:

  • rates[] holds the usable Rate options — every Rate returned, across all carriers that produced one. A carrier that failed contributes nothing here.
  • carrierResponses[] is the per-carrier diagnostic view: one entry for every carrier that was asked, including the ones that returned nothing, so a carrier that declined can be told apart from one that was never contacted.
  • carrierCount is the number of requested carriers that returned at least one Rate — not the number that answered. A carrier that replied with an error is recorded in carrierResponses[] but does not raise carrierCount.
  • totalCount is the number of entries in rates[].
  • A failed carrierResponses entry does not mean the operation failed. Treat a partial result as a normal outcome, and do not re-issue the request expecting the missing carrier to appear.

Continue with Select a Rate before Buy a Label. Working with USPS? See USPS with Mailhub. Rates carry no expiry and no TTL. A repeat request for the same Shipment normally returns the stored Rates with the same identifiers; the set is replaced when the stored Rates were requested more than 24 hours earlier, when the carriers enabled for your Account or Sub-account change, or when a merge action changes the Shipment. Buy from the set you most recently received. See Validity and outcomes.

Errors​

404 if the Shipment does not exist for your account. See Rate Errors for general recovery guidance.

409 Shipment.Superseded if a merge replaced this Shipment, or it was a merged Shipment that has since been taken apart. Neither can be rated or bought again. Read the Order with Get Order (GET /api/v1/orders/{orderId}) and rate the shipment.shipmentId it returns now — the merged Shipment while the Order is merged, or its own Shipment again after the merge was taken apart. Repeating the request on the old shipmentId gets the same answer.

For a merged Shipment, a refusal caused by another of its Orders keeps that refusal's own code and names the Order in metaData (orderId, orderNumber, reason). Resolve that Order's status and rate again, or take the Shipment apart and rate each Order's own Shipment. See Order State Errors.

409 SubAccount.Inactive if X-SubAccount-Id names an inactive sub-account.