# Add Items To A Shopping List

| POST | /v1/:id/items |
| ---- | ------------- |

## Parameters

| ATTRIBUTE | TYPE                               | DESCRIPTION                                                                                                                |
| --------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| name      | string                             | Shopping List name                                                                                                         |
| language  | string                             | Language can be provided explicitly which will impact analysis on shopping list items. Default: en                         |
| recipes   | array \[ShoppingListRecipePayload] | references to recipes to add to a shopping list                                                                            |
| rawItems  | array \[string]                    | Ids of recipes. The cart will be generated based on recipe ingredients. The id can be represented by GraphID or recipe URL |
| items     | array \[ShoppingListItemPayload]   | list of normalised items to add                                                                                            |

### ShoppingListRecipePayload

| ATTRIBUTE | TYPE   | DESCRIPTION                                          |
| --------- | ------ | ---------------------------------------------------- |
| id\*      | string | GraphId or URL of a Recipe                           |
| scale     | float  | Multiplier for default amounts in recipe: 0.5, 2 ... |

### ShoppingListItemPayload

| ATTRIBUTE | TYPE   | DESCRIPTION               |
| --------- | ------ | ------------------------- |
| quantity  | double | Item quantity             |
| unit      | string | Item unit (e.g. gram, ml) |
| name\*    | string | Item name (e.g. potato)   |
| comment   | string |                           |

## Response

| ATTRIBUTE     | TYPE                             | DESCRIPTION                             |
| ------------- | -------------------------------- | --------------------------------------- |
| id\*          | string                           |                                         |
| name\*        | string                           |                                         |
| primary       | boolean                          |                                         |
| createdTime\* | datetime                         | The time the Shopping List was created. |
| updatedTime\* | datetime                         |                                         |
| items         | array \[ShoppingListItemElement] |                                         |

## ShoppingListItemElement

| ATTRIBUTE      | TYPE           | DESCRIPTION               |
| -------------- | -------------- | ------------------------- |
| quantity       | double         | Item quantity             |
| unit           | string         | Item unit (e.g. gram, ml) |
| name\*         | string         | Item name (e.g. potato)   |
| comment        | string         |                           |
| brand          | string         |                           |
| analysis       | SLItemAnalysis |                           |
| recipe         | string         |                           |
| recipeOrdering | integer        |                           |
| createdTime    | datetime       |                           |
| combined       | array          |                           |

### Request

```bash
curl -X POST "https://graph.whisk.com/v1/0415a504f28c4e2c9535a1f56f98b41c/items" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <User-Access-Token>" \
  -d '{
    "items": [
      {
        "quantity": 200,
        "unit": "g",
        "name": "smoked salmon"
      },
      {
        "quantity": 2,
        "unit": "slices",
        "name": "cheddar cheese",
        "comment": "extra mature"
      }
    ]
  }'
```

### Sample Response

```javascript
{
  "id": "ef610b5c0e294ef6a54931738d79f55d",
  "name": "My Shopping List",
  "primary": true,
  "createdTime": "2017-12-07T20:06:14+0000",
  "updatedTime": "2017-12-07T20:06:14+0000",
  "items": [
    {
      "id": "c484682c-66b7-4fa9-82b6-9ef34dec9fc7",
      "quantity": 200,
      "unit": "g",
      "name": "smoked salmon",
      "analysis": {
        "canonicalName": "SMOKED SALMON",
        "category": {
          "name": "MEATS AND SEAFOOD"
        }
      },
      "recipe": "9773cb7eca5d11e7ae7e42010a9a0035",
      "recipeOrdering": 0
    },
    {
      "id": "bb47bf7b-060d-49f0-9091-bada6b695019",
      "quantity": 4,
      "name": "eggs",
      "comment": "large",
      "analysis": {
        "canonicalName": "EGG",
        "category": {
          "name": "DAIRY AND EGGS"
        }
      },
      "recipe": "9773cb7eca5d11e7ae7e42010a9a0035",
      "recipeOrdering": 1
    }
  ],
  "recipes": [
    {
      "id": "9773cb7eca5d11e7ae7e42010a9a0035",
      "name": "Omelette pancakes with tomato & pepper sauce",
      "url": "https://www.bbcgoodfood.com/recipes/omelette-pancakes-tomato-pepper-sauce"
    }
  ]
}
```
