Skip to main content

Endpoint

PATCH /diary/:id

Authentication

This endpoint requires authentication via Bearer token.
Authorization: Bearer <token>

Path Parameters

id
string
required
Entry ID (MongoDB ObjectId - 24 hexadecimal characters)

Request Body

You can update either meal or symptom data. All fields are optional - only provide the fields you want to update.
meal
object
Meal data to update (for meal entries only)
type
string
Type of meal: breakfast, lunch, dinner, or snack
time
string
Time of the meal in HH:MM format
foods
array
Complete array of foods (replaces existing foods, minimum 1 required)
notes
string
Additional notes about the meal (max 500 characters)
symptom
object
Symptom data to update (for symptom entries only)
type
string
Type of symptom
intensity
number
Intensity level from 1 to 5
time
string
Time in HH:MM format
duration
number
Duration in minutes
notes
string
Additional notes (max 500 characters)

Response

success
boolean
Indicates if the update was successful
data
object
The updated diary entry with all fields

Examples

Update meal time and notes

curl -X PATCH "https://api.ceboelha.com/diary/65f1a2b3c4d5e6f7a8b9c0d1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "meal": {
      "time": "09:00",
      "notes": "Ajustado o horário correto da refeição"
    }
  }'

Update entire meal foods list

curl -X PATCH "https://api.ceboelha.com/diary/65f1a2b3c4d5e6f7a8b9c0d1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "meal": {
      "foods": [
        {
          "foodId": 1234,
          "foodName": "Aveia",
          "portion": "1 xícara",
          "quantity_g": 80
        },
        {
          "foodId": 5678,
          "foodName": "Banana",
          "portion": "1 média",
          "quantity_g": 120,
          "markedAsBad": true
        },
        {
          "foodId": 9012,
          "foodName": "Mel",
          "portion": "1 colher de sopa",
          "quantity_g": 20
        }
      ]
    }
  }'

Update symptom intensity and add duration

curl -X PATCH "https://api.ceboelha.com/diary/65f1a2b3c4d5e6f7a8b9c0d2" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "symptom": {
      "intensity": 4,
      "duration": 60,
      "notes": "O sintoma piorou e durou mais tempo que o esperado"
    }
  }'

Change symptom type

curl -X PATCH "https://api.ceboelha.com/diary/65f1a2b3c4d5e6f7a8b9c0d2" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "symptom": {
      "type": "cramps",
      "notes": "Percebi que era mais cólica do que inchaço"
    }
  }'

Update meal type from snack to breakfast

curl -X PATCH "https://api.ceboelha.com/diary/65f1a2b3c4d5e6f7a8b9c0d1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "meal": {
      "type": "breakfast"
    }
  }'
{
  "success": true,
  "data": {
    "_id": "65f1a2b3c4d5e6f7a8b9c0d1",
    "userId": "65e1a2b3c4d5e6f7a8b9c0d1",
    "date": "2024-03-15",
    "type": "meal",
    "meal": {
      "type": "breakfast",
      "time": "09:00",
      "foods": [
        {
          "foodId": 1234,
          "foodName": "Aveia",
          "portion": "1 xícara",
          "quantity_g": 80,
          "calculatedNutrition": {
            "calories": 303,
            "carbs": 54.8,
            "protein": 10.7,
            "fat": 5.3,
            "sugar": 0.8,
            "fiber": 8.2,
            "sodium": 2
          }
        }
      ],
      "notes": "Ajustado o horário correto da refeição"
    },
    "createdAt": "2024-03-15T08:35:22.000Z",
    "updatedAt": "2024-03-15T09:05:15.000Z"
  }
}

Error Responses

Entry not found

{
  "success": false,
  "error": "Entry not found"
}

Unauthorized (not the entry owner)

{
  "success": false,
  "error": "Forbidden"
}

Invalid entry ID format

{
  "success": false,
  "error": "Invalid entry ID format"
}

Notes

  • You can only update entries that belong to your user account
  • When updating the foods array in a meal, you must provide the complete array (it replaces the existing foods)
  • All other fields are merged with existing data
  • The entry’s date and type cannot be changed - create a new entry if you need to change these
  • The updatedAt timestamp is automatically updated

Build docs developers (and LLMs) love