# Add Items to a Shopping List

## Add Items

<mark style="color:orange;">`PUT`</mark> `https://api.whisk.com/list/v2/{id}/item`

You can use a body parameter to add items to a shopping list:

#### Path Parameters

| Name | Type   | Description                   |
| ---- | ------ | ----------------------------- |
| id   | string | The shopping list identifier. |

#### Headers

| Name           | Type   | Description                                                                                                                                      |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Authentication | string | Server Token or a User Access token containing `shopping_list:write` scope to authorize the API usage. For more information, see Authentication. |

#### Request Body

| Name | Type   | Description                                                                         |
| ---- | ------ | ----------------------------------------------------------------------------------- |
| body | object | The body object contains a list of items to add. See the Body Object Example below. |

```graphql
{
  "list": {
    "id": "string",
    "name": "string",
    "primary": true
  },
  "content": {
    "items": [
      {
        "id": "string",
        "item": {
          "name": "string",
          "brand": "string",
          "comment": "string",
          "quantity": 0,
          "unit": "string"
        },
        "checked": true,
        "image_url": "string",
        "analysis": {
          "product": {
            "canonical_name": "string",
            "original_name": "string"
          },
          "category": {
            "canonical_name": "string"
          },
          "brand": {
            "canonical_name": "string"
          }
        },
        "recipe": {
          "recipe_id": "string",
          "position": 0
        },
        "combined": {
          "combined_item_id": "string",
          "quantity": 0
        },
        "created_time": "string",
        "updated_at": "string",
        "matching_properties": {
          "gtin": "string",
          "custom_product_id": "string"
        }
      }
    ],
    "combined_items": [
      {
        "id": "string",
        "item": {
          "name": "string",
          "brand": "string",
          "comment": "string",
          "quantity": 0,
          "unit": "string"
        },
        "checked": true,
        "image_url": "string",
        "analysis": {
          "product": {
            "canonical_name": "string",
            "original_name": "string"
          },
          "category": {
            "canonical_name": "string"
          },
          "brand": {
            "canonical_name": "string"
          }
        },
        "created_time": "string",
        "updated_at": "string"
      }
    ],
    "recipes": [
      {
        "id": "string",
        "name": "string",
        "images": [
          {
            "responsive": {
              "url": "string",
              "width": 0,
              "height": 0,
              "selection": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              }
            },
            "url": "string"
          }
        ],
        "source": {
          "name": "string",
          "display_name": "string",
          "source_recipe_url": "string",
          "image": {
            "responsive": {
              "url": "string",
              "width": 0,
              "height": 0,
              "selection": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              }
            },
            "url": "string"
          },
          "license": "LICENCE_INVALID"
        }
      }
    ]
  }
}
```

```yaml
{
  "error_code": "REAL_CODES_ARE_IN_ENDPOINT_DESCRIPTION",
  "message": "Additional details about error are not static and can be changed"
}
```

{% tab title="401 This failed response appears due to API authentication failure. The possible error codes that may appear are: auth.tokenNotFound , auth.tokenExpired, auth.tokenInvalid, auth.tokenRequired." %}

```yaml
{
  "code": "auth.tokenNotFound"
}
```

```yaml
This is unexpected response, something is wrong on our side, please contact: help@whisk.com
```

### Request Body Object Example

```graphql
{
   "items":[
      {
         "normalized":{
            "name":"bacon",
            "brand":"Oscar mayer",
            "comment":"cooked, crumbled",
            "quantity":8,
            "unit":"slices"
         },
         "gtin":"00000034411207"
      },
      {
         "raw":{
            "text":"2 garlic cloves"
         },
         "custom_product_id":"6037bd956f0187c6c0f56241"
      }
   ],
   "recipes":[
      {
         "recipe_id":"1011f5a116db3c3e56e57bea0a52ffbfca5fc96f6b1",
         "scale":{
            "scale":2
         },
         "ingredients":{
            "ids":[
               "f83e58370ebc70b01798c575f5132a76d8dba890:1:0"
            ]
         }
      },
      {
         "recipe_id":"10745889d4a1c0f4b8dbfab66bffa433524"
      }
   ]
}
```

The `body` object contains the following attributes that let you add items to your shopping list:

#### `items`

The `items` array allows you to add individual items in a normalized or raw format based on your preference.

| Attribute    | Type   | Description                                                                                                                                                                                                                                                             | Example |
| ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `normalized` | object | <p>This object allows you to add items in a normalized format by specifying each information element of the item separately.</p><p>Optionally, you can also link an item to a custom product using <code>gtin</code> or <code>custom\_product\_id</code> if needed.</p> | `{`     |

`"normalized":{`

`"name":"bacon",`

`"brand":"Oscar mayer",`

`"comment":"cooked, crumbled",`

`"quantity":8,`

`"unit":"slices"`

`},`

`"gtin":"00000034411207"`

`}`

\| | \`raw\` | object | This object allows you to add the item details like a raw string and leave it for automatic normalization. Optionally, you can also link an item to a custom product using \`gtin\` or \`custom\_product\_id\` if needed. |

`{`

`"raw":{`

`"text":"2 garlic cloves"`

`},`

`"custom_product_id":"6037bd956f0187c6c0f56241"`

`}`

|

#### `recipes`

The `recipes` array allows add a list of recipes to move their ingredients as items in your shopping list. You can either specify the exact ingredients of a particular recipe or move all recipe ingredients to the shopping list, depending on the need.

| Attribute     | Type   | Description                                                                                                                                                                                                                                                                                                                               | Example                                                                                                                                                                                          |
| ------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `recipe_id`   | string | This attribute allows you to identify the recipe for moving its ingredients as items to your shopping list.                                                                                                                                                                                                                               | `recipe_id": "1011f5a116db3c3e56e57bea0a52ffbfca5fc96f6b1"`                                                                                                                                      |
| `scale`       | object | This object allows you to mention the scale to determine and set the ingredient's quantity while adding it to the shopping list. For example, if you set it to 2, the ingredient/item's count or volume gets doubled in the shopping list. If you want to add the exact quantity specified in the recipe, you can skip it or set it to 1. | <p><code>"scale":</code></p><p><code>{</code></p><p><code>"scale":2</code></p><p><code>}</code></p>                                                                                              |
| `ingredients` | object | This array allows you individually specify each recipe ingredient that you want to add as an item to the shopping list. If you are looking to move all recipe ingredients to your shopping list, you can skip it.                                                                                                                         | <p><code>"ingredients":{</code></p><p><code>"ids":\[</code></p><p><code>"f83e58370ebc70b01798c575f5132a76d8dba890:1:0"</code></p><p><code>]</code></p><p><code>}</code></p><p><code>}</code></p> |

### Sample Request and Response

{% tabs %}
{% tab title="Curl Request" %}

```bash
curl -X PUT "https://api.whisk.com/list/v2/106c5fa85ddbba343099347c57e54632500/item"
    -H "Accept: application/json"
    -H "Authorization: Bearer <YOUR-API-ACCESS-KEY>"
    -d "{ \"items\":[ { \"normalized\":{ \"name\":\"bacon\", \"brand\":\"Oscar mayer\", \"comment\":\"cooked, crumbled\", \"quantity\":8, \"unit\":\"slices\" }, \"gtin\":\"00000034411207\" }, { \"raw\":{ \"text\":\"2 garlic cloves\" }, \"custom_product_id\":\"6037bd956f0187c6c0f56241\" } ], \"recipes\":[ { \"recipe_id\":\"1011f5a116db3c3e56e57bea0a52ffbfca5fc96f6b1\", \"scale\":{ \"scale\":2 }, \"ingredients\":{ \"ids\":[ \"f83e58370ebc70b01798c575f5132a76d8dba890:1:0\" ] } }, { \"recipe_id\":\"10745889d4a1c0f4b8dbfab66bffa433524\" } ]}"
```

{% hint style="info" %}
Whisk allows you to discover and understand its API capabilities on the Swagger interface with the ability to try out the API calls directly in your browser. You can call this endpoint [here](https://api.whisk.com/spec/#/ShoppingListAPI/ShoppingListAPI_AddItems).
{% endhint %}
{% endtab %}

{% tab title="Response" %}

```graphql
{
  "list": {
    "id": "106c5fa85ddbba343099347c57e54632500",
    "name": "My New Shopping List"
  },
  "content": {
    "items": [
      {
        "id": "0c76dbb5-c626-4a49-8f5e-87829fea0cbe",
        "item": {
          "name": "bacon",
          "brand": "Oscar mayer",
          "comment": "cooked, crumbled",
          "quantity": 8,
          "unit": "slices"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764646/graph/fooddb/0919f5d46996479ba5575bcdc19dc0ba.jpg",
        "analysis": {
          "product": {
            "canonical_name": "BACON"
          },
          "category": {
            "canonical_name": "MEATS AND SEAFOOD"
          },
          "brand": {
            "canonical_name": "OSCAR MAYER"
          }
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {
          "gtin": "00000034411207"
        }
      },
      {
        "id": "23c0bff5-c910-4b06-97d9-4137f8c6a657",
        "item": {
          "name": "semi-skimmed milk",
          "quantity": 750,
          "unit": "ml"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764818/graph/fooddb/48b648475f551475af2148db6c709031.jpg",
        "analysis": {
          "product": {
            "canonical_name": "SEMI SKIMMED MILK"
          },
          "category": {
            "canonical_name": "DAIRY AND EGGS"
          }
        },
        "recipe": {
          "recipe_id": "10745889d4a1c0f4b8dbfab66bffa433524",
          "position": 5
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {}
      },
      {
        "id": "26d30eb1-64a8-481e-99ad-d2914cd56c1d",
        "item": {
          "name": "onion",
          "comment": "chopped",
          "quantity": 2
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764494/graph/fooddb/d5bd477463b289845a984f7792ed6d70.jpg",
        "analysis": {
          "product": {
            "canonical_name": "ONION"
          },
          "category": {
            "canonical_name": "FRUITS AND VEGETABLES"
          }
        },
        "recipe": {
          "recipe_id": "1011f5a116db3c3e56e57bea0a52ffbfca5fc96f6b1",
          "position": 1
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {}
      },
      {
        "id": "611b542e-4d9f-4a1a-afab-be960c88a3c2",
        "item": {
          "name": "vanilla ice cream",
          "quantity": 2,
          "unit": "scoops"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1552312265/custom_upload/a4b1ba7ea9533d0079424413ee9a92e8.jpg",
        "analysis": {
          "product": {
            "canonical_name": "VANILLA ICE CREAM"
          },
          "category": {
            "canonical_name": "FROZEN"
          }
        },
        "recipe": {
          "recipe_id": "10745889d4a1c0f4b8dbfab66bffa433524",
          "position": 1
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {}
      },
      {
        "id": "729d13af-47ec-4675-ac9c-0a47b99e1c42",
        "item": {
          "name": "dessicated coconut",
          "quantity": 3,
          "unit": "tbs"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764639/graph/fooddb/f1fe2fc9e0919c4d60a8aaa808296684.jpg",
        "analysis": {
          "product": {
            "canonical_name": "DESICCATED COCONUT"
          },
          "category": {
            "canonical_name": "BAKING"
          }
        },
        "recipe": {
          "recipe_id": "10745889d4a1c0f4b8dbfab66bffa433524",
          "position": 4
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {}
      },
      {
        "id": "83c64f92-336b-40b6-9434-10f3bd9ce7f1",
        "item": {
          "name": "bananas",
          "quantity": 400,
          "unit": "g"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764678/graph/fooddb/0cc366548b4413cebaaeec7ec862b530.jpg",
        "analysis": {
          "product": {
            "canonical_name": "BANANA"
          },
          "category": {
            "canonical_name": "FRUITS AND VEGETABLES"
          }
        },
        "recipe": {
          "recipe_id": "10745889d4a1c0f4b8dbfab66bffa433524"
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {}
      },
      {
        "id": "9a32a754-4f6b-4c4a-947e-7a140c89b438",
        "item": {
          "name": "garlic cloves",
          "quantity": 2
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764463/graph/fooddb/fb90ea8fbd3e81005fc22ada2c8ddd1f.jpg",
        "analysis": {
          "product": {
            "canonical_name": "GARLIC CLOVE"
          },
          "category": {
            "canonical_name": "FRUITS AND VEGETABLES"
          }
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {
          "gtin": "00000075259567",
          "custom_product_id": "6037bd956f0187c6c0f56241"
        }
      },
      {
        "id": "faa50af4-c8dd-4ee9-8250-3eb546e940d5",
        "item": {
          "name": "vanilla essence",
          "quantity": 0.5,
          "unit": "tsp"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764596/graph/fooddb/e17ca99279ef46921f34ac8b0884134f.jpg",
        "analysis": {
          "product": {
            "canonical_name": "VANILLA ESSENCE"
          },
          "category": {
            "canonical_name": "BAKING"
          }
        },
        "recipe": {
          "recipe_id": "10745889d4a1c0f4b8dbfab66bffa433524",
          "position": 2
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {}
      },
      {
        "id": "fb496a90-f075-468b-a613-bb685db5263c",
        "item": {
          "name": "maple syrup",
          "comment": "or golden syrup or honey",
          "quantity": 1,
          "unit": "tbs"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764501/graph/fooddb/4b54ff13e2e0d22f60715e45d00ac95f.jpg",
        "analysis": {
          "product": {
            "canonical_name": "MAPLE SYRUP"
          },
          "category": {
            "canonical_name": "BREAKFAST FOODS"
          }
        },
        "recipe": {
          "recipe_id": "10745889d4a1c0f4b8dbfab66bffa433524",
          "position": 3
        },
        "created_time": "1614333362",
        "updated_at": "1614333362",
        "matching_properties": {}
      },
      {
        "id": "ec162612-e137-4b7a-823e-e9dc6651b261",
        "item": {
          "name": "onion",
          "comment": "medium, diced",
          "quantity": 1
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764494/graph/fooddb/d5bd477463b289845a984f7792ed6d70.jpg",
        "analysis": {
          "product": {
            "canonical_name": "ONION"
          },
          "category": {
            "canonical_name": "FRUITS AND VEGETABLES"
          }
        },
        "created_time": "1614618694",
        "updated_at": "1614618694",
        "matching_properties": {}
      },
      {
        "id": "fe9be106-3c5a-4cbd-b51a-37a7ef929416",
        "item": {
          "name": "fresh basil",
          "comment": "chopped",
          "unit": "handful"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764699/graph/fooddb/fb3922212f4471d2dc6c0d116318c165.jpg",
        "analysis": {
          "product": {
            "canonical_name": "BASIL"
          },
          "category": {
            "canonical_name": "FRUITS AND VEGETABLES"
          }
        },
        "created_time": "1614618694",
        "updated_at": "1614618694",
        "matching_properties": {}
      },
      {
        "id": "827bb416-6ba7-4174-b96a-d413b841e0d4",
        "item": {
          "name": "garlic cloves",
          "quantity": 2
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764463/graph/fooddb/fb90ea8fbd3e81005fc22ada2c8ddd1f.jpg",
        "analysis": {
          "product": {
            "canonical_name": "GARLIC CLOVE"
          },
          "category": {
            "canonical_name": "FRUITS AND VEGETABLES"
          }
        },
        "created_time": "1614621738",
        "updated_at": "1614621738",
        "matching_properties": {
          "gtin": "00000075259567",
          "custom_product_id": "6037bd956f0187c6c0f56241"
        }
      },
      {
        "id": "da8280f9-096f-4518-a670-e538643f1f5a",
        "item": {
          "name": "bacon",
          "brand": "Oscar mayer",
          "comment": "cooked, crumbled",
          "quantity": 8,
          "unit": "slices"
        },
        "image_url": "https://image-cdn.whisk.com/image/upload/v1550764646/graph/fooddb/0919f5d46996479ba5575bcdc19dc0ba.jpg",
        "analysis": {
          "product": {
            "canonical_name": "BACON"
          },
          "category": {
            "canonical_name": "MEATS AND SEAFOOD"
          },
          "brand": {
            "canonical_name": "OSCAR MAYER"
          }
        },
        "created_time": "1614621738",
        "updated_at": "1614621738",
        "matching_properties": {
          "gtin": "00000034411207"
        }
      }
    ],
    "recipes": [
      {
        "id": "10745889d4a1c0f4b8dbfab66bffa433524",
        "name": "Banana & coconut smoothie",
        "images": [
          {
            "responsive": {
              "url": "https://image-cdn.whisk.com/image/upload/v1611680399/recipe/957f8b170c57cfdcad1ea4c598c9ddcb.jpg",
              "width": 960,
              "height": 1280
            },
            "url": "https://image-cdn.whisk.com/image/upload/v1611680399/recipe/957f8b170c57cfdcad1ea4c598c9ddcb.jpg"
          }
        ],
        "source": {
          "license": "LICENCE_FAIRUSE"
        }
      },
      {
        "id": "1011f5a116db3c3e56e57bea0a52ffbfca5fc96f6b1",
        "name": "Bacon Cheeseburger Casserole",
        "images": [
          {
            "responsive": {
              "url": "https://image-cdn.whisk.com/image/upload/v1536910467/recipe/94f698dfcafefe3223aa66f1b3b21ae7.jpg",
              "width": 428,
              "height": 640
            },
            "url": "https://assets.kraftfoods.com/recipe_images/opendeploy/126725_MXM_K59919V0_OR1_CR_640x428.jpg"
          }
        ],
        "source": {
          "name": "myfoodandfamily.com",
          "display_name": "My Food and Family",
          "source_recipe_url": "https://www.myfoodandfamily.com/recipe/126725/bacon-cheeseburger-casserole",
          "image": {
            "responsive": {
              "url": "https://image-cdn.whisk.com/image/upload/v1565965713/publishers/logos/myfoodandfamily-logo.png",
              "width": 256,
              "height": 256
            },
            "url": "https://image-cdn.whisk.com/image/upload/v1565965713/publishers/logos/myfoodandfamily-logo.png"
          },
          "license": "LICENCE_FAIRUSE"
        }
      }
    ]
  }
}
```

{% hint style="info" %}
A successful response returns the shopping list definition with an updated list of items. To understand the data structure of a shopping list definition, see [Shopping List Object](https://docs.whisk.com/api/shopping-lists/..#shopping-list-object).
{% endhint %}
{% endtab %}
{% endtabs %}
