Rate a parcel across multiple carriers using EasyPost: create a Shipment object, retrieve all available rates, and purchase the lowest-cost rate in a single workflow
Authenticate with your EasyPost API key via the Authorization header on all requests to the EasyPost v2 base URL.
POST to the shipments endpoint with a payload containing 'to_address', 'from_address', and 'parcel' objects; EasyPost automatically rates the shipment across all carrier accounts linked to your account.
Inspect the 'rates' array on the returned Shipment object; each rate includes 'carrier', 'service', 'rate' (cost as a string), 'currency', and 'delivery_days'.
Identify the lowest-cost rate by sorting on the numeric value of 'rate'; optionally filter by 'delivery_days' to enforce a service-level requirement before selecting the cheapest option.
POST to the shipment's 'buy' sub-resource (verify path against current docs) with the selected 'rate.id' in the request body to purchase the label; the response returns 'postage_label.label_url' for download.
Store the returned 'tracking_code' and 'tracker.id' for subsequent tracking lookups or webhook correlation.
Known gotchas
Rates expire: EasyPost rate objects have a short TTL (verify exact duration in current docs); always buy within the same session or re-create the shipment rather than caching rate IDs.
Carrier account availability varies by EasyPost account tier; not all carriers appear in the rates array unless you have connected and enabled the respective CarrierAccount on your EasyPost dashboard.
The 'rate' field is a string, not a number; parse it to float before comparing costs or you risk lexicographic sort errors.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp