# Update a meal

> Changes a meal. Only what you send changes.

`PATCH /meals/:id`

Needs the **Read and write** permission.

## Path parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `id` | string | Required. The meal's id. |

## Body

Send at least one field. A field you leave out keeps its value.

| Field | Type | Description |
| --- | --- | --- |
| `state` | string | Whether the meal was eaten or is planned ahead. Send `logged` when a planned meal is eaten. One of `planned` or `logged`. |
| `eatenAt` | date-time | When it was eaten, or will be for a plan, with a UTC offset. |
| `timezone` | string | The IANA timezone it is eaten in, such as `Europe/Berlin`. Up to 100 characters. |
| `name` | string or null | The meal's name. `null` clears it. Up to 2,000 characters. |
| `notes` | string or null | The meal's notes. `null` clears them. Up to 2,000 characters. |
| `images` | array | Replaces the meal's photos. Keep a saved photo by sending it as the meal returned it. Up to 20 items. |
| `items` | object | Items to add, change or remove. |

## Items

| Field | Type | Description |
| --- | --- | --- |
| `add` | array | New items, as creating a meal takes them. Up to 100 items. |
| `change` | array | New portions for items, by id. Up to 100 items. |
| `remove` | array | Ids of items to remove. Up to 100 items. |

Items are matched by the ids the meal returned. A meal keeps at least one item and at most 100; to remove the last one, delete the meal.

## Response

`200` with the updated [meal](https://splot.health/docs/api/meals/object).

## Example

```sh
curl -X PATCH https://app.splot.health/v1/meals/6f1c2a8e-3b7d-4c5e-9a1f-2d8b7e4c9a10 \
  -H "Authorization: Bearer $SPLOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "state": "logged",
    "items": { "change": [{ "id": "0b9e4d2c-7a51-4f8e-b3c6-5d1a9e2f7c48", "quantity": 30, "unit": "g" }] }
  }'
```
