{"openapi":"3.0.3","info":{"title":"IronPulse Gym, Nutrition & Hydration API","version":"1.0.0","description":"REST API for AI agents (Claude, ChatGPT, LangChain, n8n) and external systems to monitor and control weekly workouts, set logs, macros, and water tracking.","contact":{"name":"IronPulse Fitness Support"}},"servers":[{"url":"/api/v1","description":"Current Host API Endpoint"}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Your personal IronPulse API Key (format: sk_iron_...)"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT or API Key"}}},"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"paths":{"/ai/context":{"get":{"summary":"Get Full User Context for AI","description":"Returns today's scheduled workout, current PRs, daily macro goals and consumption, and hydration status formatted for LLM prompts.","responses":{"200":{"description":"Full user context JSON"}}}},"/ai/action":{"post":{"summary":"Execute AI Action","description":"Enables external AI agents or webhooks to perform actions like logging a set, adding a meal, logging water, or updating workout routines.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["log_workout_set","log_meal","log_water","set_nutrition_goals","set_water_target","update_profile"]},"params":{"type":"object"},"source":{"type":"string","default":"external_ai"}},"required":["action","params"]}}}},"responses":{"200":{"description":"Action executed successfully"}}}},"/workouts/today":{"get":{"summary":"Get Today's Workout","description":"Returns the day's scheduled focus, exercises, previous weights, and today's completed sets.","responses":{"200":{"description":"Today's workout details"}}}},"/workouts/weekly":{"get":{"summary":"Get Weekly Routine (7 Days)","description":"Returns the full 7-day schedule (Saturday to Friday) with all exercises.","responses":{"200":{"description":"Weekly workout split"}}}},"/workouts/log-set":{"post":{"summary":"Log a Workout Set","description":"Records weight, reps, and RPE for an exercise set. Automatically detects Personal Records (PRs) and calculates 1RM.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["exercise_name","weight","reps"],"properties":{"exercise_name":{"type":"string","example":"پرس سینه با هالتر"},"muscle_group":{"type":"string","example":"chest"},"set_number":{"type":"integer","example":1},"weight":{"type":"number","example":90},"reps":{"type":"integer","example":8},"rpe":{"type":"number","example":8.5},"notes":{"type":"string","example":"فرم عالی و انقباض تمیز"}}}}}},"responses":{"201":{"description":"Set logged with PR detection"}}}},"/nutrition/today":{"get":{"summary":"Get Today's Nutrition & Macros","description":"Returns consumed vs target calories, protein, carbs, fat, and categorized meals.","responses":{"200":{"description":"Today's nutrition summary"}}}},"/nutrition/log":{"post":{"summary":"Log a Meal","description":"Records a food item with calories and macronutrients.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["meal_type","food_name","calories"],"properties":{"meal_type":{"type":"string","enum":["breakfast","lunch","dinner","snack","pre_workout","post_workout"]},"food_name":{"type":"string","example":"سینه مرغ گریل با برنج کته"},"calories":{"type":"integer","example":650},"protein":{"type":"number","example":52},"carbs":{"type":"number","example":75},"fat":{"type":"number","example":10},"portion":{"type":"string","example":"۲۰۰ گرم فیله + ۱ پیمانه برنج"}}}}}},"responses":{"201":{"description":"Meal logged"}}}},"/water/today":{"get":{"summary":"Get Today's Water Intake","description":"Returns total ml consumed, target ml, percentage, and log timestamps.","responses":{"200":{"description":"Water hydration status"}}}},"/water/log":{"post":{"summary":"Log Water Intake","description":"Adds water volume (in ml) to today's hydration total.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["amount_ml"],"properties":{"amount_ml":{"type":"integer","example":350}}}}}},"responses":{"201":{"description":"Water logged"}}}}}}