> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fitsociety.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Reorder the days inside one week of a multi-week plan

> Reorder the DAYS INSIDE ONE WEEK of a multi-week calendar plan, leaving every other week untouched. Each weekday's CONTENT (its `isRestDay` flag and its `items[]`) moves to a new weekday slot within the same week.

`weekdays[i]` is the weekday whose content moves to weekday `i + 1`. So `[7, 1, 2, 3, 4, 5, 6]` rotates the week — what sat on Sunday moves to Monday and everything else shifts one day later. All seven weekdays must be listed exactly once, which keeps the request idempotent and lets one call express any rearrangement.

Stored `days[]` is SPARSE (a week holds an entry only for the weekdays that have been authored), so the permutation is applied as an old→new weekday remap over whatever is stored: slots with no stored day contribute nothing and no empty days are invented. The response therefore returns only the weekdays this week actually stores, in their new order.

Requires `schedule.mode === "multi_week"`. This is the calendar-placement counterpart to `PATCH /template/{planId}/days/reorder`, which permutes the plan moments' own `dayOrder`/`sessionOrder`; the two are independent.

Requires the workout_plans:write scope. This operation maps to /app/v1/workout/plans/template/:planId/weeks/:weekNumber/days/reorder and retains its Workout V2 permission, feature-flag, and resource-scope checks.

The clientId path parameter is resolved inside the company bound to the Public API token when present.



## OpenAPI

````yaml /openapi/public-v1.json patch /public/v1/workout/plans/template/{planId}/weeks/{weekNumber}/days/reorder
openapi: 3.1.0
info:
  title: FITsociety Public API v1
  version: 1.0.0
  description: >-
    Developer Public API endpoints under `/public/v1`. This reference is
    filtered to OAuth/Bearer Public API resources and excludes provider callback
    receivers, storefront routes, public widgets, wishlist routes, and
    access-device validation endpoints.
  contact:
    name: FITsociety Engineering
servers:
  - url: https://api.fitsociety.io
    description: Production
security: []
tags:
  - name: Workout
    description: >-
      Workout V2 libraries, programmes, client plans, calendars, sessions,
      groups, settings and progress. AI operations are excluded.
  - name: OAuth
    description: Public API OAuth endpoints for server-to-server client credentials.
  - name: Health
    description: Public API token health checks.
  - name: Platform
    description: >-
      Inspect Public API client context, capabilities, scopes, and redacted
      audit logs.
  - name: Company Catalog
    description: Read and manage company profile metadata and locations.
  - name: Clients
    description: >-
      Create and manage clients through the Public API using Bearer access
      tokens.
  - name: Coaches
    description: Retrieve coaches for the authenticated company via integrations.
  - name: Calendar Events
    description: Read Public API calendar events.
  - name: Calendar Templates
    description: >-
      Read and manage event types and event templates used by calendar
      availability and bookings.
  - name: Calendar Extensions
    description: >-
      Read recurring bookings, booking requests, calendar tasks, and
      availability closure metadata.
  - name: Availability
    description: Read bookable availability slots and signed availability tokens.
  - name: Availability Management
    description: >-
      Manage coach and location availability templates used to derive bookable
      slots.
  - name: Bookings
    description: Read and manage Public API bookings.
  - name: Finance
    description: >-
      Read invoices, transactions, products, subscriptions, and memberships with
      guarded finance writes.
  - name: Credits
    description: >-
      Read company-wide and client-scoped credit allocations, mutations, and
      guarded credit adjustments.
  - name: Exports
    description: >-
      Create and monitor asynchronous company exports through Public API Bearer
      endpoints.
  - name: Webhooks
    description: >-
      Manage outbound webhook subscriptions and inspect delivery attempts
      through Public API Bearer endpoints.
  - name: Measurements
    description: Read and write client measurement entries.
  - name: Progress Photos
    description: Read client progress photo metadata and short-lived signed media URLs.
  - name: Forms
    description: Read, create, update, and archive company form templates.
  - name: Intakes
    description: Assign intake forms and read client intake assignments and submissions.
  - name: Check-ups
    description: >-
      Schedule and cancel client check-ups and read their status and
      submissions.
  - name: Documents
    description: >-
      Read client document and folder metadata, register external document
      links, update metadata, and archive documents from Public API listings.
      Binary upload, permanent deletion, and company-wide document management
      are not exposed.
  - name: Habits
    description: Read habits and habit entries.
  - name: Goals
    description: Read client goal summaries.
  - name: Conversations
    description: >-
      Read and manage direct and group chat conversations through the Public
      API.
  - name: Reports
    description: Read aggregate attendance, revenue, and retention summaries.
paths:
  /public/v1/workout/plans/template/{planId}/weeks/{weekNumber}/days/reorder:
    patch:
      tags:
        - Workout
      summary: Reorder the days inside one week of a multi-week plan
      description: >-
        Reorder the DAYS INSIDE ONE WEEK of a multi-week calendar plan, leaving
        every other week untouched. Each weekday's CONTENT (its `isRestDay` flag
        and its `items[]`) moves to a new weekday slot within the same week.


        `weekdays[i]` is the weekday whose content moves to weekday `i + 1`. So
        `[7, 1, 2, 3, 4, 5, 6]` rotates the week — what sat on Sunday moves to
        Monday and everything else shifts one day later. All seven weekdays must
        be listed exactly once, which keeps the request idempotent and lets one
        call express any rearrangement.


        Stored `days[]` is SPARSE (a week holds an entry only for the weekdays
        that have been authored), so the permutation is applied as an old→new
        weekday remap over whatever is stored: slots with no stored day
        contribute nothing and no empty days are invented. The response
        therefore returns only the weekdays this week actually stores, in their
        new order.


        Requires `schedule.mode === "multi_week"`. This is the
        calendar-placement counterpart to `PATCH
        /template/{planId}/days/reorder`, which permutes the plan moments' own
        `dayOrder`/`sessionOrder`; the two are independent.


        Requires the workout_plans:write scope. This operation maps to
        /app/v1/workout/plans/template/:planId/weeks/:weekNumber/days/reorder
        and retains its Workout V2 permission, feature-flag, and resource-scope
        checks.


        The clientId path parameter is resolved inside the company bound to the
        Public API token when present.
      operationId: >-
        publicWorkoutpatchPublicV1WorkoutPlansTemplatePlanIdWeeksWeekNumberDaysReorder
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 200
            example: booking-create-20260714-001
          description: >-
            Required for Public API write requests. Reusing the same key with
            the same method, path, and body replays the stored successful
            response; reusing it with a different request returns `409
            idempotency.conflict`.
        - in: path
          name: planId
          required: true
          description: Workout plan id (Template or Assigned).
          schema:
            type: string
            example: 67f1234567890abcdef1234
        - name: weekNumber
          in: path
          required: true
          schema:
            type: integer
            minimum: 1
            example: 1
          description: The 1-based week of the multi-week schedule to reorder.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/PublicWorkoutSourcePATCHAppV1WorkoutPlansTemplatePlanIdWeeksWeekNumberDaysReorderRequest
      responses:
        '200':
          description: Week days reordered.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/PublicApiWriteSuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: >-
                          #/components/schemas/PublicWorkoutSourcePATCHAppV1WorkoutPlansTemplatePlanIdWeeksWeekNumberDaysReorderResponse200
              examples:
                success:
                  summary: Successful response
                  value:
                    data:
                      planId: 67f1234567890abcdef1234
                      templateType: Template
                      weekNumber: 1
                      weekdays:
                        - 7
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                        - 6
                      days:
                        - weekday: 2
                          isRestDay: false
                          items:
                            - _id: 67f1234567890abcdef1234
                              type: workout
                              order: 1
                              startTime: ''
                              plannedDurationMinutes: 23
                              planMomentId: 67f1234567890abcdef1234
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
                      idempotency:
                        replayed: false
        '400':
          description: >-
            Validation error. Keys: `INVALID_PLAN_ID`, `INVALID_WEEK_NUMBER`,
            `WORKOUTPLAN_WEEKDAY_ORDER_INVALID` (not a permutation of 1..7),
            `WORKOUTPLAN_SCHEDULE_NOT_MULTI_WEEK`,
            `WORKOUTPLAN_CALENDAR_SCHEDULE_INVALID`, or a model validation
            message.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
              examples:
                invalidRequest:
                  summary: Invalid request
                  value:
                    error:
                      code: 400
                      key: request.invalid
                      message: The request is invalid.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
                idempotencyRequired:
                  summary: Missing Idempotency-Key
                  value:
                    error:
                      code: 400
                      key: idempotency.required
                      message: >-
                        Idempotency-Key header is required for Public API write
                        requests.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
                idempotencyInvalid:
                  summary: Invalid Idempotency-Key
                  value:
                    error:
                      code: 400
                      key: idempotency.invalid
                      message: Idempotency-Key header must be 200 characters or fewer.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
        '401':
          $ref: '#/components/schemas/ErrorResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
              examples:
                missingBearer:
                  summary: Missing Bearer token
                  value:
                    error:
                      code: 401
                      key: auth.missing_bearer
                      message: Authorization Bearer token is required.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
                invalidToken:
                  summary: Invalid or expired token
                  value:
                    error:
                      code: 401
                      key: auth.invalid_token
                      message: The access token is invalid or expired.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
                invalidClient:
                  summary: Inactive or revoked client
                  value:
                    error:
                      code: 401
                      key: auth.invalid_client
                      message: The Public API client is inactive or revoked.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
        '403':
          description: Caller is not authorized to update this plan.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
              examples:
                insufficientScopes:
                  summary: Missing required scope
                  value:
                    error:
                      code: 403
                      key: scopes.insufficient
                      message: The access token does not include the required scope.
                      details:
                        requiredScopes:
                          - required:scope
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
        '404':
          description: >-
            Plan (`WORKOUTPLAN_NOT_FOUND`) or week
            (`WORKOUTPLAN_WEEK_NOT_FOUND`) not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
              examples:
                notFound:
                  summary: Resource not found
                  value:
                    error:
                      code: 404
                      key: resource.not_found
                      message: The requested Public API resource was not found.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
        '409':
          $ref: '#/components/schemas/ErrorResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
              examples:
                idempotencyConflict:
                  summary: Idempotency-Key conflict
                  value:
                    error:
                      code: 409
                      key: idempotency.conflict
                      message: >-
                        Idempotency-Key was already used with a different
                        request.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
                idempotencyInProgress:
                  summary: Idempotency-Key in progress
                  value:
                    error:
                      code: 409
                      key: idempotency.in_progress
                      message: >-
                        Idempotency-Key is already processing for this Public
                        API client.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
        '422':
          $ref: '#/components/schemas/ErrorResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
              examples:
                emptyBody:
                  summary: Empty or invalid JSON object body
                  value:
                    error:
                      code: 422
                      key: EMPTY_BODY
                      message: Request body must be a non-empty JSON object.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
        '429':
          $ref: '#/components/schemas/ErrorResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
              examples:
                rateLimitExceeded:
                  summary: Rate limit exceeded
                  value:
                    error:
                      code: 429
                      key: rate_limit.exceeded
                      message: Too many Public API requests. Retry later.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 0
                        resetSeconds: 1
                        retryAfterSeconds: 1
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiError'
              examples:
                serverInternalError:
                  summary: Unexpected server error
                  value:
                    error:
                      code: 500
                      key: server.internal_error
                      message: An unexpected Public API server error occurred.
                    meta:
                      requestId: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
                      rateLimit:
                        limit: 10
                        remaining: 9
                        resetSeconds: 1
      security:
        - PublicBearerAuth: []
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: >-
            curl -X PATCH
            "https://api.fitsociety.io/public/v1/workout/plans/template/{planId}/weeks/{weekNumber}/days/reorder"
            \
              -H "Authorization: Bearer <access_token>" \
              -H "Idempotency-Key: <stable_request_key>" \
              -H "Content-Type: application/json" \
              -d '{}'
components:
  schemas:
    PublicWorkoutSourcePATCHAppV1WorkoutPlansTemplatePlanIdWeeksWeekNumberDaysReorderRequest:
      type: object
      required:
        - weekdays
      properties:
        weekdays:
          type: array
          minItems: 7
          maxItems: 7
          description: >-
            A permutation of 1..7 — the week's weekday slots in their new order.
            `weekdays[i]` moves to weekday `i + 1`.
          items:
            type: integer
            minimum: 1
            maximum: 7
          example:
            - 7
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
    PublicApiWriteSuccessResponse:
      type: object
      additionalProperties: false
      required:
        - data
        - meta
      properties:
        data:
          type: object
        meta:
          $ref: '#/components/schemas/PublicApiWriteMeta'
    PublicWorkoutSourcePATCHAppV1WorkoutPlansTemplatePlanIdWeeksWeekNumberDaysReorderResponse200:
      type: object
      properties:
        planId:
          type: string
          example: 67f1234567890abcdef1234
        templateType:
          type: string
          example: Template
        weekNumber:
          type: integer
          example: 1
        weekdays:
          type: array
          description: The remap that was applied, echoed back.
          items:
            type: integer
          example:
            - 7
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
        days:
          type: array
          description: The week's stored days after the remap, ordered by weekday.
          items:
            type: object
            properties:
              weekday:
                type: integer
                example: 2
              isRestDay:
                type: boolean
                example: false
              items:
                type: array
                items:
                  type: object
                  properties:
                    _id:
                      type: string
                      example: 67f1234567890abcdef1234
                    type:
                      type: string
                      enum:
                        - workout
                        - activity
                      example: workout
                    order:
                      type: integer
                      example: 1
                    startTime:
                      type: string
                      example: ''
                    plannedDurationMinutes:
                      type: integer
                      nullable: true
                      example: 23
                    planMomentId:
                      type: string
                      example: 67f1234567890abcdef1234
    PublicApiError:
      type: object
      additionalProperties: false
      required:
        - error
        - meta
      properties:
        error:
          type: object
          additionalProperties: false
          required:
            - code
            - key
            - message
          properties:
            code:
              type: integer
              example: 401
            key:
              type: string
              example: auth.invalid_token
            message:
              type: string
              example: The access token is invalid.
            details:
              type: object
              additionalProperties: true
        meta:
          $ref: '#/components/schemas/PublicApiMeta'
    ErrorResponse:
      allOf:
        - $ref: '#/components/schemas/StandardResponse'
        - example:
            status: 401
            error: true
            message: MISSING_AUTH
    PublicApiWriteMeta:
      type: object
      additionalProperties: false
      required:
        - requestId
      properties:
        requestId:
          type: string
          description: Stable request correlation id. Mirrors `X-Request-Id` when supplied.
          example: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
        rateLimit:
          $ref: '#/components/schemas/PublicApiRateLimitMeta'
        idempotency:
          type: object
          additionalProperties: false
          properties:
            replayed:
              type: boolean
              description: >-
                True when the response was replayed from a previous request with
                the same `Idempotency-Key`.
              example: true
    PublicApiMeta:
      type: object
      additionalProperties: false
      required:
        - requestId
      properties:
        requestId:
          type: string
          description: Stable request correlation id. Mirrors `X-Request-Id` when supplied.
          example: 4f849d7d-f4f1-45cc-b4b7-3984a3d17f83
        rateLimit:
          $ref: '#/components/schemas/PublicApiRateLimitMeta'
    StandardResponse:
      type: object
      properties:
        status:
          type: integer
          example: 200
        error:
          type: boolean
          example: false
        message:
          type: string
          example: SUCCESS
      required:
        - status
        - error
        - message
    PublicApiRateLimitMeta:
      type: object
      additionalProperties: false
      properties:
        limit:
          type: integer
          example: 10
        remaining:
          type: integer
          example: 9
        resetSeconds:
          type: integer
          description: Seconds until the current rate limit window resets.
          example: 1
        retryAfterSeconds:
          type: integer
          description: Present when the request was rate limited.
          example: 1
  securitySchemes:
    PublicBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Opaque
      description: >-
        Public API access token issued by `/public/v1/oauth/token`. Example:
        `Authorization: Bearer fspt_...`. Each resource request rechecks the
        token company's current provider access. Disabling access blocks
        existing tokens with `403 auth.provider_unavailable`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.