Skip to main content
POST
/
orders
Create Order
curl --request POST \
  --url https://api.example.com/orders \
  --header 'Content-Type: application/json' \
  --data '
{
  "items": [
    {
      "productId": "<string>",
      "count": 123,
      "itemPrice": 123
    }
  ],
  "address": {
    "province": "<string>",
    "city": "<string>",
    "detail": "<string>"
  }
}
'
{
  "id": "<string>"
}
Creates a new order with the specified items and delivery address.

Request Body

items
array
required
List of order items. Cannot be empty.
productId
string
required
The ID of the product to order.
count
integer
required
The quantity of the product. Must be at least 1.
itemPrice
decimal
required
The unit price of the product.
address
object
required
The delivery address for the order.
province
string
required
Province or state.
city
string
required
City name.
detail
string
required
Detailed address information.

Response

id
string
The unique identifier of the newly created order.

Status Codes

  • 201 Created - Order successfully created
  • 400 Bad Request - Invalid request body or validation errors

Error Responses

Validation errors will be returned with status 400 and include details about which fields failed validation:
  • “订单项不能为空” - Order items cannot be empty
  • “产品ID不能为空” - Product ID cannot be blank
  • “产品数量必须大于0” - Product count must be greater than 0
  • “产品单价不能为空” - Item price cannot be null
  • “订单地址不能为空” - Order address cannot be null

Example Request

curl -X POST https://api.example.com/orders \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {
        "productId": "prod_123456",
        "count": 2,
        "itemPrice": 29.99
      },
      {
        "productId": "prod_789012",
        "count": 1,
        "itemPrice": 49.99
      }
    ],
    "address": {
      "province": "California",
      "city": "San Francisco",
      "detail": "123 Market St, Suite 400"
    }
  }'

Example Response

{
  "id": "order_abc123def456"
}

Build docs developers (and LLMs) love