Skip to content

Submit order (post_order)

About 823 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
}
FieldRequiredDescription
req_idYesIdempotency key, unique per shop, 1–64 characters; reuse the same value on retries
dstm_order_refNoYour storefront's order number, used for reconciliation and support lookups
trace_idNoYour trace identifier; returned unchanged in callbacks
callback_uriNoCallback URL for this order's status changes; defaults to the portal configuration
quote_idNoQuote identifier; when passed, the order transacts at that quoted unit price
items[].sku_id / sku_guidEither oneAt least one is required; when both are given, sku_guid takes precedence
items[].qtyYesQuantity, an integer
items[].manual_schemaNoManual 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.

FieldDescription
req_idEchoes the req_id from your request; the first field
trace_idEchoes the trace_id from your request
accept_stateWhether the order was accepted: accepted / rejected
order_id / order_noOrder identifiers, present only when the order was accepted
totalAmount held
lines[].qtyInteger quantity, without step or similar information
lines[].unit_priceTransacted unit price

Status fields

FieldValuesMeaning
accept_stateaccepted / rejectedWhether the order was accepted
fulfill_statenone / fullWhether the order has been fulfilled in full
fund_stateheld / captured / released / refundedFund state: held / captured / released / refunded
ticket_statenone / open / resolving / resolvedAfter-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

ScenarioResult
Same req_id, identical request contentReturns the original order with code=0; no additional hold
Same req_id, different contentcode=3002; no new order and no hold
New req_idA 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, total is held; insufficient balance returns 2004.
  • 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_uri is passed, changes to this order's status are pushed to that address; otherwise the address configured in the portal is used.
  • Callbacks carry req_id and trace_id unchanged, so you can link orders to traces.

Timeouts and indeterminate results

If the request times out or the network drops:

  1. Do not resend with a new req_id.
  2. Query with get_orders by trace_id.
  3. 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

codeScenarioAction
2004Insufficient available balanceTop up or reduce the quantity
2001SKU does not exist or is delistedRefresh the goods list
2002Goods suspended from saleUpdate the storefront display
2003Non-compliant quantityAdjust per min_qty / max_qty / per in the goods list
3002Idempotency key conflictCheck your business reference number generation
1001Invalid parameter (for example, quote_id inconsistent with the unit price)Re-quote, then submit again
4001Rate limit triggeredBack off per retry_after
xstock 数字供应云服务 · 接入文档