Authenticated — all requests require Authorization: Bearer mk_test_…Learn more
API ReferenceShipmentsCreate a shipment
Create a shipment
POST/api/v1/shipments idempotent
Re-quotes the selected service tier server-side, deducts the wallet in live mode (test mode skips), dispatches to the carrier, and returns the full shipment record with pricing snapshot + dispatch result. In live mode, dispatch.waybill_number is the carrier's waybill (e.g. Yun Express YT…) and dispatch.label_pdf_url its label PDF; with an mk_test_* key dispatch is skipped and dispatch is null — the example response shows a live-mode create. Requires Idempotency-Key. service_tier_id takes a Service Code (e.g. HKASTDGGSTCM) — list yours via GET /v1/service_tiers. Optional selected_surcharges opts into SIGNATURE / INSURANCE where eligible (check opt_in_availability on POST /v1/rates; eligibility is gated per destination and carrier product). Optional ioss_number (IM + 10 digits) overrides the account-level IOSS default for this shipment; EU destinations only. A 409 PRICING_QUOTE_CHANGED (1500015) carries data.reason, data.quoted_at, data.expected and data.current_option (the current quote, same shape as a POST /v1/rates option); nothing is charged and no shipment is created. If an administrator has restricted the destination for the Product Code of the chosen service, creation is refused before any wallet hold or shipment is made, in one of two ways. If the destination is already restricted when the create request starts (including when you quoted before the restriction and create after it), the first check refuses it with 400 INVALID_FIELD (data.field service_tier_id), carrying data.unavailable_code CLIENT_PRODUCT_COUNTRY_DISABLED and data.unavailable_reason. Only if the restriction takes effect after that first check has passed, before the final re-quote inside the same create request, does the 409 PRICING_QUOTE_CHANGED instead carry data.current_option.unavailable_code with the same value. Contact customer support to have the destination enabled.
Sandbox IOSS: with a mk_test_* key, first register the number through POST /v1/ioss for the same account, then send that same ioss_number to POST /v1/rates and POST /v1/shipments. The sandbox registry is separate from live: a live registration or live account default alone does not authorize an explicit sandbox override; it returns 400 IOSS_NOT_OWNED until registered in sandbox. Sandbox registration never files with the carrier or changes the live account default. Omitting ioss_number keeps the existing account-default fallback behavior.
USD-wallet account: the response also carries wallet_charge, e.g. {"currency":"USD","amount":12.34} (the amount debited from the wallet, in USD). HKD accounts receive no wallet_charge key.
Parameters
FieldRequirementDescription
service_tier_id*
stringbody
Required
Service Code to book (e.g. HKASTDGGSTCM) — list the codes your account can use via GET /v1/service_tiers. The wire name service_tier_id is historical and kept for backwards compatibility.
recipient*
objectbody
Required
Recipient address. For US destinations, postal_code is required and must be five digits or ZIP+4, e.g. 02108 or 02108-1234. Prefer and retain the full valid ZIP+4 when supplied; use ZIP5 when only a five-digit ZIP is supplied. Shipment storage and carrier submission preserve the supplied postal_code; rating and zone lookup use the first five digits.
Required: contact_name, country_code, city, address. For the US, postal_code is also required. phone, email and district are optional.
parcels*
array<object>body
Required
Each parcel requires weight_kg; length_cm, width_cm and height_cm are optional.
Declared-value currency for the whole shipment (items carry no currency of their own). Accepted values: HKD, USD and, once multi-currency declaration is enabled on the platform, 15 further currencies: EUR, GBP, JPY, AUD, CNY, CAD, SGD, NZD, TWD, MXN, BRL, COP, CLP, MYR, THB (until then they return 400 INVALID_FIELD). "HKD": unit_price and unit_price_hkd are both HKD amounts; the server converts each item's HKD unit price to USD at the rate frozen when the order is placed and stores the shipment in USD (declared_currency reads back as "USD"), while billing still uses the HKD figures you sent (see declared_fx); if no rate can be resolved the whole shipment falls back to being stored in HKD and the order is never rejected for this reason. "USD": every item must use unit_price (not unit_price_hkd); in this mode an unresolvable rate returns 503 (FX_RATE_UNAVAILABLE). Any of the 15 further currencies: every item must use unit_price (not unit_price_hkd); the original currency and amounts are kept on the order (declared_currency reads back as that currency), the HKD billing value is converted at the rates frozen when the order is placed (declared_conversion for the currency to USD rate, declared_fx for USD to HKD), and an unresolvable rate returns 503 (FX_RATE_UNAVAILABLE). Whatever the declared currency, the carrier always receives the declared value in USD. Omitted (changed in v1.20; previously always handled as "HKD"): decided by the price field the items use. If any item carries unit_price, the shipment is read as USD: unit_price is a USD amount, an item with no unit price is declared at 0, and an unresolvable rate returns 503. If no item carries unit_price (items use unit_price_hkd, or carry no unit price), the shipment is handled exactly as "HKD". Mixing unit_price and unit_price_hkd across items while declared_currency is omitted is rejected with 400 INVALID_FIELD. We recommend always sending declared_currency.
items*
array<object>body
Required
Required — at least one item (max 100). Every shipment must declare its contents; a request with no items is rejected with 400 before any order is created. For an item containing a battery, including a built-in battery, send has_battery as the JSON boolean true. Omission and false both mean the item contains no battery. Please declare batteries accurately so Merdi can prepare customs and air cargo declarations. Service and carrier restrictions still apply. See unit_price and unit_price_hkd for pricing field rules.
Each item requires description and quantity. Every item needs a non-blank description_zh for CN-prefixed services, or for a YunExpress service with Hong Kong (HK) origin and Croatia (HR) destination. Other services and routes keep their existing requirements. Missing required names return 400 INVALID_FIELD, with the affected items[i].description_zh paths in data.field. Brazil requires an 8-digit hs_code. unit_price / unit_price_hkd requirements depend on currency and service. sku, country_of_manufacture and is_cspc are optional. Some domestic delivery services are exempt from Brazil HS code and EU product ID requirements. See EU identifiers below.
goods_category
stringbody
Optional
payment_type
enum (prepaid | cod)body
Optional
Payment type. Only "prepaid" is currently available — "cod" (cash on delivery) returns 400 COD_NOT_AVAILABLE (1500034), with no quote, hold or shipment created.
expected_currency
enum (HKD | USD)body
Optional
Currency of expected_total; must equal your wallet currency. Required when expected_total is sent.
expected_discount_rule_id
stringbody
Optional
Discount rule_id returned by the selected /v1/rates option, or null when that option had no discount. When supplied, create rejects if the final quote differs.
expected_total
numberbody
Optional
Currency-neutral price confirmation: the wallet_charge.amount returned by the selected /v1/rates option, in your wallet currency. Required for USD-wallet accounts; accepted (with expected_currency HKD) on HKD accounts, where it is compared with total_hkd. Send it together with expected_currency. When both this and expected_total_hkd are sent, each is checked in its own currency and a mismatch on either rejects the order.
expected_total_hkd
numberbody
Optional
total_hkd returned by the selected /v1/rates option. When supplied, create rejects if the final quote differs. USD-wallet accounts cannot confirm a price with this field alone: they must send expected_total and expected_currency (a request with only expected_total_hkd is refused with 400 INVALID_FIELD, and the message names expected_total and expected_currency).
insured_amount
numberbody
Optional
Custom insured amount, in the shipment's declared currency — the same currency as unit_price (see declared_currency). Replaces the standard insurance pricing basis (0.7% × (freight + declared value), min HKD 9) with 0.7% × this amount converted to HKD (same minimum), using the rates frozen on the order: an HKD amount is used as is; a USD amount is multiplied by declared_fx.rate (USD to HKD); an amount in any of the 15 further currencies is multiplied by both frozen legs, declared_conversion.source_to_usd.rate (that currency to USD) and then declared_fx.rate (USD to HKD), rounded to 2 decimal places. Available only to accounts enrolled for custom insured amount, and only when the selected option's opt_in_availability INSURANCE entry (see POST /v1/rates) carries custom_insured_amount — today that means the cosmetics lane only. Requires "INSURANCE" in selected_surcharges (case-insensitive), else 400 INVALID_FIELD. Must be > 0 with at most 2 decimal places and at most USD 2500 (an HKD amount is converted at the frozen rate first; an amount in any of the further currencies is converted to USD at the frozen rate first) — any other value, or supplying it when the selected option does not support it, returns 400 INVALID_FIELD. On an HKD shipment for which no USD/HKD rate can be resolved, supplying it returns 503 FX_RATE_UNAVAILABLE.
ioss_number
stringbody
Optional
EU IOSS number (IM + 10 digits). Overrides the account-level default for this shipment; EU destinations only. With IOSS, EU VAT prepay is not charged and the number is forwarded to the carrier. The number must belong to your account — your own saved IOSS or a marketplace platform IOSS registered to you (contact support to add one); anything else returns 400 IOSS_NOT_OWNED.
metadata
objectbody
Optional
order_type
stringbody
Optional
Order type: "full_service" (default when omitted — end-to-end shipping, unchanged behaviour) or "domestic_delivery" (destination local delivery). service_tier_id must be a service of the same type (list them with GET /v1/service_tiers?order_type=, or quote them with POST /v1/rates), otherwise 400 ORDER_TYPE_SERVICE_MISMATCH. Unknown values (including empty string and null) return 400 ORDER_TYPE_INVALID; domestic_delivery returns 400 ORDER_TYPE_DISABLED while the feature is off. For domestic_delivery the sender is optional (see the sender field): when it is omitted, incomplete or outside the destination country, the service's destination warehouse is used as the sender; the account default sender address is NOT applied.
reference_no
stringbody
Optional
Optional order reference of your own (e.g. your shop's order number, max 64 chars). Stored with the shipment, echoed in the create response, returned on list/detail reads, and usable as a list filter (GET /v1/shipments?reference_no=). Not required to be unique. Also printed on the carrier label when it is 6–50 characters of letters, digits and # & ( ) * + . : ; < = > ? [ ] ^ _ ` { | } - (not starting with = or +) and no other order already uses it; otherwise the label shows the iMile tracking number.
sales_platform_name
stringbody
Conditional
Sales platform name (free text), required when recipient.country_code is JP — the carrier rejects Japan shipments without it. Optional for other destinations; when supplied it is still forwarded to the carrier. 1–50 characters.
selected_surcharges
array<string>body
Optional
Common opt-in codes (availability depends on the shipment):
SIGNATURE — Signature on delivery
INSURANCE — Insurance
NO_VOEC_PREPAY — Norway VOEC prepayment; subject to the service and feature availability
Quote the same shipment details with the rates API. In data.data, find the service_tier_id and check available and opt_in_availability: code identifies the service, selectable says whether it can be chosen, and reason explains a rejection.
Requote with selected_surcharges. Check available is true, every selected code is present and selectable is true, and review surcharge_conflicts and total_hkd. Then create the shipment with the same details, service and selections. The rates API uses different parcel fields: weight_kg is the total weight, while parcels contains dimensions only.
NO_VOEC_PREPAY is equivalent to voec_prepay and cannot be combined with tax_number, ioss_number or vat_prepay. See voec_prepay below for restrictions. Unsupported INSURANCE returns 400 INSURANCE_UNSUPPORTED. Other opt-in codes may be available; the quote is authoritative.
Sender address, optional. For domestic_delivery every sender field is optional: a complete address in the destination country (for example Colombia or Mexico) is used as given, while an omitted, incomplete or non-local (for example Hong Kong or China) sender is replaced by the service's destination warehouse and marked as system-filled; the original input is kept for the record. For other order types a sender, when provided, must be complete.
If supplied, contact_name, phone, country_code, city and address are required; district and postal_code are optional. Some services require a sender; an account default may apply to full-service orders.
tax_number
stringbody
Conditional
Destination tax registration number (e.g. Norway's VOEC number, or the recipient's RUT for Chile). Required for shipments to Norway (NO) unless voec_prepay is true, otherwise returns 400 TAX_NUMBER_REQUIRED. Exception: on the China-origin lanes CNASTDGGSTCM, CNASTDBTSTCM, CNCSTDGGSTCM and CNCSTDBTSTCM, omitting both tax_number and voec_prepay selects carrier VOEC prepayment by default while that service is enabled (see voec_prepay); send a VOEC number here to use your own instead. Required for shipments to Chile (CL) — the recipient's RUT — otherwise returns 400 CL_TAX_NUMBER_REQUIRED. Mutually exclusive with voec_prepay — sending both returns 400 VOEC_PREPAY_CONFLICT. 1–100 characters after trimming.
vat_number
stringbody
Optional
Optional UK VAT registration number, for recipient.country_code GB only. 1–100 characters after trimming; omit when unused. Kept separate from tax_number (VOEC/RUT), ioss_number and vat_prepay. Passed to YunExpress B2C as customs_number.vat_code; the number must be registered with the carrier in advance. Unsupported services and non-GB destinations return 400 INVALID_FIELD. UK VAT does not select VAT prepayment; vat_prepay remains EU-only.
vat_prepay
booleanbody
Optional
Set true to have the carrier prepay destination VAT on your behalf (EU destinations only) instead of using an IOSS number. Mutually exclusive with ioss_number — sending both returns 400 IOSS_AND_PREPAY_CONFLICT. When true, the EU VAT prepay fee (declared value × destination VAT rate + 2% handling) is charged on the quote.
voec_prepay
booleanbody
Optional
Set true to have the carrier prepay Norway's VOEC VAT on your behalf, skipping tax_number entirely. Norway (NO) destinations only. Supported lanes: (1) Hong Kong-origin lanes HKASTDGGSTCM (standard goods) and HKASTDCSSTCM (cosmetics) — prepayment applies only when you send voec_prepay true (or NO_VOEC_PREPAY in selected_surcharges) and is never the default; (2) China-origin lanes CNASTDGGSTCM, CNASTDBTSTCM, CNCSTDGGSTCM and CNCSTDBTSTCM — prepayment is the default while that service is enabled, so voec_prepay may be omitted (or set true) when you have no VOEC number, and an explicit false behaves the same as omitting it. Any other lane returns 400 VOEC_PREPAY_UNSUPPORTED. Mutually exclusive with tax_number, ioss_number and vat_prepay — sending voec_prepay with any of them returns 400 VOEC_PREPAY_CONFLICT; on the China-origin lanes the default prepayment is likewise refused with 400 VOEC_PREPAY_CONFLICT when ioss_number or vat_prepay is sent without tax_number (send tax_number to use your own VOEC number instead). Equivalent to including "NO_VOEC_PREPAY" in selected_surcharges (case-insensitive) — either form is honoured. Hong Kong lanes: the fee is declared value × 27% on the standard-goods lane (plus HKD 3/shipment, and the carrier product silently switches to HK-ASS-PF) or declared value × 27% on the cosmetics lane (no switch, no per-shipment fee), charged on the quote. China-origin lanes: the fee is declared value × 27% plus a handling fee that steps with chargeable weight (see the surcharge lines of POST /v1/rates), the carrier product switches to TDPHR (general goods) or TDZXR (battery goods), and a shipment whose total declared value is USD 250 or more is refused. If the prepayment cannot be applied to the selected service the request returns 400 VOEC_PREPAY_UNSUPPORTED and is never silently downgraded to a non-prepaid product.
EU product identifiers in items
For each item sent to an EU member state, meet the following requirements (some domestic delivery services are exempt):
Required for EU (may be filled automatically) · merchant_product_id — M-PID (merchant product ID). May be omitted if a valid sku is provided.
Required for EU (may be filled automatically) · mfr_id_nonstd — NS-PID (manufacturer model, batch or serial number). May be omitted if mfr_id_std meets both S-PID and NS-PID format rules; sku cannot replace it.
Optional · mfr_id_std — S-PID (GTIN). If supplied, it must be valid and can replace NS-PID when it also meets NS-PID format rules.
Use the same value for M-PID and NS-PID only if it identifies both. Provide merchant_product_id explicitly if it differs from sku.
Format rules and exceptions
M-PID and NS-PID: half-width ASCII, 2–70 characters per identifier; no placeholders, repeated single characters or numeric sequences such as 1234. Separate multiple identifiers with half-width commas, without empty or duplicate entries. Each field is limited to 200 characters. S-PID must be a valid GTIN of 8, 12, 13 or 14 digits with a correct check digit. Missing or invalid identifiers can return 400 EU_PID_REQUIRED or EU_PID_INVALID. Domestic delivery services that only require a description and quantity are exempt.