Skip to main content

Create Order

mailhub_create_order

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

Permission and safety

Changes dataYes
ConfirmationRequiredconfirm: 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
shipmentsarrayYesOne or more Shipments; each carries one parcel

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

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

FieldTypeRequiredRule
weightdecimalYesGreater than 0 and at most 70 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 — greater than 0
widthdecimalConditionalRequired for a custom parcel — greater than 0
heightdecimalConditionalRequired for a custom parcel — greater than 0

With a recognised predefinedPackage, the dimensions may be omitted; Mailhub uses the package's own. Without one, all three are required together — two of the three is rejected.

Example input

{
"order": {
"fromAddress": {
"name": "Warehouse Team",
"company": "Example Shipper",
"street1": "500 Example Way",
"city": "Columbus",
"state": "OH",
"zip": "43215",
"country": "US",
"phone": "5555550100"
},
"toAddress": {
"name": "Sample Recipient",
"street1": "72 Sample Street",
"street2": "Apt 4",
"city": "Austin",
"state": "TX",
"zip": "78701",
"country": "US",
"phone": "5125550142",
"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.

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 and that shipments holds at least one parcel. 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_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