Skip to main content

Buy Label

mailhub_buy_label

Buy a shipping Label for a Shipment using a Rate returned by mailhub_get_shipment_rates. This is the one tool that spends money.

Permission and safety

Changes dataYes
ConfirmationRequiredconfirm: true
Spends fundsYes — real wallet funds
PermissionUpdate access to Orders

Input

FieldTypeRequiredNotes
shipmentIdstringYesThe Shipment's UUID
rateIdstringYesThe chosen Rate's UUID, from mailhub_get_shipment_rates
confirmbooleanNoDefaults to false; the operation is refused unless the value is the boolean true

Example input

{
"shipmentId": "22222222-2222-2222-2222-222222222222",
"rateId": "33333333-3333-3333-3333-333333333333",
"confirm": true
}

Output

Either the completed purchase, or an acknowledgement that the purchase was accepted and is still running.

  • Completed — the Label is bought and its detail comes back.
  • Still running — Mailhub accepted the purchase and is finishing it. There is no dedicated purchase-status tool; check the Order again with mailhub_get_order, or ask for the Label with mailhub_download_label a few seconds later.

Rules and common tool-specific errors

Mailhub validates the Rate against the Shipment, checks the Order's status, checks the agent spend limit and the wallet balance, and then buys the Label with the carrier. The Order moves to LabelCreated as a result of the purchase — you do not set that status yourself.

Order statuses that block a purchase

A purchase is refused when the Order is:

StatusWhyWhat to do
CancelledThe Order will not shipNothing — the Order is closed
OnHoldThe Order is paused; the refusal names the status to resume it toResume it with mailhub_update_order_status, then buy
FulfilledThe Order has already been handed overNothing
ReturnedThe Order came backNothing
LabelCreatedA Label already exists for itUse mailhub_download_label, or cancel the existing Label first

A refusal for an on-hold Order happens before any wallet activity, so no funds are touched. Order Statuses sets out the whole fulfillment model these rules come from.

  • A Rate is a point-in-time quote. A stale Rate is refused; rate again and buy the new one.
  • A Label that was bought and then cancelled before its result came back is a terminal answer, not a retry. Buy a new Label if the Shipment still needs one.

Common tool-specific errors

CodeWhat it meansRetrying
MCP_CONFIRMATION_REQUIREDThe call did not carry confirm: trueYes, confirming
MCP_INVALID_UUIDshipmentId or rateId is not a UUIDNo — fix the value
MCP_WRITE_RATE_LIMITEDToo many changing calls for the account just nowYes, shortly
Wallet.InsufficientFundsThe wallet balance is below the amountAfter topping up in Mailhub
Wallet.McpSpendCapExceededThe purchase would exceed the account's rolling 24-hour agent spend limitAfter the window moves on, or after the limit is raised in Mailhub
LabelPurchase.InProgressAnother purchase for this Shipment is still runningAfter it settles
A carrier rejection or carrier unavailabilityThe carrier declined or could not be reachedDepends on the message — correct and retry, or retry shortly

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

Next