> For the complete documentation index, see [llms.txt](https://docs.suggestic.com/graphql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.suggestic.com/graphql/query/mutations/food-log/log-entries/food-log/add-a-food-log.md).

# Add a Food Log Entry

Add a food log entry

Use the `addFoodLog` mutation to create a new log entry for the logged-in user. It is possible to log the same food, on the same day by using a different time.

### Available Arguments

| Argument          | Required? | Type                                                                     | Description                                                                                                                                                                                                                                                                     |
| ----------------- | --------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FoodID`          | True      | String                                                                   | The `FoodID` retrieved from the [`brandedFoods`](https://docs.suggestic.com/graphql/query/search/food-search-for-food-log/branded-foods-search) or [`customFoods` ](https://docs.suggestic.com/graphql/query/search/food-search-for-food-log/common-foods-search)search queries |
| `mealTime`        | True      | [MealTime](https://docs.suggestic.com/graphql/objects/common/meal-times) | Available options are `BREAKFAST`, `SNACK`, `LUNCH` and `DINNER`                                                                                                                                                                                                                |
| `date`            | True      | Date                                                                     | Date when the food is logged. Use the format `YYYY-mm-dd`                                                                                                                                                                                                                       |
| `time`            | False     | Time                                                                     | Time when the food is logged.                                                                                                                                                                                                                                                   |
| `servings`        | False     | `Float`                                                                  | Number of servings                                                                                                                                                                                                                                                              |
| `grams`           | False     | String                                                                   | Food quantity expressed in grams                                                                                                                                                                                                                                                |
| `miligrams`       | False     | String                                                                   | Food quantity expressed in milligrams                                                                                                                                                                                                                                           |
| `portionModifier` | False     | String                                                                   | Name of the portion consumed.                                                                                                                                                                                                                                                   |

## Examples

### GrapqhQL Example using grams as portion

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

```graphql
mutation {
  addFoodLog (date:"2021-10-02", 
  foodId: "Q29tbW9uRm9vZE5vZGU6MTczNDQ0", 
  mealTime:DINNER,
  servings:2,
  grams:20)
    {
      success
      message
    }
  }
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "addFoodLog": {
      "success": true,
      "message": "Food log saved"
    }
  }
}
```

{% endtab %}
{% endtabs %}

### GrapqhQL Example using `portionModifier`

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

```graphql
mutation {
  addFoodLog (date:"2023-01-12", 
  foodId: "QnJhbmRlZEZvb2ROb2RlOjFhMDFlMzI5LTc3ZjQtNDgzYy1hNzg4LTZkOTNlYWE1MjMzMQ==", 
  mealTime:SNACK,
  servings:2,
  portionModifier: "1 PIECE")
    {
      success
      message
    }
  }
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "addFoodLog": {
      "success": true,
      "message": "Food log saved"
    }
  }
}
```

{% endtab %}
{% endtabs %}

### curl Example

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

```java
curl -XPOST 'https://production.suggestic.com/graphql' \
  -H 'Authorization: Bearer <User-JWT>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"query":"mutation { addFoodLog(foodId:\"QnJhbmRlZEZvb2ROb2RlOjQ3OTk0MQ==\", date:\"2021-10-02\", mealTime:DINNER, servings:2, grams:2) { success message } }"}'

```

{% endtab %}

{% tab title="Response" %}

```java
{
    "data": {
        "addFoodLog": {
            "success": true,
            "message": "Food log saved"
        }
    }
}
```

{% endtab %}
{% endtabs %}
