Skip to main content

Create Order

mailhub_create_order

Create an Order from a sender address, a recipient address, and one parcel. It does not rate the Order and does not buy a Label, so it spends nothing.

Permission and safety​

Changes dataYes
ConfirmationRequired — confirm: true
Spends fundsNo
PermissionUpdate access to Orders

Confirmation is enforced by the server. A call without confirm: true is refused with MCP_CONFIRMATION_REQUIRED and creates nothing.

Input​

FieldTypeRequiredNotes
orderobjectYesThe Order to create
confirmbooleanNoDefaults to false; the operation is refused unless the value is the boolean true

order:

FieldTypeRequiredNotes
toAddressaddressYesDestination (recipient) address
fromAddressaddressYesOrigin (sender) address
shipmentsarrayYesExactly one Shipment, carrying one parcel. Create another Order for another box

Address — the same rules apply to both fromAddress and toAddress. Order creation through MCP is US domestic only:

FieldTypeRequiredRule
namestringConditionalProvide name, company, or both. Max 50 characters, printable ASCII
companystringConditionalProvide company, name, or both. Max 50 characters, printable ASCII
street1stringYesMax 50 characters, printable ASCII
street2stringNoMax 50 characters, printable ASCII
citystringYesMax 50 characters, printable ASCII
statestringYesTwo-letter US state or territory code, for example TX
zipstringYesFive digits, or ZIP+4 — 78701 or 78701-1234
countrystringYesUS only. USA and United States are rejected
phonestringYesA US number: ten digits with an area code starting 2–9, optionally prefixed with country code 1. +, spaces, dashes, dots and parentheses are accepted
emailstringNoMust be a valid address when supplied
residentialbooleanNo

The Shipment carries one parcel. Either name a package Mailhub recognises or give all three dimensions:

FieldTypeRequiredRule
weightdecimalYesGreater than 0 and at most 150 pounds
predefinedPackagestringConditionalA package code Mailhub recognises. Omit it for a custom parcel; an unrecognised code is rejected and the message names it
lengthdecimalConditionalRequired for a custom parcel — at least 6 and at most 119 inches
widthdecimalConditionalRequired for a custom parcel — at least 4 inches
heightdecimalConditionalRequired for a custom parcel — at least 1 inch

With a recognised predefinedPackage, the dimensions may be omitted; Mailhub uses the package's own. Without one, all three are required together — giving only two of the three is rejected. Length plus girth (twice the sum of width and height) may be at most 165 inches; a parcel outside these limits is refused with Parcel.OutsideCarrierLimits. Carriers apply lower limits of their own when rating — see Address and Parcel Data.

Example input​

{
"order": {
"fromAddress": {
"name": "Warehouse Team",
"company": "Northline Goods",
"street1": "500 Lake Shore Ave",
"city": "Columbus",
"state": "OH",
"zip": "43215",
"country": "US",
"phone": "3112010144"
},
"toAddress": {
"name": "Maria Alvarez",
"street1": "72 Elm Street",
"street2": "Apt 4",
"city": "Austin",
"state": "TX",
"zip": "78701",
"country": "US",
"phone": "3112010188",
"residential": true
},
"shipments": [
{
"parcel": {
"weight": 2.5,
"length": 12,
"width": 9,
"height": 4
}
}
]
},
"confirm": true
}

This is a complete, accepted request: copy it, change the values, and it still passes. It is not a minimal one. For each address, provide at least one of name or company — the sender here happens to carry both, and either alone would be accepted. street2 and residential are optional throughout. The parcel here is custom, which is why all three dimensions are present — swap them for a recognised predefinedPackage and they can go. Use the user's real details: values that look made up — test or example names, a 555 phone number, an example.com address — are refused.

Output​

FieldContents
idThe new Order's identifier
createdAtUtcWhen it was created, in UTC
createdAtDisplayThe same instant, formatted and labelled UTC
shipmentsOne entry per Shipment, each with its shipmentId

The new Order starts in Created. No Rates are returned and no Label is bought — those are separate, explicit steps.

Rules and common tool-specific errors​

Before anything is sent, MCP checks that toAddress.street1 and fromAddress.street1 are present, that shipments holds exactly one parcel, and that no address value looks made up. Mailhub then applies the full rules in the tables above — both addresses, and every parcel — and rejects the Order if any of them fails, naming the field. Nothing partial is created. Order creation through MCP is US domestic only; treat anything else as unsupported here.

  • Repeating a confirmed call creates another Order. See the warning above.
  • The identifiers in the response are what the next tools need: carry shipmentId into mailhub_get_shipment_rates.
  • The Order is created for the account you signed in with. MCP has no sub-account scope today.

Common tool-specific errors​

CodeWhat it meansRetrying
MCP_CONFIRMATION_REQUIREDThe call did not carry confirm: trueYes, confirming
MCP_MISSING_FIELDA required field is missing — the message names itNo — supply it
MCP_ONE_PARCEL_PER_ORDERshipments held more than one parcelNo — create one Order per box
MCP_PLACEHOLDER_VALUEAn address value looks made up — the message names the fieldNo — ask the user for the real value
MCP_WRITE_RATE_LIMITEDToo many changing calls for the account just nowYes, shortly
A validation refusal from MailhubAn address or parcel value was not acceptedYes, after correcting it

Every code above, plus the access and shared failures this table does not cover, is listed in Errors & Troubleshooting.

Next​