Skip to main content

Create Nutrition Plan (v1)

Method & Path

POST /api/v1/workspace/:workspaceId/nutrition/plans

Description

Creates a new nutrition plan for a client. Creating a new active plan will automatically archive any existing active plans for the same client.

Authentication

Required: Workspace token with nutrition management permission.

Headers

HeaderRequiredDescription
AuthorizationYesBearer <token>
Content-TypeYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
workspaceIdstringYesWorkspace ID

Request Body

{
"clientId": "507f1f77bcf86cd799439011",
"name": "خطة إنقاص الوزن - شهر يناير",
"startDate": "2024-01-15T00:00:00.000Z",
"endDate": "2024-02-15T00:00:00.000Z",
"dailyCalories": 1800,
"macros": {
"protein": 120,
"carbs": 180,
"fats": 60
},
"days": [
{
"dayNumber": 1,
"meals": [
{
"id": "meal-1",
"name": "الفطور",
"time": "08:00",
"calories": 400,
"items": [
{ "name": "بيض مسلوق", "quantity": "2 حبة", "calories": 140 },
{ "name": "خبز أسمر", "quantity": "شريحة", "calories": 80 },
{ "name": "جبنة قريش", "quantity": "50 جرام", "calories": 80 }
],
"alternatives": [
{ "name": "شوفان بالحليب", "quantity": "كوب", "calories": 300 }
]
}
],
"totalCalories": 1800
}
],
"notes": "تجنب الأطعمة المقلية"
}

Body Fields

FieldTypeRequiredDescription
clientIdstringYesClient ID
namestringYesPlan name
startDatestringYesISO 8601 start date
endDatestringNoISO 8601 end date
dailyCaloriesnumberNoTarget daily calories
macrosobjectNoTarget macros (protein, carbs, fats in grams)
daysarrayNoArray of daily meal plans
notesstringNoAdditional notes
templateIdstringNoID of template to use

Response 201 Created

{
"plan": {
"id": "507f1f77bcf86cd799439013",
"workspaceId": "507f1f77bcf86cd799439012",
"clientId": "507f1f77bcf86cd799439011",
"name": "خطة إنقاص الوزن - شهر يناير",
"startDate": "2024-01-15T00:00:00.000Z",
"endDate": "2024-02-15T00:00:00.000Z",
"status": "active",
"dailyCalories": 1800,
"macros": {
"protein": 120,
"carbs": 180,
"fats": 60
},
"days": [...],
"notes": "تجنب الأطعمة المقلية",
"templateId": null,
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}
}

Common Errors

  • 400 Bad Request: Invalid input data
  • 401 Unauthorized: Missing or invalid token
  • 404 Not Found: Workspace or client not found