Skip to main content
PUT
/
cart
/
item
/
:id
PUT /cart/item/10
{
  "id": 10,
  "cartId": 1,
  "productId": 42,
  "quantity": 5
}

Authentication

This endpoint requires authentication. Include a valid JWT token in the Authorization header.
Authorization: Bearer <token>

Path Parameters

id
integer
required
The ID of the cart item to update (not the product ID)

Request Body

quantity
integer
required
The new quantity for the cart item. Must be at least 1.
PUT /cart/item/10

Response

Returns the updated cart item.
id
integer
required
Unique identifier for the cart item
cartId
integer
required
ID of the cart this item belongs to
productId
integer
required
ID of the product
quantity
integer
required
Updated quantity of the product in the cart
{
  "id": 10,
  "cartId": 1,
  "productId": 42,
  "quantity": 5
}

Behavior

  • This endpoint sets the quantity to the specified value (not incremental)
  • The cart item must belong to the authenticated user’s cart
  • Use the DELETE endpoint if you want to remove the item entirely

Error Responses

Cart Item Not Found (404)

{
  "message": "Item no encontrado en tu carrito"
}
This error occurs when:
  • The cart item ID doesn’t exist
  • The cart item belongs to another user’s cart

Validation Error (400)

{
  "errors": [
    {
      "field": "quantity",
      "message": "La cantidad debe ser al menos 1"
    }
  ]
}

Unauthorized (401)

{
  "message": "Usuario no autenticado"
}

Build docs developers (and LLMs) love