Merge Orders
mailhub_merge_orders
Merge 2 to 25 Orders into one new Shipment, packed in one box and bought with
one Label. Use Orders that
mailhub_find_merge_candidates lists
as available. The Orders stay separate Orders, each with its own identifier and
status; what they share is the Shipment, its parcel, its Rates, and its Label.
Permission and safety
| Changes data | Yes |
| Confirmation | Required — confirm: true |
| Spends funds | No |
| Permission | Update access to Orders |
Confirmation is enforced by the server — see
Confirmations & Spend Safety. Merging buys nothing: postage is still a separate
mailhub_buy_label call. Asking for the same merge
again answers with the same Shipment.
Input
| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
anchorOrderId | string | Yes | — | The Order to start the merge from; its addresses are copied onto the Shipment |
orderIds | array of strings | Yes | — | Every Order to merge, the anchor included — 2 to 25 Order UUIDs |
parcel | object | No | — | The box for the merged Shipment, in the same shape as on mailhub_create_order |
confirm | boolean | No | false | Defaults to false; the call is refused unless the value is the boolean true |
Without a parcel, the box takes the anchor's size and the Orders' weights
added together.
Example input
{
"anchorOrderId": "11111111-1111-1111-1111-111111111111",
"orderIds": [
"11111111-1111-1111-1111-111111111111",
"22222222-2222-2222-2222-222222222222"
],
"confirm": true
}
Output
The merged Shipment and its Orders, passed through from Mailhub, with a note
that one Label will cover every Order in it. Use the merged Shipment's
identifier from here on: rate it with
mailhub_get_shipment_rates.
Rules and common tool-specific errors
- Fewer than two Orders is refused with
MCP_MISSING_FIELDbefore Mailhub is called. - An Order that cannot be merged refuses the whole merge with
Order.MergeRefused. The result does not say which Order was refused or why: callmailhub_find_merge_candidatesto see which Orders are unavailable and theirunavailableReason. - Every Order must be
DraftorCreated, ship within the US, and go to the same recipient from the same source — the REST guide has the full rules. - Access and shared failures — sign-in, permissions, rate guards — are listed in Errors & Troubleshooting.
Next
mailhub_get_shipment_rates— Rates for the merged Shipment.mailhub_unmerge_shipment— take it apart again before a Label is bought.