Skip to main content

Endpoint

POST /diary/meal

Authentication

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

Request Body

date
string
required
Date of the meal in YYYY-MM-DD format (e.g., “2024-03-15”)
meal
object
required
Meal data object
type
string
required
Type of meal: breakfast, lunch, dinner, or snack
time
string
required
Time of the meal in HH:MM format (e.g., “08:30”)
foods
array
required
Array of foods consumed (minimum 1 food required)
foodId
number
required
Food database ID
foodName
string
required
Name of the food
portion
string
Portion description (e.g., “1 cup”, “2 slices”)
quantity_g
number
Quantity in grams
markedAsBad
boolean
Mark this food as potentially problematic
calculatedNutrition
object
Calculated nutritional information
calories
number
Calories in kcal
carbs
number
Carbohydrates in grams
protein
number
Protein in grams
fat
number
Fat in grams
sugar
number
Sugar in grams
fiber
number
Fiber in grams
sodium
number
Sodium in milligrams
notes
string
Additional notes about the meal (max 500 characters)

Response

success
boolean
Indicates if the meal was successfully created
data
object
The created diary entry
_id
string
Entry ID (MongoDB ObjectId)
userId
string
User ID who created the entry
date
string
Entry date in YYYY-MM-DD format
type
string
Entry type (always “meal” for this endpoint)
meal
object
Complete meal data including all provided fields
createdAt
string
Timestamp when the entry was created
updatedAt
string
Timestamp when the entry was last updated

Examples

Log a breakfast meal

curl -X POST "https://api.ceboelha.com/diary/meal" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "date": "2024-03-15",
    "meal": {
      "type": "breakfast",
      "time": "08:30",
      "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
          }
        },
        {
          "foodId": 5678,
          "foodName": "Leite sem lactose",
          "portion": "200ml",
          "quantity_g": 200,
          "calculatedNutrition": {
            "calories": 90,
            "carbs": 9,
            "protein": 6,
            "fat": 3.5,
            "sugar": 9,
            "fiber": 0,
            "sodium": 100
          }
        }
      ],
      "notes": "Primeira refeição após jejum intermitente"
    }
  }'

Log a lunch with potentially problematic food

curl -X POST "https://api.ceboelha.com/diary/meal" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "date": "2024-03-15",
    "meal": {
      "type": "lunch",
      "time": "12:30",
      "foods": [
        {
          "foodId": 9012,
          "foodName": "Arroz integral",
          "portion": "1 xícara",
          "quantity_g": 150
        },
        {
          "foodId": 3456,
          "foodName": "Feijão preto",
          "portion": "1/2 xícara",
          "quantity_g": 80,
          "markedAsBad": true
        },
        {
          "foodId": 7890,
          "foodName": "Frango grelhado",
          "portion": "150g",
          "quantity_g": 150
        }
      ],
      "notes": "Feijão pode causar gases"
    }
  }'

Log a simple snack

curl -X POST "https://api.ceboelha.com/diary/meal" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "date": "2024-03-15",
    "meal": {
      "type": "snack",
      "time": "15:30",
      "foods": [
        {
          "foodId": 2468,
          "foodName": "Maçã verde",
          "portion": "1 unidade média",
          "quantity_g": 150
        }
      ]
    }
  }'
{
  "success": true,
  "data": {
    "_id": "65f1a2b3c4d5e6f7a8b9c0d1",
    "userId": "65e1a2b3c4d5e6f7a8b9c0d1",
    "date": "2024-03-15",
    "type": "meal",
    "meal": {
      "type": "breakfast",
      "time": "08:30",
      "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
          }
        },
        {
          "foodId": 5678,
          "foodName": "Leite sem lactose",
          "portion": "200ml",
          "quantity_g": 200,
          "calculatedNutrition": {
            "calories": 90,
            "carbs": 9,
            "protein": 6,
            "fat": 3.5,
            "sugar": 9,
            "fiber": 0,
            "sodium": 100
          }
        }
      ],
      "notes": "Primeira refeição após jejum intermitente"
    },
    "createdAt": "2024-03-15T08:35:22.000Z",
    "updatedAt": "2024-03-15T08:35:22.000Z"
  }
}

Meal Types

TypeDescription
breakfastMorning meal
lunchMidday meal
dinnerEvening meal
snackLight meal between main meals

Build docs developers (and LLMs) love