> For the complete documentation index, see [llms.txt](https://docs.whisk.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.whisk.com/master/api/carts/swap-cart-item-product.md).

# Swap Cart Item Product

You can use this API to change the matched products for cart items. It can be useful if the user wants to choose another item or item that was not matched.

Use this [endpoint](/master/api/carts/get-cart-item-options.md) to get alternative product options for the current item. Or this [endpoint](/master/api/retailers/search-store-items.md) to find an alternative by a string.

## Swap Cart Item Product

<mark style="color:green;">`POST`</mark> `https://graph.whisk.com/v1/:cart_id/items/:item_id/swap`

#### Path Parameters

| Name     | Type   | Description            |
| -------- | ------ | ---------------------- |
| cart\_id | string | Unique cart identifier |
| item\_id | string | Unique item identifier |

#### Request Body

| Name    | Type   | Description                                               |
| ------- | ------ | --------------------------------------------------------- |
| newItem | object | The new product for the cart item - StoreItemValue object |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "id": "d57471c6de434340bd600d6b93f7b77c",
  "sourceList": [
    {
      "name": "eggs"
    }
  ],
  "product": {
    "sku": "278837857",
    "name": "Dr.Oetker Egg White Powder Multipack Sach4x5g",
    "quantity": {
      "count": 1
    },
    "price": {
      "list": 1.2
    },
    "images": [
      {
        "url": "https://img.tesco.com/Groceries/pi/303/5000254019303/IDShot_540x540.jpg"
      }
    ],
    "url": "https://www.tesco.com/groceries/en-GB/products/278837857"
  }
}
```

{% endtab %}
{% endtabs %}

## StoreItemValue

| ATTRIBUTE | TYPE           | DESCRIPTION                                  |
| --------- | -------------- | -------------------------------------------- |
| sku\*     | string         | item identifier in Retailer                  |
| quantity  | integer        | number of items to checkout Default value: 1 |
| source    | CartItemSource | source for store product                     |

## CartItemResponse

| ATTRIBUTE    | TYPE                          | DESCRIPTION                                                                   |
| ------------ | ----------------------------- | ----------------------------------------------------------------------------- |
| id\*         | string                        | unique cart item identifier                                                   |
| sourceList\* | array \[CartItemSource]       | list of original ingredients related to the current item                      |
| product      | CartProductOption             | store item                                                                    |
| combined     | array \[CombinedProductsInfo] | information about combined items, if items were combined by a similar product |
| analysis     | object                        | Analysis for cart item (category, product canonical name)                     |

### CartProductOption

| ATTRIBUTE  | TYPE                    | DESCRIPTION                      |
| ---------- | ----------------------- | -------------------------------- |
| sku\*      | string                  | store item identifier            |
| name\*     | string                  | store item name                  |
| quantity\* | CartProductQuantity     | quantity of product items        |
| price      | CartItemPrice           | price for the number of products |
| images\*   | array \[ImageContainer] |                                  |
| url        | string                  | link to product page in store    |

### CartItemPrice

| ATTRIBUTE | TYPE   | DESCRIPTION |
| --------- | ------ | ----------- |
| list\*    | double | list price  |

### CartItemSource

| ATTRIBUTE | TYPE   | DESCRIPTION      |
| --------- | ------ | ---------------- |
| name\*    | string | source item text |
| groupId   | string | group identifier |

### CartProductQuantity

| ATTRIBUTE | TYPE    | DESCRIPTION     |
| --------- | ------- | --------------- |
| count\*   | integer | number of items |

### CombinedProductsInfo

| ATTRIBUTE | TYPE   | DESCRIPTION            |
| --------- | ------ | ---------------------- |
| name\*    | string | name of combined items |

### Sample Request

```bash
curl -X POST "https://graph.whisk.com/v1/:id/items" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Token Access-Token>" \
  -d '{
    "newItem": {
      "sku": "278837857",
      "quantity": 1
    }
  }'
```

### Sample Response

```javascript
{
  "id": "d57471c6de434340bd600d6b93f7b77c",
  "sourceList": [
    {
      "name": "eggs"
    }
  ],
  "product": {
    "sku": "278837857",
    "name": "Dr.Oetker Egg White Powder Multipack Sach4x5g",
    "quantity": {
      "count": 1
    },
    "price": {
      "list": 1.2
    },
    "images": [
      {
        "url": "https://img.tesco.com/Groceries/pi/303/5000254019303/IDShot_540x540.jpg"
      }
    ],
    "url": "https://www.tesco.com/groceries/en-GB/products/278837857"
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.whisk.com/master/api/carts/swap-cart-item-product.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
