---
search:
  tags:
    - Foods
    - PUT
seo:
  description: >-
    Edits one of the account's own foods. If the food is already used in a meal
    plan, recipe… Reference for the PUT /foods/{food_id} endpoint in the
    Almendra API.
sidebar:
  label: Edit a custom food
  badge: PUT
title: Edit a custom food
type: openapi-operation
---
Edits one of the account's own foods. If the food is already used in a meal plan, recipe or exchange group and its nutrition or measures change, the answer is a copy with a new `_id` that replaces it from now on, and existing plans keep the old values.

Requires the `library:write` permission.

`PUT /foods/{food_id}`

**Request body** (`application/json`)

- `name` (string)
- `category` (string)
- `caloriesKcal` (number)
- `proteinG` (number)
- `carbsG` (number)
- `fatG` (number)
- `nutrients` (object) — Other nutrients, per 100 g, with the names \`GET /foods/{food\_id}\` returns (\`fiber\_g\`, \`sodium\_mg\`, \`vitaminC\_mg\`, …). Unknown names answer 400.
- `measures` (FoodMeasureInput[]) — Household measures (e.g. 1 slice = 30 g). Grams are always available.

Request body example:

```json
{
  "name": "Pan integral de la panadería",
  "category": "string",
  "caloriesKcal": 247,
  "proteinG": 13,
  "carbsG": 41,
  "fatG": 3.4,
  "nutrients": {
    "fiber_g": 7,
    "sodium_mg": 400
  },
  "measures": [
    {
      "amount": 1,
      "description": "taza",
      "grams": 240
    }
  ]
}
```

**Responses**

- `200` — Food edited
- `400` — Invalid path parameter, query parameter or request body
- `401` — Missing or invalid API key
- `403` — The account behind the API key has no active paid plan, or the key lacks the permission this operation needs
- `404` — Not one of the account's own foods
- `415` — Request body sent without \`Content-Type: application/json\`
- `429` — Rate limit exceeded (600 requests per 60 seconds); retry after \`Retry-After\` seconds
- `500` — Unexpected server error

Response example, 200:

```json
{
  "_id": "string",
  "name": "Pechuga de pollo, cocida",
  "type": "food",
  "source": "CENAN (2017)",
  "category": "string",
  "createdByThisAccount": true,
  "caloriesKcal": 165,
  "proteinG": 31,
  "carbsG": 0,
  "fatG": 3.6,
  "nutrients": {
    "fiber_g": 0,
    "sodium_mg": 74,
    "iron_mg": 1
  },
  "measures": [
    {
      "amount": 1,
      "description": "taza",
      "grams": 240
    }
  ]
}
```
