Skip to main content
POST
/
orders
/
{id}
/
products
Change Product Count
curl --request POST \
  --url https://api.example.com/orders/{id}/products \
  --header 'Content-Type: application/json' \
  --data '
{
  "productId": "<string>",
  "count": 123
}
'
Updates the quantity of a specific product within an order.

Path Parameters

id
string
required
The unique identifier of the order to modify.

Request Body

productId
string
required
The ID of the product to update. Cannot be blank.
count
integer
required
The new quantity for the product. Must be at least 1.

Response

Returns no content on success.

Status Codes

  • 200 OK - Product count updated successfully
  • 400 Bad Request - Invalid request body or validation errors
  • 404 Not Found - Order not found
  • 409 Conflict - Order cannot be modified or product not in order

Error Responses

Order Not Found (404)

{
  "code": "ORDER_NOT_FOUND",
  "message": "没有找到订单",
  "orderId": "order_123"
}

Order Cannot Be Modified (409)

{
  "code": "ORDER_CANNOT_BE_MODIFIED",
  "message": "订单无法变更",
  "orderId": "order_123"
}
This error occurs when attempting to modify an order that has already been paid or shipped.

Product Not In Order (409)

{
  "code": "PRODUCT_NOT_IN_ORDER",
  "message": "订单不包含产品",
  "productId": "prod_123",
  "orderId": "order_123"
}

Validation Errors (400)

  • “产品ID不能为空” - Product ID cannot be blank
  • “产品数量必须大于0” - Product count must be greater than 0

Example Request

curl -X POST https://api.example.com/orders/order_abc123def456/products \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "prod_123456",
    "count": 5
  }'

Example Response

No content is returned on success (status 200).

Build docs developers (and LLMs) love