Submit order (post_order)
About 824 words
v1 draft
This page is part of the draft v1 integration contract; details may change along with the integration checklist, so rely on the official checklist published in the portal.
Submits a sales order. Acceptance places a hold on the corresponding balance; the order is fulfilled and charged once it can be assembled in full.
- Permission:
order.create - Method:
POST - Idempotency: keyed by
req_id(unique per shop)
正在加载交互式结构…
Request example
Endpoint: POST /dist/api/v1/post_order
{
"id": "shop-a-20261124-ord-001",
"cmd": "post_order",
"data": {
"req_id": "shop-a-20261124-0001",
"dstm_order_ref": "202611240001",
"trace_id": "trace-7f3a9c",
"callback_uri": "https://shop-a.example/api/xstock/callback",
"quote_id": "q_8f21c0",
"items": [
{
"sku_guid": "5d8f2a6c9e1b4d3f8a7c0e2b5d9f1a3c",
"qty": 2,
"manual_schema": {}
}
],
"remark": ""
},
"stamp": 1795000000
}| Field | Required | Description |
|---|---|---|
req_id | Yes | Idempotency key, unique per shop, 1–64 characters; reuse the same value on retries |
dstm_order_ref | No | Your storefront's order number, used for reconciliation and support lookups |
trace_id | No | Your trace identifier; returned unchanged in callbacks |
callback_uri | No | Callback URL for this order's status changes; defaults to the portal configuration |
quote_id | No | Quote identifier; when passed, the order transacts at that quoted unit price |
items[].sku_id / sku_guid | Either one | At least one is required; when both are given, sku_guid takes precedence |
items[].qty | Yes | Quantity, an integer |
items[].manual_schema | No | Manual delivery fields; pass them per manual_deliver_schema from the goods list |
Response example
{
"id": "shop-a-20261124-ord-001",
"cmd": "post_order",
"code": 0,
"msg": "",
"data": {
"req_id": "shop-a-20261124-0001",
"trace_id": "trace-7f3a9c",
"accept_state": "accepted",
"order_id": 9001,
"order_no": "XS20261124000123",
"status": "paid",
"fulfill_state": "none",
"fund_state": "held",
"total": { "amt": "19.00", "ccy": "CNY" },
"created_at": "2026-11-24T13:05:21Z",
"lines": [
{
"line_no": 1,
"sku_id": 1001,
"sku_guid": "5d8f2a6c9e1b4d3f8a7c0e2b5d9f1a3c",
"qty": 2,
"unit_price": { "amt": "9.50", "ccy": "CNY" }
}
],
"balance": {
"available": { "amt": "501.00", "ccy": "CNY" },
"held": { "amt": "19.00", "ccy": "CNY" }
}
},
"stamp": 1795000001
}accept_state is the first field and the primary basis for judging the result. When the order is rejected, order_id and order_no are not returned — no order means no order number, so never use the req_id from your request as an order number.
| Field | Description |
|---|---|
req_id | Echoes the req_id from your request; the first field |
trace_id | Echoes the trace_id from your request |
accept_state | Whether the order was accepted: accepted / rejected |
order_id / order_no | Order identifiers, present only when the order was accepted |
total | Amount held |
lines[].qty | Integer quantity, without step or similar information |
lines[].unit_price | Transacted unit price |
Status fields
| Field | Values | Meaning |
|---|---|---|
accept_state | accepted / rejected | Whether the order was accepted |
fulfill_state | none / full | Whether the order has been fulfilled in full |
fund_state | held / captured / released / refunded | Fund state: held / captured / released / refunded |
ticket_state | none / open / resolving / resolved | After-sales ticket state (returned when querying orders) |
On rejection, accept_state=rejected, code is non-0, msg explains the reason, no funds are held, and the response contains no order_id / order_no.
Idempotency semantics
| Scenario | Result |
|---|---|
Same req_id, identical request content | Returns the original order with code=0; no additional hold |
Same req_id, different content | code=3002; no new order and no hold |
New req_id | A new order |
Never reuse idempotency keys
Do not build the idempotency key from "current time + goods", and do not regenerate it when retrying. One business request maps to one fixed value; if you genuinely need to order again (for example, the previous order was cancelled), use a new key and link it to the original order in your own system.
Funds and fulfillment
- On acceptance,
totalis held; insufficient balance returns2004. - The whole order is fulfilled and charged in a single step once it can be assembled in full; partial fulfillment and split charges are not supported.
- Cancelling before fulfillment releases the hold (a release, not a refund).
- Cancellation is not supported after fulfillment; use after-sales for quality issues.
Callbacks
- When
callback_uriis passed, changes to this order's status are pushed to that address; otherwise the address configured in the portal is used. - Callbacks carry
req_idandtrace_idunchanged, so you can link orders to traces.
Timeouts and indeterminate results
If the request times out or the network drops:
- Do not resend with a new
req_id. - Query with
get_ordersbytrace_id. - If the order exists, continue based on its status; only after confirming there is no order, retry once with the original key.
The same applies when a 9xxx code is returned: verify first.
Errors
| code | Scenario | Action |
|---|---|---|
2004 | Insufficient available balance | Top up or reduce the quantity |
2001 | SKU does not exist or is delisted | Refresh the goods list |
2002 | Goods suspended from sale | Update the storefront display |
2003 | Non-compliant quantity | Adjust per min_qty / max_qty / per in the goods list |
3002 | Idempotency key conflict | Check your business reference number generation |
1001 | Invalid parameter (for example, quote_id inconsistent with the unit price) | Re-quote, then submit again |
4001 | Rate limit triggered | Back off per retry_after |