"/pose/whoami":
    get:
        tags: [Pose]
        operationId: poseWhoami
        summary: Pose-app auth probe
        description: Returns the pose-api auth status — used by the pose-analysis factory tool to confirm credentials before pulling jobs.
        security:
            - poseApiKey: []
              poseAccessToken: []
        responses:
            "200":
                description: Caller's pose auth status.
                content:
                    application/json:
                        schema:
                            type: object
                            properties:
                                authorizedApp: { type: string }
                                accountId: { type: string }
                                username: { type: string }
                                authenticated: { type: boolean }
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
        x-access-policies: [PoseAppUser]

"/pose/schemas":
    get:
        tags: [Pose]
        operationId: poseGetSchemas
        summary: Fabricator schema enumerations
        description: Returns the same schema enumerations as `/admin/fabricator/schemas2` — exposed under `/pose/*` so the pose tool can hit it without admin credentials.
        security:
            - poseApiKey: []
              poseAccessToken: []
        responses:
            "200":
                description: V2 schema enumerations.
                content:
                    application/json:
                        schema:
                            type: object
                            additionalProperties:
                                type: array
                                items: { type: string }
                            description: Each top-level key is an enum name; the value is the list of legal members.
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "429":
                description: Rate-limited.
        x-access-policies: [PoseAppUser]

"/pose/jobs":
    get:
        tags: [Pose]
        operationId: poseGetJobs
        summary: List jobs (filtered)
        description: Returns manufacturing jobs with filtering — a pose-tool-friendly subset of `/admin/fabricator/jobs`.
        security:
            - poseApiKey: []
              poseAccessToken: []
        responses:
            "200":
                description: Jobs page.
                content:
                    application/json:
                        schema:
                            type: object
                            properties:
                                items:
                                    type: array
                                    items: { $ref: "../components/schemas/Job.yaml" }
                                count: { type: integer }
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "429":
                description: Rate-limited.
        x-access-policies: [PoseAppUser]

"/pose/job/{jobId}":
    parameters:
        - in: path
          name: jobId
          required: true
          schema: { type: string }
          description: Manufacturing job id.
    get:
        tags: [Pose]
        operationId: poseGetJob
        summary: Fetch one job by id
        description: Returns a single manufacturing job by id.
        security:
            - poseApiKey: []
              poseAccessToken: []
        responses:
            "200":
                description: The job record.
                content:
                    application/json:
                        schema: { $ref: "../components/schemas/Job.yaml" }
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "404":
                description: No job with this id.
                content:
                    application/json:
                        schema: { $ref: "../admin-api.yaml#/components/schemas/Error" }
            "429":
                description: Rate-limited.
        x-access-policies: [PoseAppUser]
    put:
        tags: [Pose]
        operationId: poseUpdateJob
        summary: Update a job
        description: |
            Updates fields on a manufacturing job — pose-app-friendly variant of
            `PUT /admin/fabricator/job/{jobId}`. Subject to the same state-machine rules.
        security:
            - poseApiKey: []
              poseAccessToken: []
        requestBody:
            required: true
            content:
                application/json:
                    schema:
                        type: object
                        additionalProperties: true
        responses:
            "200":
                description: Updated job record.
                content:
                    application/json:
                        schema: { $ref: "../components/schemas/Job.yaml" }
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "404":
                description: No job with this id.
                content:
                    application/json:
                        schema: { $ref: "../admin-api.yaml#/components/schemas/Error" }
            "429":
                description: Rate-limited.
        x-access-policies: [PoseAppUser]

"/pose/job/{jobId}/scan":
    parameters:
        - in: path
          name: jobId
          required: true
          schema: { type: string }
    get:
        tags: [Pose]
        operationId: poseDownloadScan
        summary: Download the scan zip
        description: |
            Downloads the raw scan zip uploaded by the customer's iOS face-scan app.
            Subject to a separate, stricter rate limiter than the rest of `/pose/*` —
            scan files are large.
        security:
            - poseApiKey: []
              poseAccessToken: []
        responses:
            "200":
                description: Scan zip.
                content:
                    application/zip:
                        schema:
                            type: string
                            format: binary
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "404":
                description: No job or no scan file for this id.
                content:
                    application/json:
                        schema: { $ref: "../admin-api.yaml#/components/schemas/Error" }
            "429":
                description: Rate-limited (separate limiter from the rest of `/pose/*`).
        x-access-policies: [PoseAppUser]

"/pose/job/{jobId}/mesh":
    parameters:
        - in: path
          name: jobId
          required: true
          schema: { type: string }
    get:
        tags: [Pose]
        operationId: poseDownloadMesh
        summary: Download the processed mesh
        description: Downloads the processed mesh file (output of the scan preprocessor) for a job.
        security:
            - poseApiKey: []
              poseAccessToken: []
        responses:
            "200":
                description: Mesh file.
                content:
                    application/octet-stream:
                        schema:
                            type: string
                            format: binary
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "404":
                description: No mesh file for this job.
                content:
                    application/json:
                        schema: { $ref: "../admin-api.yaml#/components/schemas/Error" }
            "429":
                description: Rate-limited.
        x-access-policies: [PoseAppUser]

"/pose/job/{jobId}/debug_start_toolpath":
    parameters:
        - in: path
          name: jobId
          required: true
          schema: { type: string }
    get:
        tags: [Pose]
        operationId: poseDebugStartToolPath
        summary: Debug — start toolpath generation
        description: Debug helper that kicks off toolpath generation for a job from the pose tool.
        security:
            - poseApiKey: []
              poseAccessToken: []
        responses:
            "200":
                description: Toolpath generation started.
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "429":
                description: Rate-limited.
        x-access-policies: [PoseAppUser]

"/pose/job/{jobId}/debug_upload_toolpath":
    parameters:
        - in: path
          name: jobId
          required: true
          schema: { type: string }
    put:
        tags: [Pose]
        operationId: poseDebugUploadToolPath
        summary: Debug — upload a toolpath
        description: Debug helper to manually upload a generated toolpath file for a job.
        security:
            - poseApiKey: []
              poseAccessToken: []
        requestBody:
            required: true
            content:
                multipart/form-data:
                    schema:
                        type: object
                        properties:
                            file:
                                type: string
                                format: binary
        responses:
            "200":
                description: Toolpath stored.
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "429":
                description: Rate-limited.
        x-access-policies: [PoseAppUser]

"/pose/job/{jobId}/toolpath":
    parameters:
        - in: path
          name: jobId
          required: true
          schema: { type: string }
    get:
        tags: [Pose]
        operationId: poseDownloadToolPath
        summary: Download the G-code toolpath
        description: Downloads the G-code toolpath file produced for the job, filtered by the job's WaxId.
        security:
            - poseApiKey: []
              poseAccessToken: []
        responses:
            "200":
                description: Toolpath file.
                content:
                    application/octet-stream:
                        schema:
                            type: string
                            format: binary
            "401": { $ref: "../admin-api.yaml#/components/responses/Unauthorized" }
            "403": { $ref: "../admin-api.yaml#/components/responses/Forbidden" }
            "404":
                description: No toolpath for this job.
                content:
                    application/json:
                        schema: { $ref: "../admin-api.yaml#/components/schemas/Error" }
            "429":
                description: Rate-limited.
        x-access-policies: [PoseAppUser]
