TestingAPIs is still being built. If something breaks, email support@testingapis.com.

Update a cart

PUThttps://api.testingapis.com/api/Carts/{id}Sign in to see this endpoint's URL

Use this to add or remove items.

Parameters 1

NameTypeDescription
idrequiredpath · integer (int32)Cart ID.

Request body

Optional. application/json, text/json, application/*+json, application/xml, text/xml, application/*+xml. Model: Cart. The new field values.

Example body
{
  "userId": 101,
  "items": [
    {"productId": 3, "quantity": 2, "price": 89.99},
    {"productId": 7, "quantity": 1, "price": 49.99}
  ],
  "total": 229.97,
  "updatedAt": "2025-07-16T12:00:00Z"
}

Responses

200
Updated; returns { message, data }.
404
The cart does not exist.
500
Unexpected server error.

Example

Request
curl -X PUT "https://api.testingapis.com/api/Carts/9" \
  -H "Content-Type: application/json" \
  -d '{"userId": 101, "items": [{"productId": 3, "quantity": 2, "price": 89.99}, {"productId": 7, "quantity": 1, "price": 49.99}], "total": 229.97, "updatedAt": "2025-07-16T12:00:00Z"}' \
  -H "X-TestingApis-Key: YOUR_API_KEY"
Response200 OK
{
  "message": "Cart updated successfully",
  "data": {
    "id": 9,
    "userId": 101,
    "items": [
      {"productId": 3, "quantity": 2, "price": 89.99},
      {"productId": 7, "quantity": 1, "price": 49.99}
    ],
    "total": 229.97,
    "updatedAt": "2026-09-30T18:26:45Z"
  }
}

Sign in to see the details

The parameters, request and response examples and the live Try it panel for this endpoint are for signed-in members. Accounts are free and take a few seconds to create.