Skip to main content

Recipes

A Recipe answers one question: I want to accomplish this — what is the shortest correct sequence of requests?

Each one is mostly code. You get the request in cURL, JavaScript, and Python, a trimmed response, the exact field to carry into the next step, and the handful of outcomes that change what your code does next. Anything that needs a longer explanation is a link, not a paragraph.

Recipes call the public Mailhub API directly. There is no SDK to install and no client library to configure — every example is an HTTP request you can paste into your own project.

Where Recipes fit

SurfaceUse it to
RecipesCopy a working sequence for one task
GuidesUnderstand how an operation behaves and what can go wrong
ConceptsLearn the model the operations act on
API ReferenceRead the complete schema for any operation

Available now

They compose in this order, each one's response feeding the next one's request:

  1. Create an Order and Get Rates in One Call — one request that creates an Order and returns the Rates for its Shipments.
  2. Buy a Label from a Selected Rate — spend a Rate identifier and get a Label identifier back.
  3. Recover a Label Purchase After 202 — when the response arrives before the purchase finishes.
  4. Download a Label File — the Label bytes, written to disk.
  5. Create and Download a USPS Label — the whole path in one page, with a USPS Rate chosen from the response.

Two more start from a Label you already have, or from a different scope:

  1. Cancel a Label — request cancellation of a Label you already purchased, and read the one documented result.
  2. Run a Shipping Workflow for a Sub-account — the same Order-to-Label path with X-SubAccount-Id sent only where the contract gives it an effect.

Start anywhere: each Recipe states the identifiers it needs and where they come from.

Pick by outcome

You want toStart here
Ship your first parcel end to endCreate and Download a USPS Label
Get Rates before committing to anythingCreate an Order and Get Rates in One Call
Turn a chosen Rate into a LabelBuy a Label from a Selected Rate
Get the Label file onto diskDownload a Label File
Recover a purchase that answered 202Recover a Label Purchase After 202
Undo a Label you already boughtCancel a Label
Ship on behalf of one of your Sub-accountsRun a Shipping Workflow for a Sub-account

Before you start

Every Recipe assumes you have exchanged an API key for an access token — see Authentication and Token Lifecycle — and that your API base URL is configured as MAILHUB_API_BASE_URL. The portal publishes no fixed API host; use the value supplied for your account.

To run the same operations from the browser instead of your own client, see the API Playground guide.