EndpointsFitness Workout Plans

Fitness Workout Plans

Function-calling namespace: fitnessWorkoutPlans

  • Base URL: https://api.aivida.in
  • Engine endpoint: POST /api
  • Auth: Stack token middleware enabled in optional mode.
  • Send token in header: x-stack-access-token: <access_token> (or Authorization: Bearer <access_token>).
  • In optional mode: no token is allowed; invalid token is rejected with 401.

cancel

Source: backend/endpoints/fitness-workout-plans/cancel

Input Fields

FieldTypeRequiredConstraints
organizationIdstringYes-
assignmentIdstringYes-
reasonstringNo-
actorStackUserIdstringNo-

Example Request

curl -X POST https://api.aivida.in/api \
  -H "Content-Type: application/json" \
  -H "x-stack-access-token: <access_token_optional>" \
  -d '{
  "namespace": "fitnessWorkoutPlans",
  "apiName": "cancel",
  "data": {
    "organizationId": "org_123",
    "assignmentId": "assignment_123"
  }
}'

Example Response

{ "status": "ok", "data": {} }

createDateRangePlan

Source: backend/endpoints/fitness-workout-plans/create-date-range-plan

Input Fields

FieldTypeRequiredConstraints
organizationIdstringYes-
memberIdstringYes-
titlestringYes-
descriptionstringNo-
startDatestringYesformat: YYYY-MM-DD
endDatestringYesformat: YYYY-MM-DD
workoutDaysarray<object>Yesmin: 1; dive
actorStackUserIdstringNo-

workoutDays Shape

Each item in workoutDays creates exactly one daily task in fitness_workout_tasks for that date.

FieldTypeRequired
datestring (YYYY-MM-DD)Yes
dayLabelstringNo
exercises[]WorkoutExerciseInputYes

WorkoutExerciseInput

FieldTypeRequired
exerciseIdstringYes
targetSetsintNo
targetRepsintNo
targetDurationSecint (>=1)Yes
plannedRestSecintNo
sortOrderintNo

Validation Rules

  • startDate, endDate, and each workoutDays[].date must be in YYYY-MM-DD format.
  • startDate cannot be after endDate.
  • Each workoutDays[].date must be within startDate..endDate.
  • Duplicate workoutDays[].date values are rejected.
  • Each day must include at least one exercise.
  • exerciseId must exist in the exercises table.

Example Request

curl -X POST https://api.aivida.in/api \
  -H "Content-Type: application/json" \
  -H "x-stack-access-token: <access_token_optional>" \
  -d '{
  "namespace": "fitnessWorkoutPlans",
  "apiName": "createDateRangePlan",
  "data": {
    "organizationId": "org_123",
    "memberId": "member_123",
    "title": "Week 1 Foundation Plan",
    "description": "Starter block for lower body + push work",
    "startDate": "2026-03-10",
    "endDate": "2026-03-12",
    "workoutDays": [
      {
        "date": "2026-03-10",
        "dayLabel": "Day 1",
        "exercises": [
          {
            "exerciseId": "ex_squats",
            "targetSets": 4,
            "targetReps": 10,
            "targetDurationSec": 45,
            "plannedRestSec": 20,
            "sortOrder": 1
          },
          {
            "exerciseId": "ex_wall_pushups",
            "targetSets": 3,
            "targetReps": 12,
            "targetDurationSec": 40,
            "plannedRestSec": 30,
            "sortOrder": 2
          }
        ]
      },
      {
        "date": "2026-03-12",
        "dayLabel": "Day 2",
        "exercises": [
          {
            "exerciseId": "ex_backward_lunge",
            "targetSets": 3,
            "targetReps": 12,
            "targetDurationSec": 50,
            "plannedRestSec": 25,
            "sortOrder": 1
          }
        ]
      }
    ]
  }
}'

Example Response

{ "status": "ok", "data": {} }

getById

Source: backend/endpoints/fitness-workout-plans/get-by-id

Input Fields

FieldTypeRequiredConstraints
organizationIdstringYes-
assignmentIdstringYes-
actorStackUserIdstringNo-

Example Request

curl -X POST https://api.aivida.in/api \
  -H "Content-Type: application/json" \
  -H "x-stack-access-token: <access_token_optional>" \
  -d '{
  "namespace": "fitnessWorkoutPlans",
  "apiName": "getById",
  "data": {
    "organizationId": "org_123",
    "assignmentId": "assignment_123"
  }
}'

Example Response

{ "status": "ok", "data": {} }

listByOrganization

Source: backend/endpoints/fitness-workout-plans/list-by-organization

Input Fields

FieldTypeRequiredConstraints
organizationIdstringYes-
memberIdstringNo-
statusstringNo-
fromDatestringNoformat: YYYY-MM-DD
toDatestringNoformat: YYYY-MM-DD
pageintegerNo-
pageSizeintegerNo-
actorStackUserIdstringNo-

Example Request

curl -X POST https://api.aivida.in/api \
  -H "Content-Type: application/json" \
  -H "x-stack-access-token: <access_token_optional>" \
  -d '{
  "namespace": "fitnessWorkoutPlans",
  "apiName": "listByOrganization",
  "data": {
    "organizationId": "org_123"
  }
}'

Example Response

{ "status": "ok", "data": {} }

updateDateRangePlan

Source: backend/endpoints/fitness-workout-plans/update-date-range-plan

Input Fields

FieldTypeRequiredConstraints
organizationIdstringYes-
assignmentIdstringYes-
titlestringNonullable
descriptionstringNonullable
endDatestringNoformat: YYYY-MM-DD; nullable
workoutDaysarray<object>Nomin: 1; dive; nullable
actorStackUserIdstringNo-

When workoutDays is provided in update:

  • the same shape/validation rules as createDateRangePlan are applied.
  • days included in payload are created/updated by date.
  • days not included are not auto-created.
  • non-pending existing task days cannot be replaced.

Example Request

curl -X POST https://api.aivida.in/api \
  -H "Content-Type: application/json" \
  -H "x-stack-access-token: <access_token_optional>" \
  -d '{
  "namespace": "fitnessWorkoutPlans",
  "apiName": "updateDateRangePlan",
  "data": {
    "organizationId": "org_123",
    "assignmentId": "assignment_123",
    "endDate": "2026-03-15",
    "workoutDays": [
      {
        "date": "2026-03-13",
        "dayLabel": "Day 3",
        "exercises": [
          {
            "exerciseId": "ex_jumping_jacks",
            "targetSets": 3,
            "targetReps": 20,
            "targetDurationSec": 60,
            "plannedRestSec": 20,
            "sortOrder": 1
          }
        ]
      }
    ]
  }
}'

Example Response

{ "status": "ok", "data": {} }