AI Ordering API
After a customer confirms an order in chat, we call your API to create a pending-payment order and give the customer the payment link.
After a customer selects products in the conversation, AI drafts an order for the customer to confirm. Once the customer confirms, we ask your system to create a pending-payment order and give the customer the payment link you return. We do not store orders or handle payments.
In the admin panel's "Bot Settings", fill in the order API (if left blank, AI cannot place orders). You can also fill in the login page URL: when a customer who is not logged in wants to place an order, a "Log in" button appears in the chat window.
Prerequisites:
- Only logged-in customers can place orders.
user_idcomes from theuser_tokenyou issue (see Identify logged-in customers). - Products must be synced via the open API (see Knowledge base and products); products with variants must include
variants[].sku. When placing an order, we pass theskuto you unchanged.
How customers confirm:
- Web chat window: After AI drafts the order, an order card is displayed. The order is created only after the customer clicks "Confirm order"; once created, a "Pay now" button appears on the card.
- Channels that can only send text, such as WeChat Mini Programs: AI sends the customer an order summary. The order is created only after the customer replies "Confirm"; once created, a payment entry point is sent (see
mp_pathbelow).
Request
The same endpoint uses mode to distinguish between quotes and order creation. The signing and signature verification methods are the same as those for the Order lookup API; the timeout is 10 seconds.
POST {你的下单接口}
Content-Type: application/json
X-AICS-Timestamp: 1761120000
X-AICS-Signature: v1=<hex>
{
"mode": "quote",
"request_id": "chk_3f2a9c...",
"user_id": "u_123",
"conversation_id": "b3c1...",
"channel": "widget",
"language": "en",
"country": "US",
"items": [{"product_id": "w1", "sku": "w1-black", "qty": 1}]
}
| Field | Description |
|---|---|
mode | quote: calculate prices only (discounts, shipping, tax), do not create an order or reserve inventory; create: create a pending-payment order |
request_id | The same value is used for the quote and order creation for the same order confirmation. create must return the same order when it receives a duplicate request_id; this prevents duplicate orders from our retries and the customer's repeated clicks |
user_id | The logged-in customer; an order can only be created for this customer |
channel | widget / wechat_mp / api |
language, country | The customer's language and the country of their IP address; may be null; can be used to select the settlement currency and calculate tax |
items[].product_id / sku | The product's external_id and the variant's sku; for products without variants, sku is null |
Response
Quote successful:
{
"status": "quoted",
"currency": "USD",
"goods_amount": "399.00",
"discount": "20.00",
"discounts": [{"label": "新客券", "amount": "20.00"}],
"shipping_fee": "0",
"tax": "0",
"total": "379.00"
}
Order created successfully:
{
"status": "created",
"order_no": "T2026102300001",
"pay_url": "https://shop.example.com/pay?orderno=T2026102300001",
"mp_path": "pages/order/pay?orderno=T2026102300001",
"expires_at": "2026-10-23T12:30:00Z",
"currency": "USD",
"goods_amount": "399.00",
"discount": "20.00",
"shipping_fee": "0",
"tax": "0",
"total": "379.00"
}
Unable to place an order:
{"status": "rejected", "code": "OUT_OF_STOCK", "message": "这款黑色暂时缺货"}
- All amounts are strings.
totalandcurrencyare required; the rest may be omitted.discountsdisplays at most 5 entries. pay_urlis the web payment link and must use https. If a domain allowlist is configured on the "Integration" page, it must also be on an allowlisted domain or one of its subdomains; otherwise it will not be displayed.mp_pathis the payment page path in the Mini Program. In the WeChat channel, it is sent to the customer as a Mini Program card (using the image of the first product as the cover). Ifmp_pathis not provided,pay_urlis sent. At least one of the two must be provided.expires_atis the payment deadline and is displayed on the card.- Possible values for
code:OUT_OF_STOCK,SKU_UNAVAILABLE,REGION_UNAVAILABLE,NOT_LOGGED_IN,LIMIT,OTHER.messageis shown directly to the customer; please use wording the customer can understand. - If you do not want to provide a quote, you can return
{"status": "unsupported"}forquote; the card will estimate the amount based on prices in the product library and note "The final amount is subject to the payment page." - If
createreturns a non-200 response or an invalid format, the order confirmation is retained and the customer can click again; please make sure a duplicaterequest_iddoes not create a second order.
Limits: An order confirmation is valid for 30 minutes. Drafting a new one in the same conversation invalidates the old one. An order can contain at most 10 product types and at most 20 units of each type. A single conversation can create at most 5 orders within 24 hours.
Was this page helpful?
Last updated:
