Skip to main content

Create an Order with Rates

POST/api/v2/orders Open this operation in the API Reference.

Mailhub provides two Order creation operations. Use standard Order creation when you want to create the Order first and request Rates later. Use Create an Order with Rates when you want Mailhub to create the Order and immediately request Rates for its Shipment in the same API call.

Compare the creation choices​

BehaviorPOST /api/v1/ordersPOST /api/v2/orders
CreatesOne OrderOne Order
Request bodyOrder fields at the top levelRequired top-level order wrapper
Rates during creationNoYes, for the created Shipment
Success response201 created Order200 created Order plus shipmentRates
Typical next stepRequest Shipment RatesSelect a returned Rate
Label purchaseSeparateSeparate

Both operations create the same public Order resource. The create-and-rate operation uses the same underlying Order-creation workflow, then requests Rates for the created Shipment. An Order is created with exactly one Shipment, so shipments holds one entry here as in V1.

Request​

The request accepts exactly one Order under the required order property. It is one Order per request, not a batch operation, and does not accept an orders array.

{
"order": {
"fromAddress": {
"name": "Jane Sender",
"street1": "405 Fremont St",
"city": "Lander",
"state": "WY",
"zip": "82520",
"country": "US",
"phone": "5125550100"
},
"toAddress": {
"name": "John Recipient",
"street1": "405 Fremont St",
"city": "Lander",
"state": "WY",
"zip": "82520",
"country": "US",
"phone": "3035550100"
},
"shipments": [
{"parcel": {"weight": 16, "length": 10, "width": 8, "height": 4}}
]
}
}

See Create an Order for the verified address and parcel requirements.

Read the response​

The order in a successful 200 response is the created Order. shipmentRates is grouped by Shipment: each entry identifies a created Shipment and contains that Shipment's returned Rate results. Your application chooses a returned rate.id; Mailhub does not select a Rate or buy a Label in this operation.

Use the selected Rate with Buy label. That remains a separate operation. Do not infer a preferred Rate from response order.

Complete success response​

Every field below is one the public contract declares for this operation. The carrier, serviceCode, and serviceName values are illustrative — see Carrier Availability.

{
"success": true,
"data": {
"status": "created",
"order": {
"id": "5f2c1a10-2b3d-4e5f-8a9b-0c1d2e3f4a5b",
"status": 0,
"isReturn": false,
"createdAt": "2026-08-20T14:31:07.482Z",
"updatedAt": "2026-08-20T14:31:07.482Z",
"fromAddress": {
"id": "8c5e0f14-7a2b-4d36-9e81-2f6a4b90c7d3",
"name": "Jane Sender",
"company": null,
"street1": "405 Fremont St",
"street2": null,
"city": "Lander",
"state": "WY",
"zip": "82520",
"country": "US",
"phone": "5125550100",
"email": null,
"residential": null,
"federalTaxId": null,
"stateTaxId": null,
"carrierFacility": null,
"createdAt": "2026-08-20T14:31:07.482Z",
"updatedAt": "2026-08-20T14:31:07.482Z"
},
"toAddress": {
"id": "2d90a7b6-3f18-4e52-8c47-6b1d0e35f9a2",
"name": "John Recipient",
"company": null,
"street1": "405 Fremont St",
"street2": null,
"city": "Lander",
"state": "WY",
"zip": "82520",
"country": "US",
"phone": "3035550100",
"email": null,
"residential": null,
"federalTaxId": null,
"stateTaxId": null,
"carrierFacility": null,
"createdAt": "2026-08-20T14:31:07.482Z",
"updatedAt": "2026-08-20T14:31:07.482Z"
},
"shipments": [
{
"id": "b91a2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
"status": "Unknown",
"isReturn": false,
"createdAt": "2026-08-20T14:31:07.482Z",
"updatedAt": "2026-08-20T14:31:07.482Z",
"fromAddress": {
"id": "8c5e0f14-7a2b-4d36-9e81-2f6a4b90c7d3",
"name": "Jane Sender",
"company": null,
"street1": "405 Fremont St",
"street2": null,
"city": "Lander",
"state": "WY",
"zip": "82520",
"country": "US",
"phone": "5125550100",
"email": null,
"residential": null,
"federalTaxId": null,
"stateTaxId": null,
"carrierFacility": null,
"createdAt": "2026-08-20T14:31:07.482Z",
"updatedAt": "2026-08-20T14:31:07.482Z"
},
"toAddress": {
"id": "2d90a7b6-3f18-4e52-8c47-6b1d0e35f9a2",
"name": "John Recipient",
"company": null,
"street1": "405 Fremont St",
"street2": null,
"city": "Lander",
"state": "WY",
"zip": "82520",
"country": "US",
"phone": "3035550100",
"email": null,
"residential": null,
"federalTaxId": null,
"stateTaxId": null,
"carrierFacility": null,
"createdAt": "2026-08-20T14:31:07.482Z",
"updatedAt": "2026-08-20T14:31:07.482Z"
},
"parcel": {
"id": "7e41b3c8-5d69-4a02-9b7f-1c8e2a604d5b",
"weight": 16,
"length": 10,
"width": 8,
"height": 4,
"predefinedPackage": null,
"createdAt": "2026-08-20T14:31:07.482Z",
"updatedAt": "2026-08-20T14:31:07.482Z"
}
}
]
},
"shipmentRates": [
{
"shipmentId": "b91a2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
"rates": [
{
"id": "c4a1b2d3-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
"carrier": "USPS",
"carrierCode": null,
"serviceCode": "<carrier-specific service code>",
"serviceName": "USPS Ground Advantage",
"rate": 8.42,
"currency": "USD",
"listRate": 9.1,
"listCurrency": "USD",
"retailRate": 11.3,
"retailCurrency": "USD",
"deliveryDays": 3,
"estDeliveryDays": 3,
"deliveryDateGuaranteed": false,
"estimatedDeliveryDate": "2026-08-23T00:00:00Z",
"billingType": null,
"mailClass": null,
"zone": null,
"sku": null,
"rateIndicator": null,
"processingCategory": null,
"destinationEntryFacilityType": null
}
],
"carrierResponses": [
{"carrier": "USPS", "success": true, "errorCode": null, "errorMessage": null, "errorField": null}
],
"errors": []
}
],
"errors": []
},
"errors": null
}

Two fields in this response are named status and they are not the same thing:

FieldWhat it is
data.statusA fixed acknowledgement for the combined create-and-rate call — always the string "created" on a 200. It is not an Order status, and it does not report whether Rates came back: a call that produced no Rates at all fails with a 422 instead of returning this response.
data.order.statusThe created Order's own fulfilment status, as the numeric OrderStatus value — 0 is Created. The same representation Update Order Status uses.

data.order.shipments[].status is a third, unrelated concept: a tracking-oriented Shipment status, published as a string, which stays "Unknown" in the current integration because tracking is not yet implemented.

Three errors arrays appear in this response and they are not the same thing:

FieldOn a 200
errors (envelope)null — the envelope's own failure list.
data.errors[].
data.shipmentRates[].errorsCan carry entries about rating the Shipment. A 200 means at least one Rate came back, not that every carrier answered.

An Order holds one Shipment, so shipmentRates has one entry. Within it, carrierResponses has one item per carrier that was asked, including carriers that returned nothing. A 200 needs at least one returned Rate; a carrier that declined appears as a carrierResponses item with success: false beside the Rates the others returned. Read rates, carrierResponses and the entry's errors before treating a 200 as a full set of carrier options.

Each carrierResponses item always carries errorCode, errorMessage and errorField; all three are null when the carrier succeeded. When a carrier returned no Rates, errorField names which part of the request it objected to (for example the sender or recipient address or phone). It is null, not omitted, where the carrier names no field.

Optional fields are shown as null rather than omitted so the shape is unambiguous; the exact set a carrier populates varies. See API Conventions for the envelope rules.

When no Rate comes back​

The Order is created before Rates are requested. If no carrier returns a Rate, the Order still exists, but the call answers with an error instead of the 200 above, and the error carries no Order identifier.

StatusWhen
422The input was invalid, or the carrier rejected the Shipment for a reason you can correct. Also the answer when no Rate came back and no more specific cause is known (Order.NoRatesAvailable).
503No Rates were produced because a carrier is temporarily unavailable. There is nothing to correct; retry later.
500No Rates were produced and the failure could not be classified.

The status follows the carrier's own answer, so a 503 or 500 is not the caller's input at fault, and a 422 is not always a lost-Order case: invalid input is rejected before any Order is created.

What the key does and does not give you:

  • Rates are requested again. A keyed repeat finds the existing Order, then asks for Rates a second time. It can fail to get Rates again and answer with the same kinds of error, so it does not necessarily return an Order identifier or a 200. Keep the key and retry later.
  • The key is not sent after the fact. It must be on the first attempt; adding it only to a retry matches nothing.
  • The rest of the key rules apply, including that the payload is not compared and that the key is scoped to the account. See Retries and Ambiguous Outcomes.

Next steps​