Shipments
Product reads retrieve real data. Order preview and shipping quotes estimate costs without creating or paying an order. Procurement creation creates a real business order; procurement payment and shipment payment can spend real funds. Inbound notices create warehouse records, and shipment creation requests warehouse processing. Confirm production activation, the intended order, amount and account before each business mutation. Persist business identifiers and use
Idempotency-Keywhere documented; query the existing result after an uncertain response instead of submitting a new payment.
Create, pay, cancel, intercept, list, and fetch international outbound shipments (/v1/fulfillment/shipments/*).
Lifecycle
Public status codes: PENDING → WAIT_PAYMENT → WAIT_SHIP → SHIPPED → SIGNED. Cancel → CANCELLED.
Create / pay still return a summary total (freight / services / discount / payment). List is lightweight; detail is the full view (split boxes, packing media, first/last-mile relabel, charge lines, warehouse timeline). Scan events stay on International tracking. Field reference: response models.
Retired: POST /v1/fulfillment/shipments/preview, POST /v1/fulfillment/shipments/logistics/trace, POST /v1/fulfillment/shipments/cancel, POST /v1/fulfillment/shipments/detail. Use {id}/tracking, {id}/cancel, and GET {id} instead. Exact freight is returned on create.
POST /v1/fulfillment/shipments/create
Required: tracking_numbers[], receiver, shipping_channel_code. Optional:
external_shipment_id— your stable business/reconciliation identifier. It is not the request retry key.remarkreceiver.personal_code— optional personal customs clearance code (e.g. Korea PCCC). Pass when the shipping lane requires it; Gateway forwards the value as-is and does not validate format or presence.
Which package number belongs in tracking_numbers[]?
US destination (illustrative address and channel placeholder):
{
"tracking_numbers": [
"YOUR_RECEIVED_PACKAGE_TRACKING_NUMBER"
],
"shipping_channel_code": "YOUR_US_CHANNEL_CODE",
"receiver": {
"name": "Alex Morgan",
"mobile": "+12025550123",
"country_code": "US",
"postal_code": "10001",
"address_line1": "123 Example Ave, Apt 4B",
"province": "New York",
"city": "New York"
},
"external_shipment_id": "your-shipment-us-001",
"remark": "Example consolidation request"
}China destination (domestic forwarding example): The endpoint also supports destinations in eligible regions of China, subject to channel coverage. For country_code: "CN", write the recipient name and address fields (province, city, address_line1, and any address_line2) in Chinese, using the actual recipient address rather than English placeholders or romanized text. Include the district within address_line1; the create API does not forward a separate receiver.district field. Use CN001 only when it is returned and available for your app and this destination.
{
"tracking_numbers": [
"YOUR_RECEIVED_PACKAGE_TRACKING_NUMBER"
],
"shipping_channel_code": "CN001",
"receiver": {
"name": "测试收件人",
"mobile": "+8613800000000",
"country_code": "CN",
"postal_code": "200000",
"province": "上海市",
"city": "上海市",
"address_line1": "浦东新区示例路88号3楼"
},
"external_shipment_id": "your-shipment-cn-001",
"remark": "中国境内转运示例"
}Shipment identifier rule
Shipment detail, tracking, cancel, and pay accept either the HioBuy shipment id or the external_shipment_id supplied at create time. Numeric-only path values are resolved as HioBuy internal IDs. Any path value containing a non-digit is resolved as external_shipment_id.
Prefix developer identifiers, for example shp_MY-INTL-ORDER-001. A numeric-only external_shipment_id is allowed at create time but cannot be selected unambiguously through these {shipment_id} paths because it is treated as an internal ID.
Send the optional Idempotency-Key header to protect retries and concurrent create requests. Generate one unique key per logical shipment and reuse it only with the same request body.
POST /v1/fulfillment/shipments/create
Authorization: Bearer <API_KEY>
Content-Type: application/json
Idempotency-Key: 3b4cc23d-c1a3-41a1-b809-c64200f42a71total.payment is the amount charged on pay:
{
"total": {
"freight": {
"amount": 8900,
"currency": "CNY"
},
"services": {
"amount": 1500,
"currency": "CNY"
},
"discount": {
"amount": 200,
"currency": "CNY"
},
"payment": {
"amount": 10200,
"currency": "CNY"
}
}
}Returns id, order_sn, and status (typically PENDING). Public id is the warehouse numeric PK as a string (e.g. "115"); order_sn is the warehouse order number (e.g. JIYUNRI1349). Subsequent pay / cancel / detail / tracking paths use this id.
Create errors (live warehouse → 4xx error object):
| HTTP | error.code | Warehouse upstream_code | Typical message |
|---|---|---|---|
| 404 | PARCEL_NOT_FOUND | SHIPMENT_PACKAGE_NOT_FOUND | 部分包裹不存在 |
| 400 | SHIPMENT_CREATE_EXCEPTION | SHIPMENT_CREATE_EXCEPTION | 请先更新包裹…物品属性信息 / 有包裹不是已入库,下单失败 |
| 400 | SHIPMENT_CREATE_FAILED | SHIPMENT_CREATE_FAILED | 创建订单失败 |
| 409 | EXTERNAL_ORDER_ID_ALREADY_EXISTS | EXTERNAL_ORDER_ID_ALREADY_EXISTS | 外部订单号已存在 |
| 409 | PACKAGE_ALREADY_CONSOLIDATED | PACKAGE_ALREADY_CONSOLIDATED | One or more tracking numbers are already in another shipment |
| 409 | IDEMPOTENCY_CONFLICT | — | Same idempotency key was reused with different parameters |
| 409 | IDEMPOTENCY_REQUEST_IN_PROGRESS | — | A request using the same key is still running |
Recoverable conflict details may include existing_resource, existing_resources, conflicting_tracking_numbers, idempotency_key, and retry_after_ms. If existing_resource identifies the intended shipment, store its shipment_id / order_sn and continue with that resource instead of creating another shipment.
POST /v1/fulfillment/shipments/{shipment_id}/pay
POST /v1/fulfillment/shipments/115/pay
Authorization: Bearer <API_KEY>
Idempotency-Key: d7ade627-41ea-416c-89f9-da4693dc73acPath {shipment_id} follows the shipment identifier rule. Body may be empty. The Gateway sends numeric-only values to the warehouse as shipment_id and prefixed/non-numeric values as external_shipment_id.
Charges fulfillment wallet. Successful pay → WAIT_SHIP.
Idempotency-Key is optional but strongly recommended for payment. Concurrent retries with the same key return the same successful payment result and do not charge twice. Replayed responses may include Idempotency-Replayed: true.
Pay errors:
| HTTP | error.code | Warehouse upstream_code | Typical message |
|---|---|---|---|
| 404 | NOT_FOUND | SHIPMENT_NOT_EXISTS | 订单不存在 |
| 409 | SHIPMENT_NOT_READY_FOR_PAYMENT | SHIPMENT_NOT_READY_FOR_PAYMENT | 该批货物尚未达到可结算状态… |
| 409 | SHIPMENT_ALREADY_PAID | SHIPMENT_ALREADY_PAID | 订单已支付 |
| 402 | INSUFFICIENT_BALANCE | INSUFFICIENT_BALANCE | 余额不足 |
SHIPMENT_ALREADY_PAID may include error.details.existing_resource with the existing transaction_id, shipment_id, payment_status, and paid_at. Treat that as a recoverable state after verifying it matches the intended shipment. IDEMPOTENCY_CONFLICT means the key was reused for different parameters; IDEMPOTENCY_REQUEST_IN_PROGRESS means wait for retry_after_ms and retry with the same key.
POST /v1/fulfillment/shipments/{shipment_id}/cancel
Path {shipment_id} follows the shipment identifier rule. The Gateway sends numeric-only values as shipment_id and prefixed/non-numeric values as external_shipment_id.
cancel_reason is required. Warehouse upstream: POST /api/gateway-worker/v1/shipments/cancel with the resolved identifier and cancel_reason.
{
"cancel_reason": "buyer_request"
}Cancellable while PENDING or WAIT_PAYMENT. Success → CANCELLED.
POST /v1/fulfillment/shipments/{shipment_id}/intercept
v1 requests a hold after outbound has started. This does not change shipment lifecycle status. Warehouse upstream: POST /api/gateway-worker/v1/shipments/set-exceptional with { shipment_id, reason, remark }.
{
"reason": "CUSTOMER_REQUEST",
"remark": "Customer requested to stop the shipment before dispatch."
}reason is a fixed CODE: CUSTOMER_REQUEST / ADDRESS_ISSUE / ORDER_CHANGE / PAYMENT_ISSUE / COMPLIANCE_ISSUE / PACKAGE_ISSUE / OTHER. remark is required when reason is OTHER.
Success:
{
"shipment_id": "107",
"interception": {
"status": "REQUESTED",
"reason": "ADDRESS_ISSUE",
"remark": "Customer address needs to be corrected.",
"requested_at": "2026-08-20T12:30:00Z"
}
}interception.status: REQUESTED → PROCESSING → INTERCEPTED / FAILED. Detail can show status: "SHIPPED" with interception.status: "REQUESTED".
WAIT_SHIP / SHIPPED → Fulfillment; SHIPMENT_NOT_INTERCEPTABLE → Errors.
| HTTP | error.code |
|---|---|
| 404 | SHIPMENT_NOT_FOUND |
| 409 | SHIPMENT_NOT_INTERCEPTABLE |
| 409 | SHIPMENT_INTERCEPTION_ALREADY_REQUESTED |
| 422 | INVALID_INTERCEPTION_REASON |
| 422 | INTERCEPTION_REMARK_REQUIRED |
GET /v1/fulfillment/shipments
GET /v1/fulfillment/shipments?status=WAIT_SHIP&created_from=2026-08-01&page=1&page_size=20
Authorization: Bearer <API_KEY>Lightweight rows. Split boxes, packing files, legs, charge lines, timeline, and interception stay on detail. Warehouse upstream: POST /api/gateway-worker/v1/shipments/index.
| Query | Notes |
|---|---|
status | Comma-separated or repeated. PENDING / WAIT_PAYMENT / WAIT_SHIP / SHIPPED / SIGNED / CANCELLED |
created_from | Lower bound (YYYY-MM-DD or datetime) |
created_to | Upper bound |
page | Default 1 |
page_size | Default 20, max 100 |
Each row has id (warehouse numeric PK as a string), order_sn, external_shipment_id, status, international_tracking, receiver, shipping_channel, services, total, payment_status, and times. Empty warehouse strings become null. Amounts are fen.
International tracking lives only on international_tracking — there is no top-level tracking_number. List times omit updated_at / packing_started_at (those stay on detail).
{
"data": [
{
"id": "107",
"order_sn": "JIYUNRI1338",
"status": "WAIT_SHIP",
"external_shipment_id": "MY-INTL-ORDER-001",
"international_tracking": {
"tracking_number": null,
"carrier": null
},
"receiver": {
"name": "John Doe",
"mobile": "+12025550123",
"email": "john@example.com",
"country_code": "US",
"province": "California",
"city": "Los Angeles",
"district": null,
"postal_code": "90001",
"address_line1": "123 Main St",
"address_line2": "Apt 4B",
"personal_code": null
},
"shipping_channel": {
"code": "PUHUO",
"name": "General Cargo Air Line"
},
"services": [
{
"id": "2",
"service_code": "2",
"name": "Package Reinforcement",
"quantity": 1,
"status": "PENDING"
}
],
"total": {
"charges": {
"amount": 2000,
"currency": "CNY"
},
"discount": {
"amount": 0,
"currency": "CNY"
},
"payable": {
"amount": 2000,
"currency": "CNY"
},
"paid": {
"amount": 0,
"currency": "CNY"
},
"outstanding": {
"amount": 2000,
"currency": "CNY"
}
},
"payment_status": "UNPAID",
"times": {
"created_at": "2026-08-20T09:41:36Z",
"packed_at": "2026-08-20T10:20:00Z",
"paid_at": null,
"shipped_at": null,
"delivered_at": null,
"cancelled_at": null
}
}
],
"pagination": {
"page": 1,
"page_size": 20,
"total": 1,
"total_pages": 1
},
"monetary_unit": "CNY_minor",
"request_id": "req_xxx"
}GET /v1/fulfillment/shipments/{shipment_id}
GET /v1/fulfillment/shipments/107?language=en
Authorization: Bearer <API_KEY>Path {shipment_id} follows the shipment identifier rule. Optional language is for display names (shipping_channel.name, services[].name, charges[].name). Do not expect status_name.
Warehouse upstream: POST /api/gateway-worker/v1/shipments/detail with the resolved shipment_id or external_shipment_id. Public id is the warehouse numeric PK as a string (e.g. "107"); order_sn is the warehouse order number.
This shape covers warehouse facts create/pay cannot express:
| Problem | Where to look |
|---|---|
| Split outbound cartons | boxes[]; multi_box: true when more than one carton |
| International tracking number | international_tracking; per carton boxes[].tracking |
| Warehouse business events | timeline[] (created / packed / paid). Not scan events |
| Packing photos / video | files[]: PACKING_IMAGE / PACKING_VIDEO |
| Relabel (first mile ≠ last mile) | shipping_legs[] when the warehouse sends first/last-mile numbers |
| Block | Meaning |
|---|---|
source_packages | Inbound domestic packages before consolidation (pkg_* + China tracking number) |
boxes | Packed outbound cartons; empty [] until packed |
international_tracking | Shipment-level last-mile { tracking_number, carrier }; both null before outbound |
timeline | Warehouse business events using { code, status, title, occurred_at, details }. Codes are stable and never empty or null |
shipping_legs | Line-haul vs destination last mile after relabel; [] until numbers exist |
files | Packing media (not inbound VAS photos on the package) |
charges | Line items. Discount rows are negative |
total | charges / discount (positive) / payable / paid / outstanding |
payment_status | UNPAID / PAID / PARTIAL |
times | Timestamps; unused nodes are null |
interception | Intercept handling, or null. Independent of shipment status |
Amounts are fen (monetary_unit: CNY_minor). Empty arrays are [], not omitted.
Timeline contract
Shipment status follows PENDING → WAIT_PAYMENT → WAIT_SHIP → SHIPPED → SIGNED; cancellation is CANCELLED. Every timeline[] item requires code, status, title, occurred_at, and details. Codes are stable and non-null, timestamps are timezone-aware ISO 8601, details is {} when empty, and events are newest first. Use code and status for program logic; title is localized display copy.
| Event code | Meaning | Shipment status after event | Required details |
|---|---|---|---|
SHIPMENT_CREATED | Shipment created | PENDING | — |
SHIPMENT_PACKED | Packing completed | WAIT_PAYMENT | — |
SHIPMENT_PAID | Shipment paid | WAIT_SHIP | — |
SHIPMENT_DISPATCHED | Dispatched from warehouse | SHIPPED | — |
SHIPMENT_SIGNED | Delivered and signed for | SIGNED | — |
SHIPMENT_CANCELLED | Shipment cancelled | CANCELLED | — |
SHIPMENT_INTERCEPTION_REQUESTED | Interception requested | Unchanged: WAIT_SHIP or SHIPPED | reason; optional remark |
SHIPMENT_INTERCEPTION_PROCESSING | Interception processing | Unchanged: WAIT_SHIP or SHIPPED | reason; optional remark |
SHIPMENT_INTERCEPTION_SUCCEEDED | Interception succeeded | Unchanged: WAIT_SHIP or SHIPPED | reason; optional remark |
SHIPMENT_INTERCEPTION_FAILED | Interception failed | Unchanged: WAIT_SHIP or SHIPPED | reason; optional failure_code, failure_message |
PICKUP_STATION_ARRIVED | Arrived at pickup station | SHIPPED | station_name |
PICKUP_STATION_SHELVED | Shelved at pickup station | SHIPPED | station_name |
PICKUP_STATION_CHECKED_OUT | Checked out from pickup station | SHIPPED | station_name |
PICKUP_STATION_TRANSFERRED_OUT | Transferred out from pickup station | SHIPPED | station_name |
DISTRIBUTION_CENTER_SORTED | Sorted at distribution center | SHIPPED | Optional facility_name |
Interception is independent: interception.status follows REQUESTED → PROCESSING → INTERCEPTED or FAILED and never overwrites top-level shipment status. Pickup-station names are returned both in rendered title and details.station_name.
{
"id": "107",
"order_sn": "JIYUNRI1338",
"status": "SHIPPED",
"external_shipment_id": "MY-INTL-ORDER-001",
"source_packages": [
{
"id": "pkg_01K2ABC001",
"tracking_number": "SF2026082001"
},
{
"id": "pkg_01K2ABC002",
"tracking_number": "YT2026082002"
}
],
"receiver": {
"name": "John Doe",
"mobile": "+12025550123",
"email": "john@example.com",
"country_code": "US",
"province": "California",
"city": "Los Angeles",
"district": null,
"postal_code": "90001",
"address_line1": "123 Main St",
"address_line2": "Apt 4B",
"personal_code": null
},
"shipping_channel": {
"code": "PUHUO",
"name": "General Cargo Air Line"
},
"multi_box": true,
"international_tracking": {
"tracking_number": "1Z999999999",
"carrier": "UPS"
},
"timeline": [
{
"code": "SHIPMENT_PAID",
"status": "WAIT_SHIP",
"title": "Shipment paid",
"occurred_at": "2026-08-20T10:30:00Z",
"details": {}
},
{
"code": "SHIPMENT_PACKED",
"status": "WAIT_PAYMENT",
"title": "Shipment packed",
"occurred_at": "2026-08-20T10:20:00Z",
"details": {}
},
{
"code": "SHIPMENT_CREATED",
"status": "PENDING",
"title": "Shipment created",
"occurred_at": "2026-08-20T09:41:36Z",
"details": {}
}
],
"boxes": [
{
"id": "box_01K2BOX001",
"box_no": "JIYUNRI1338-1",
"status": "SHIPPED",
"source_package_ids": [
"pkg_01K2ABC001",
"pkg_01K2ABC002"
],
"weight": {
"value": 4.25,
"unit": "kg"
},
"dimensions": {
"length": 45,
"width": 35,
"height": 30,
"unit": "cm"
},
"chargeable_weight": {
"value": 4.73,
"unit": "kg"
},
"tracking": {
"tracking_number": "1Z999999001",
"carrier": "UPS"
}
}
],
"shipping_legs": [
{
"type": "FIRST_MILE",
"carrier": "HioBuy Linehaul",
"tracking_number": "HB202608200001",
"origin_country": "CN",
"destination_country": "US",
"status": "DELIVERED",
"shipped_at": "2026-08-20T12:00:00Z",
"delivered_at": "2026-08-22T04:30:00Z"
},
{
"type": "LAST_MILE",
"carrier": "UPS",
"tracking_number": "1Z999999999",
"origin_country": "US",
"destination_country": "US",
"status": "IN_TRANSIT",
"shipped_at": "2026-08-22T08:00:00Z",
"delivered_at": null
}
],
"files": [
{
"id": "file_01K2ABC001",
"type": "PACKING_IMAGE",
"url": "https://cdn.hiobuy.com/shipments/JIYUNRI1338/packing-01.jpg",
"created_at": "2026-08-20T10:20:00Z"
}
],
"charges": [
{
"type": "FREIGHT",
"code": "FREIGHT",
"name": "Shipping Fee",
"amount": {
"amount": 3200,
"currency": "CNY"
}
},
{
"type": "COUPON_DISCOUNT",
"code": "COUPON",
"name": "Coupon Discount",
"amount": {
"amount": -300,
"currency": "CNY"
}
}
],
"total": {
"charges": {
"amount": 3200,
"currency": "CNY"
},
"discount": {
"amount": 300,
"currency": "CNY"
},
"payable": {
"amount": 2900,
"currency": "CNY"
},
"paid": {
"amount": 2900,
"currency": "CNY"
},
"outstanding": {
"amount": 0,
"currency": "CNY"
}
},
"payment_status": "PAID",
"times": {
"created_at": "2026-08-20T09:41:36Z",
"updated_at": "2026-08-22T08:10:00Z",
"packing_started_at": "2026-08-20T10:00:00Z",
"packed_at": "2026-08-20T10:20:00Z",
"paid_at": "2026-08-20T10:30:00Z",
"shipped_at": "2026-08-20T12:00:00Z",
"delivered_at": null,
"cancelled_at": null
},
"interception": null,
"monetary_unit": "CNY_minor",
"request_id": "req_xxx"
}See response models for charge type values.
Get Support
Need integration help? Contact Developer Support at support@hiobuy.com · Response within 1–2 business days