Skip to main content

Recover a Label Purchase After 202

A 202 from a Label purchase means the purchase is still running. Reading the Order is the primary way to find out how it ended.

What you'll build​

  • The primary observation path after a 202: reading the Order.
  • A check for the Label identifier appearing on that Order.
  • A completion signal you never have to set yourself.

Prerequisites​

What a 202 gives you​

{
"success": true,
"data": {
"operationId": "...",
"shipmentId": "b91a2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
"rateId": "c4a1b2d3-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
"status": "Processing",
"correlationId": "..."
},
"errors": null
}

rateId is the rate.id you submitted, echoed back. Recovery never needs it — the Order is the record you read — but it ties the pending purchase to the Rate you selected.

When the outcome is ambiguous​

Reading the Order is the path for a 202 you actually received. A transport failure or a lost response is a different situation: you do not know whether the purchase reached Mailhub at all. Sending the identical purchase request again is safe there — Mailhub recognizes it as the same purchase and replays its outcome instead of buying a second Label. Keep that within your own bounded budget rather than a loop, and see Buy a Label for the two conditions that bound it.

Step 1 — Read the Order​

GET/api/v1/orders/{orderId}
curl -s "${MAILHUB_API_BASE_URL}/api/v1/orders/${ORDER_ID}" \
-H "Authorization: Bearer ${MAILHUB_ACCESS_TOKEN}"

Response​

Once the purchase has completed:

{
"success": true,
"data": {
"id": "5f2c1a10-2b3d-4e5f-8a9b-0c1d2e3f4a5b",
"labelId": "f6c7d8e9-0a1b-4c2d-8e3f-4a5b6c7d8e9f",
"shipmentId": "b91a2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
"status": 8,
"...": "..."
},
"errors": null
}

status is the numeric public Order status enum; 8 is LabelCreated. See Order Lifecycle for the full membership.

Use this next​

data.labelId — the same identifier a 200 purchase returns as data.postageLabel.id. Carry it into Download a Label File.

Expected result​

An Order carrying a labelId, and a status of 8.

Common outcomes​

What you seeWhat it meansWhat to do
labelId is null or absentThe purchase has not completed yet.Read the Order again later. Choose a polling cadence appropriate for your application — the contract defines none.
labelId is present, status is 8The purchase completed.Use labelId to download the Label.
409 on a further purchase attemptAnother purchase for that Shipment is still being resolved.Keep reading the Order. Do not start a competing purchase.

Next steps​