> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salesive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update cart variant

> Adjust the quantity for a specific variant line item already in the cart.

## Request

```http theme={null}
PATCH /cart/692cd420b07303c9be5eafd7/692cd420b07303c9be5eafda
Authorization: Bearer {{token}}
x-shop-id: {{shopId}}
Content-Type: application/json

{
  "quantity": 3
}
```

## Path parameters

| Parameter   | Type   | Description                                         |
| ----------- | ------ | --------------------------------------------------- |
| `productId` | string | Product identifier that owns the variant line item. |
| `variantId` | string | Variant identifier to update within the product.    |

## Headers

| Header          | Type   | Description                                   |
| --------------- | ------ | --------------------------------------------- |
| `Authorization` | string | Provide the customer token as `Bearer <jwt>`. |
| `x-shop-id`     | string | Identify the shop that owns the cart.         |
| `Content-Type`  | string | Set to `application/json`.                    |

## Body parameters

| Field      | Type    | Required | Description                        |
| ---------- | ------- | -------- | ---------------------------------- |
| `quantity` | integer | Yes      | New quantity to set (minimum `1`). |

## Successful response

```json theme={null}
{
    "status": 200,
    "success": true,
    "message": "Cart item updated",
    "data": {
        "_id": "693606ada7a8f7dc8ae32d80",
        "items": [
            {
                "itemType": "product",
                "product": null,
                "variant": "692cd420b07303c9be5eafda",
                "name": "Wireless Headphones Pro",
                "image": "https://cdn.salesive.com/products/headphones.jpg",
                "price": 25000,
                "sku": "WHP-PRO-BLACK",
                "variantAttributes": {
                    "color": "black"
                },
                "quantity": 3,
                "_id": "6937b6e9e455c711f1fc9064",
                "selectedAddons": [],
                "id": "6937b6e9e455c711f1fc9064"
            }
        ],
        "totalPrice": 75000,
        "id": "693606ada7a8f7dc8ae32d80"
    }
}
```

## Error response

```json theme={null}
{
    "status": 404,
    "success": false,
    "message": "Cart item not found",
    "data": {}
}
```


## OpenAPI

````yaml PATCH /cart/{productId}/{variantId}
openapi: 3.1.0
info:
  title: Salesive Store API
  description: >-
    REST interface for querying products, categories, and merchandising banners
    exposed by Salesive storefronts.
  version: 1.0.0
servers:
  - description: Production
    url: https://store.salesive.com/api/v1
security:
  - BearerAuth: []
    ShopIdHeader: []
paths:
  /cart/{productId}/{variantId}:
    patch:
      summary: Update cart variant
      description: Update the quantity for a specific variant line item in the cart.
      parameters:
        - $ref: '#/components/parameters/XShopIdHeader'
        - $ref: '#/components/parameters/CartProductIdPathParam'
        - $ref: '#/components/parameters/CartVariantIdPathParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCartItemRequest'
      responses:
        '200':
          description: Cart variant updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CartResponse'
        '404':
          description: Cart item not found.
components:
  parameters:
    XShopIdHeader:
      name: x-shop-id
      in: header
      description: >-
        Optional identifier that scopes responses to a specific storefront when
        the referer cannot be inferred.
      required: false
      schema:
        type: string
    CartProductIdPathParam:
      name: productId
      in: path
      required: true
      description: >-
        Identifier of the cart line to target. Accepts the cart line's own
        `_id`, or the product, food, or service id it holds. A catalog id
        (product/food/service) matches every line for that item — for a food or
        service added with different add-on combinations, target one specific
        line by its `_id` via `/cart/item/{itemId}`.
      schema:
        type: string
    CartVariantIdPathParam:
      name: variantId
      in: path
      required: true
      description: Variant identifier for the cart item.
      schema:
        type: string
  schemas:
    UpdateCartItemRequest:
      type: object
      required:
        - quantity
      properties:
        quantity:
          type: integer
          minimum: 0
          description: New quantity for the cart line item. Set to `0` to remove the line.
    CartResponse:
      type: object
      required:
        - status
        - success
        - message
        - data
      properties:
        status:
          type: integer
          description: HTTP status code returned by the API.
        success:
          type: boolean
          description: Indicates whether the request succeeded.
        message:
          type: string
          description: Human-readable response message.
        data:
          $ref: '#/components/schemas/Cart'
    Cart:
      type: object
      required:
        - _id
        - items
        - totalPrice
      properties:
        _id:
          type: string
          description: Cart identifier.
        user:
          type: string
          description: Identifier of the shopper who owns the cart.
        shop:
          type: string
          description: Identifier of the shop associated with the cart.
        items:
          type: array
          items:
            $ref: '#/components/schemas/CartItem'
        totalPrice:
          type: number
          description: Total price of all items in the cart.
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the cart was created.
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when the cart was last updated.
    CartItem:
      type: object
      required:
        - itemType
        - name
        - image
        - price
        - quantity
      properties:
        _id:
          type: string
        itemType:
          type: string
          enum:
            - product
            - food
            - service
        product:
          type: object
          description: Product or variant metadata for the cart item.
          properties:
            _id:
              type: string
            id:
              type: string
            name:
              type: string
            images:
              type: array
              items:
                type: string
                format: uri
            price:
              type: number
            promoPrice:
              type: number
              nullable: true
            sku:
              type: string
            parentProductId:
              type: string
            variantAttributes:
              type: object
              additionalProperties:
                type: string
        food:
          type: object
          description: Food metadata for a food line item.
          properties:
            _id:
              type: string
            id:
              type: string
            name:
              type: string
            images:
              type: array
              items:
                type: string
                format: uri
            price:
              type: number
            promoPrice:
              type:
                - number
                - 'null'
        foodId:
          type: string
          description: Identifier of the food item when `itemType` is `food`.
        variant:
          type: string
          description: Identifier of the variant if the line item is variant-based.
        name:
          type: string
          description: Display name of the line item.
        image:
          type: string
          format: uri
          description: Primary image for the line item.
        price:
          type: number
          description: Unit price of the line item.
        sku:
          type: string
          description: SKU of the line item, if applicable.
        variantAttributes:
          type: object
          description: Attributes for the selected variant.
          additionalProperties:
            type: string
        quantity:
          type: integer
          minimum: 1
          description: Quantity of the line item in the cart.
        selectedAddons:
          type: array
          items:
            $ref: '#/components/schemas/SelectedAddon'
          description: Snapshot of selected add-ons for food items.
    SelectedAddon:
      type: object
      required:
        - addonId
        - name
        - price
        - quantity
      properties:
        addonId:
          type: string
        name:
          type: string
        description:
          type: string
        price:
          type: number
        quantity:
          type: integer
          minimum: 1
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT issued by the Salesive Store API for authenticated shoppers.
    ShopIdHeader:
      type: apiKey
      in: header
      name: x-shop-id
      description: >-
        Optional storefront identifier sent as a header to scope responses to a
        specific shop. Try It requests remember this value once provided.

````