application/json

Body Required

  • items array[object] Required

    List of items in the order

    Hide items attributes Show items attributes object
    • productId string Required

      CUID of the product

    • quantity integer(int32) Required

      Quantity of the product

      Minimum value is 1.

    • price number(double) Required

      Price per unit at the time of order (Note: Server should ideally verify this)

Responses

  • 201 application/json

    Order created successfully

    Hide response attributes Show response attributes object
    • id string Required

      Unique identifier for the order (CUID)

    • userId string Required

      CUID of the user who placed the order

    • status string Required

      Current status of the order (e.g., 'New', 'Processing', 'Shipped')

      Default value is New.

    • createdAt string(date-time) Required

      Timestamp when the order was created

    • stripePaymentIntentId string | null

      Associated Stripe Payment Intent ID

    • items array[object] Required
      Hide items attributes Show items attributes object
      • id string Required

        Unique identifier for the order item (CUID)

      • orderId string Required

        CUID of the order this item belongs to

      • productId string Required

        CUID of the product

      • quantity integer(int32) Required
      • price number(double) Required

        Price per unit at the time of order

  • 400 application/json

    Bad Request (e.g., invalid order data, missing items)

    Hide response attribute Show response attribute object
    • message string Required

      A message describing the error

  • 401 application/json

    Unauthorized (User not authenticated)

    Hide response attribute Show response attribute object
    • message string Required

      A message describing the error

  • 500 application/json

    Internal Server Error

    Hide response attribute Show response attribute object
    • message string Required

      A message describing the error

POST /orders
curl \
 --request POST 'http://localhost:3000/api/v1/orders' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"items":[{"price":19.99,"quantity":2,"productId":"clv3x..."},{"price":45.5,"quantity":1,"productId":"clv4y..."}]}'
Request example
{
  "items": [
    {
      "price": 19.99,
      "quantity": 2,
      "productId": "clv3x..."
    },
    {
      "price": 45.5,
      "quantity": 1,
      "productId": "clv4y..."
    }
  ]
}
Response examples (201)
{
  "id": "string",
  "userId": "string",
  "status": "New",
  "createdAt": "2025-05-04T09:42:00Z",
  "stripePaymentIntentId": "string",
  "items": [
    {
      "id": "string",
      "orderId": "string",
      "productId": "string",
      "quantity": 42,
      "price": 42.0
    }
  ]
}
Response examples (400)
{
  "message": "Order not found"
}
Response examples (401)
{
  "message": "Order not found"
}
Response examples (500)
{
  "message": "Order not found"
}