Skip to main content

Assign Warehouse

mailhub_assign_warehouse

Set, change, or remove the warehouse one or more Orders ship from. Only Draft and Created Orders can change warehouse. The user chooses the warehouse: take its identifier from a mailhub_list_warehouses call made for this assignment, and ask when the choice is not clear.

Permission and safety​

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

Confirmation is enforced by the server — see Confirmations & Spend Safety. Assigning a warehouse buys nothing. The same warehouse rules as the Mailhub application apply: a user limited to specific warehouses can use only those.

Input​

FieldTypeRequiredDefaultNotes
orderIdsarray of stringsYes—Every Order to change, by UUID
warehouseIdstringNo—The warehouse's UUID, to set or change the warehouse. Omit it only together with removeWarehouse
removeWarehousebooleanNofalsetrue takes the warehouse off the Orders. Never combine it with warehouseId
confirmbooleanNofalseDefaults to false; the call is refused unless the value is the boolean true

Send exactly one of warehouseId and removeWarehouse: true. Leaving warehouseId out removes nothing — without removeWarehouse the call is refused with MCP_MISSING_FIELD, and sending both is refused with MCP_CONFLICTING_FIELDS.

Example input​

{
"orderIds": [
"11111111-1111-1111-1111-111111111111",
"22222222-2222-2222-2222-222222222222"
],
"warehouseId": "33333333-3333-3333-3333-333333333333",
"confirm": true
}

Output​

One outcome per Order, so some Orders can succeed while others do not — report each one. A note explaining the outcomes that occurred comes with the result.

  • Assigned — the warehouse is set or removed. Asking again for Orders already in that warehouse also answers Assigned, so the call is safe to repeat.
  • WrongStatus — only a Draft or Created Order can change warehouse, and not while a Label is being bought for it.
  • NoAccess — the user may not use that warehouse, or may not take the Order off the one it is in. List the warehouses again rather than retrying with the same one.
  • NotFound — no such Order for this user, including an Order in a warehouse the user cannot see.
  • Changed — the Order or its merged Shipment changed while it was being assigned. Read it again and assign again only if it still needs the warehouse.

The result does not name the warehouse. Read an assigned Order with mailhub_get_order before telling the user it worked.

Rules and common tool-specific errors​

  • Setting a warehouse replaces the sender address — street, city, state, ZIP, and country — with the warehouse's address, and keeps the sender contact. Removing one leaves the sender as it is. A Draft that lacked only the sender may become Created.
  • Removing a warehouse is never done on the first request. The first removal call is refused with MCP_CONFIRM_WAREHOUSE_REMOVAL and changes nothing. Tell the user how many Orders and which ones, and that a user limited to specific warehouses cannot get Rates or buy a Label for an Order without a warehouse, then send the identical call again only if they agree.
  • A merged Shipment moves together. Change every Order of a merged Shipment (mergedWith on mailhub_get_order) in the same call. An Order changed alone leaves the Shipment — and so does removing its warehouse.
  • Rates fetched earlier may be dropped. Get them again before buying a Label.
  • Access and shared failures — sign-in, permissions, rate guards — are listed in Errors & Troubleshooting.

Next​